| Total Complexity | 9 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class Executable |
||
| 10 | { |
||
| 11 | /** @var Interactor */ |
||
| 12 | protected $io; |
||
| 13 | |||
| 14 | /** @var string The binary executable */ |
||
| 15 | protected $binary; |
||
| 16 | |||
| 17 | /** @var string */ |
||
| 18 | protected $workDir; |
||
| 19 | |||
| 20 | public function __construct($binary = null) |
||
| 21 | { |
||
| 22 | $this->workDir = \getcwd(); |
||
| 23 | $this->binary = $binary ? '"' . $binary . '"' : $this->binary; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function withWorkDir($workDir = null) |
||
| 27 | { |
||
| 28 | if (!\is_dir($workDir)) { |
||
| 29 | throw new \InvalidArgumentException('Not a valid working dir: ' . $workDir); |
||
| 30 | } |
||
| 31 | |||
| 32 | $this->workDir = $workDir; |
||
| 33 | |||
| 34 | return $this; |
||
| 35 | } |
||
| 36 | |||
| 37 | protected function findBinary($binary) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Runs the command using underlying binary. |
||
| 50 | * |
||
| 51 | * @param string $command |
||
| 52 | * |
||
| 53 | * @return string|null The output of command. |
||
| 54 | */ |
||
| 55 | protected function runCommand($command) |
||
| 64 | } |
||
| 65 | } |
||
| 67 |