X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Falchemy%2Fzippy%2Fsrc%2FProcessBuilder%2FProcessBuilderFactory.php;fp=vendor%2Falchemy%2Fzippy%2Fsrc%2FProcessBuilder%2FProcessBuilderFactory.php;h=0caaf6a84e194e0e76461963515a612be4dcc666;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php b/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php new file mode 100644 index 000000000..0caaf6a84 --- /dev/null +++ b/vendor/alchemy/zippy/src/ProcessBuilder/ProcessBuilderFactory.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Alchemy\Zippy\ProcessBuilder; + +use Alchemy\Zippy\Exception\InvalidArgumentException; +use Symfony\Component\Process\ProcessBuilder; + +class ProcessBuilderFactory implements ProcessBuilderFactoryInterface +{ + /** + * The binary path + * + * @var string + */ + protected $binary; + + /** + * Constructor + * + * @param string $binary The path to the binary + * + * @throws InvalidArgumentException In case binary path is invalid + */ + public function __construct($binary) + { + $this->useBinary($binary); + } + + /** + * @inheritdoc + */ + public function getBinary() + { + return $this->binary; + } + + /** + * @inheritdoc + */ + public function useBinary($binary) + { + if (!is_executable($binary)) { + throw new InvalidArgumentException(sprintf('`%s` is not an executable binary', $binary)); + } + + $this->binary = $binary; + + return $this; + } + + /** + * @inheritdoc + */ + public function create() + { + if (null === $this->binary) { + throw new InvalidArgumentException('No binary set'); + } + + return ProcessBuilder::create(array($this->binary))->setTimeout(null); + } +}