public static function make($response, $file)
    {
        // an empty response throws an error
        if(empty($response) || trim($response) == '')
        {
            throw new Exception('Empty response');
        }

        // decode the JSON response
        $meta = json_decode($response);

        // exceptions if metadata is not valid
        if(json_last_error())
        {
            $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'Error parsing JSON response';

            throw new Exception($message, json_last_error());
        }

        // get content type
        $mime = is_array($meta->{'Content-Type'}) ? current($meta->{'Content-Type'}) : $meta->{'Content-Type'};

        // instance based on content type
        switch(current(explode('/', $mime)))
        {
            case 'image':
                $instance = new ImageMetadata($meta, $file);
                break;

            default:
                $instance = new DocumentMetadata($meta, $file);
        }

        return $instance;
    }
public static function make($response, $file)
    {
        // an empty response throws an error
        if(empty($response) || trim($response) == '')
        {
            throw new Exception('Empty response');
        }

        // decode the JSON response
        $meta = json_decode($response);

        // exceptions if metadata is not valid
        if(json_last_error())
        {
            $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'Error parsing JSON response';

            throw new Exception($message, json_last_error());
        }

        // get content type
        $mime = is_array($meta->{'Content-Type'}) ? current($meta->{'Content-Type'}) : $meta->{'Content-Type'};

        // instance based on content type
        switch(current(explode('/', $mime)))
        {
            case 'image':
                $instance = new ImageMetadata($meta, $file);
                break;

            default:
                $instance = new DocumentMetadata($meta, $file);
        }

        return $instance;
    }
public static function make ( $ response , $ file ) { // an empty response throws an error if ( empty ( $ response ) || trim ( $ response ) == '' ) { throw new Exception ( 'Empty response' ) ; } // decode the JSON response $ meta = json_decode ( $ response ) ; // exceptions if metadata is not valid if ( json_last_error ( ) ) { $ message = function_exists ( 'json_last_error_msg' ) ? json_last_error_msg ( ) : 'Error parsing JSON response' ; throw new Exception ( $ message , json_last_error ( ) ) ; } // get content type $ mime = is_array ( $ meta -> { 'Content-Type' } ) ? current ( $ meta -> { 'Content-Type' } ) : $ meta -> { 'Content-Type' } ; // instance based on content type switch ( current ( explode ( '/' , $ mime ) ) ) { case 'image' : $ instance = new ImageMetadata ( $ meta , $ file ) ; break ; default : $ instance = new DocumentMetadata ( $ meta , $ file ) ; } return $ instance ; }
Return an instance of Metadata based on content type

@param   string  $response
@param   string  $file
@return  \Vaites\ApacheTika\Metadata\Metadata
@throws  \Exception
Return an instance of Metadata based on content type