| @@ 90-98 (lines=9) @@ | ||
| 87 | * @return string |
|
| 88 | * @throws \RuntimeException |
|
| 89 | */ |
|
| 90 | public static function detectCmdLocationInPath(string $cmd, string $path) : string |
|
| 91 | { |
|
| 92 | $command = $path . DIRECTORY_SEPARATOR . $cmd; |
|
| 93 | $bin = self::getExecutable($command); |
|
| 94 | if (empty($bin)) { |
|
| 95 | throw new RuntimeException(sprintf('wrong path specified for \'%s\': %s', $cmd, $path)); |
|
| 96 | } |
|
| 97 | return $bin; |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * Detect command location using which cli command. |
|
| @@ 125-135 (lines=11) @@ | ||
| 122 | * @param array $paths |
|
| 123 | * @return string |
|
| 124 | */ |
|
| 125 | public static function detectCmdLocationInPaths($cmd, array $paths) : string |
|
| 126 | { |
|
| 127 | foreach ($paths as $path) { |
|
| 128 | $command = $path . DIRECTORY_SEPARATOR . $cmd; |
|
| 129 | $bin = self::getExecutable($command); |
|
| 130 | if (null !== $bin) { |
|
| 131 | return $bin; |
|
| 132 | } |
|
| 133 | } |
|
| 134 | return ''; |
|
| 135 | } |
|
| 136 | ||
| 137 | /** |
|
| 138 | * Return local $PATH variable. |
|