<?php
namespace App\Archive\Uncompress;

/**
 * Base class for uncompress files
 * @author oana
 */
abstract class UncompressAbstractClass implements UncompressInterface, \App\Utils\BaseParser\NoParamsConstructorInterface
{
	/**
	 * Stores path of achive
	 * @var String
	 */
	protected $location = '';

	public function __construct()
	{
		// do nothing
	}

	/**
	 * Returns the singleton instantiation of compress class
	 * @return \App\Archive\Uncompress\UncompressAbstractClass
	 */
	static function create()
	{
		return new static();
	}


	public function open($location)
	{
		// check if location is file
		if (!is_file($location)) {
			throw new \Exception("Location is not file");
		}

		$this->location = $location;

		return $this;
	}

	/**
	 * Close file(non-PHPdoc)
	 * @see App\Archive\Uncompress.UncompressInterface::close()
	 */
	public function close()
	{
	}

	/**
	 * Function which extract file into specified destionation(non-PHPdoc)
	 * @see App\Archive\Uncompress.UncompressInterface::extractTo()
	 */
	public function extractTo($pathDestination)
	{
		return $this;
	}

	/**
	 * (non-PHPdoc)
	 * @see \App\Archive\Uncompress\UncompressInterface::test()
	 */
	public function test()
	{
		return $this;
	}
}