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