protected function extractArchive($filename, $destination, $service = null, $localhost = false)
    {
        $mime_type = null;

        if (file_exists($filename) && $localhost) {
            $mime_type = mime_content_type($filename);
        } else {
            $engine = $this->getEngineInstance();

            if ($engine instanceof DockerEngineType) {
                $mime_type = $engine->getFileMimeType($filename, $service);
            }
        }
        $command = null;

        switch ($mime_type) {
            case 'application/gzip':
            case 'application/x-gzip':
                $command = (new CommandBuilder('gunzip', $localhost))
                    ->command("-c {$filename} > {$destination}");
                break;
        }

        if (!isset($command)) {
            return $filename;
        }

        // Remove destination file if on localhost.
        if (file_exists($destination) && $localhost) {
            $this->_remove($destination);
        }
        $this->executeEngineCommand($command, $service, [], false, $localhost);

        return $destination;
    }
protected function extractArchive($filename, $destination, $service = null, $localhost = false)
    {
        $mime_type = null;

        if (file_exists($filename) && $localhost) {
            $mime_type = mime_content_type($filename);
        } else {
            $engine = $this->getEngineInstance();

            if ($engine instanceof DockerEngineType) {
                $mime_type = $engine->getFileMimeType($filename, $service);
            }
        }
        $command = null;

        switch ($mime_type) {
            case 'application/gzip':
            case 'application/x-gzip':
                $command = (new CommandBuilder('gunzip', $localhost))
                    ->command("-c {$filename} > {$destination}");
                break;
        }

        if (!isset($command)) {
            return $filename;
        }

        // Remove destination file if on localhost.
        if (file_exists($destination) && $localhost) {
            $this->_remove($destination);
        }
        $this->executeEngineCommand($command, $service, [], false, $localhost);

        return $destination;
    }
protected function extractArchive ( $ filename , $ destination , $ service = null , $ localhost = false ) { $ mime_type = null ; if ( file_exists ( $ filename ) && $ localhost ) { $ mime_type = mime_content_type ( $ filename ) ; } else { $ engine = $ this -> getEngineInstance ( ) ; if ( $ engine instanceof DockerEngineType ) { $ mime_type = $ engine -> getFileMimeType ( $ filename , $ service ) ; } } $ command = null ; switch ( $ mime_type ) { case 'application/gzip' : case 'application/x-gzip' : $ command = ( new CommandBuilder ( 'gunzip' , $ localhost ) ) -> command ( "-c {$filename} > {$destination}" ) ; break ; } if ( ! isset ( $ command ) ) { return $ filename ; } // Remove destination file if on localhost. if ( file_exists ( $ destination ) && $ localhost ) { $ this -> _remove ( $ destination ) ; } $ this -> executeEngineCommand ( $ command , $ service , [ ] , false , $ localhost ) ; return $ destination ; }
Extract archive within appropriate environment.

@param $filename
The path to the file archive.
@param $destination
The destination path of extracted data.
@param string|null $service
The service name.
@param bool $localhost
Extract archive on host.
@return null|boolean
@throws \Exception
Extract archive within appropriate environment .