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;
    }