<?php
namespace App\Archive\Uncompress;

/**
 * Uncompress files with .7zip extension
 * @author oana
 */
class Zip7 extends UncompressAbstractClass
{

	/**
	 * Extract file into specified destination
	 */
	public function extractTo($pathDestination)
	{
		$command = sprintf("7ze e %s -o %s", escapeshellarg($this->location), escapeshellarg($pathDestination));
		$processObject = new \Engine\Os\Command\Process($command);
		$processObject->runAndCaptureErrors();
		$outputObject = $processObject->getCommandOutputObj();

		if ($outputObject->hasError()) {
			throw new \RuntimeException(sprintf("Uncompress failed. `%s` returned [%s]%s.", $command, $outputObject->getErrorNumber(), $outputObject->getOutput()));
		}

		return parent::extractTo($pathDestination);
	}
}