public function request($type, $file = null)
    {
        // check if not checked
        $this->check();

        // check if is cached
        if(isset($this->cache[sha1($file)][$type]))
        {
            return $this->cache[sha1($file)][$type];
        }

        // command arguments
        $arguments = $this->getArguments($type, $file);

        // check the request
        $file = parent::checkRequest($type, $file);

        // add last argument
        if($file)
        {
            $arguments[] = escapeshellarg($file);
        }

        // build command
        $jar = escapeshellarg($this->path);
        $command = ($this->java ?: 'java') . " -jar $jar " . implode(' ', $arguments);

        // run command
        $response = $this->exec($command);

        // metadata response
        if($type == 'meta')
        {
            // fix for invalid? json returned only with images
            $response = str_replace(basename($file) . '"}{', '", ', $response);

            // on Windows, response comes in another charset
            if(defined('PHP_WINDOWS_VERSION_MAJOR'))
            {
                $response = utf8_encode($response);
            }

            $response = Metadata::make($response, $file);
        }

        // cache certain responses
        if(in_array($type, ['lang', 'meta']))
        {
            $this->cache[sha1($file)][$type] = $response;
        }

        return $response;
    }
public function request($type, $file = null)
    {
        // check if not checked
        $this->check();

        // check if is cached
        if(isset($this->cache[sha1($file)][$type]))
        {
            return $this->cache[sha1($file)][$type];
        }

        // command arguments
        $arguments = $this->getArguments($type, $file);

        // check the request
        $file = parent::checkRequest($type, $file);

        // add last argument
        if($file)
        {
            $arguments[] = escapeshellarg($file);
        }

        // build command
        $jar = escapeshellarg($this->path);
        $command = ($this->java ?: 'java') . " -jar $jar " . implode(' ', $arguments);

        // run command
        $response = $this->exec($command);

        // metadata response
        if($type == 'meta')
        {
            // fix for invalid? json returned only with images
            $response = str_replace(basename($file) . '"}{', '", ', $response);

            // on Windows, response comes in another charset
            if(defined('PHP_WINDOWS_VERSION_MAJOR'))
            {
                $response = utf8_encode($response);
            }

            $response = Metadata::make($response, $file);
        }

        // cache certain responses
        if(in_array($type, ['lang', 'meta']))
        {
            $this->cache[sha1($file)][$type] = $response;
        }

        return $response;
    }
public function request ( $ type , $ file = null ) { // check if not checked $ this -> check ( ) ; // check if is cached if ( isset ( $ this -> cache [ sha1 ( $ file ) ] [ $ type ] ) ) { return $ this -> cache [ sha1 ( $ file ) ] [ $ type ] ; } // command arguments $ arguments = $ this -> getArguments ( $ type , $ file ) ; // check the request $ file = parent :: checkRequest ( $ type , $ file ) ; // add last argument if ( $ file ) { $ arguments [ ] = escapeshellarg ( $ file ) ; } // build command $ jar = escapeshellarg ( $ this -> path ) ; $ command = ( $ this -> java ? : 'java' ) . " -jar $jar " . implode ( ' ' , $ arguments ) ; // run command $ response = $ this -> exec ( $ command ) ; // metadata response if ( $ type == 'meta' ) { // fix for invalid? json returned only with images $ response = str_replace ( basename ( $ file ) . '"}{' , '", ' , $ response ) ; // on Windows, response comes in another charset if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { $ response = utf8_encode ( $ response ) ; } $ response = Metadata :: make ( $ response , $ file ) ; } // cache certain responses if ( in_array ( $ type , [ 'lang' , 'meta' ] ) ) { $ this -> cache [ sha1 ( $ file ) ] [ $ type ] = $ response ; } return $ response ; }
Configure and make a request and return its results

@param   string  $type
@param   string  $file
@return  string
@throws  \Exception
Configure and make a request and return its results