4 * This file is part of Zippy.
6 * (c) Alchemy <info@alchemy.fr>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Alchemy\Zippy\ProcessBuilder;
14 use Alchemy\Zippy\Exception\InvalidArgumentException;
15 use Symfony\Component\Process\ProcessBuilder;
17 class ProcessBuilderFactory implements ProcessBuilderFactoryInterface
29 * @param string $binary The path to the binary
31 * @throws InvalidArgumentException In case binary path is invalid
33 public function __construct($binary)
35 $this->useBinary($binary);
41 public function getBinary()
49 public function useBinary($binary)
51 if (!is_executable($binary)) {
52 throw new InvalidArgumentException(sprintf('`%s` is not an executable binary', $binary));
55 $this->binary = $binary;
63 public function create()
65 if (null === $this->binary) {
66 throw new InvalidArgumentException('No binary set');
69 return ProcessBuilder::create(array($this->binary))->setTimeout(null);