@@ -15,30 +15,30 @@ |
||
| 15 | 15 | $this->binToLocate = $binToLocate; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function locate(){ |
|
| 19 | - $process = new Process([$this->whichCommand,$this->binToLocate]); |
|
| 18 | + public function locate() { |
|
| 19 | + $process = new Process([$this->whichCommand, $this->binToLocate]); |
|
| 20 | 20 | $process->run(); |
| 21 | 21 | |
| 22 | - if($process->getErrorOutput()){ |
|
| 22 | + if ($process->getErrorOutput()) { |
|
| 23 | 23 | throw BinLocatorException::processFailed($process); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $path = trim($process->getOutput()); |
| 27 | 27 | |
| 28 | - if(!$path){ |
|
| 28 | + if (!$path) { |
|
| 29 | 29 | throw BinLocatorException::notFound($this->binToLocate); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return $path; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function getProcess(array $commandLine){ |
|
| 35 | + public function getProcess(array $commandLine) { |
|
| 36 | 36 | $bin = $this->locate(); |
| 37 | 37 | |
| 38 | 38 | $commandLine = implode(' ', array_merge([$bin], $commandLine)); |
| 39 | 39 | |
| 40 | 40 | //compatibility fix Process >= 5.x |
| 41 | - if(method_exists(Process::class, 'fromShellCommandline')){ |
|
| 41 | + if (method_exists(Process::class, 'fromShellCommandline')) { |
|
| 42 | 42 | return Process::fromShellCommandline($commandLine); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -6,11 +6,11 @@ |
||
| 6 | 6 | |
| 7 | 7 | class BinLocatorException extends \Exception |
| 8 | 8 | { |
| 9 | - public static function notFound($bin){ |
|
| 9 | + public static function notFound($bin) { |
|
| 10 | 10 | return new BinLocatorException(sprintf('Executable "%s" has not been found on system', $bin)); |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | - public static function processFailed(Process $process){ |
|
| 13 | + public static function processFailed(Process $process) { |
|
| 14 | 14 | return new BinLocatorException(sprintf('Something gone wrong executing: %s, returned: %s', $process->getCommandLine(), $process->getErrorOutput())); |
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |