@@ 121-129 (lines=9) @@ | ||
118 | * @return string |
|
119 | * @throws \RuntimeException |
|
120 | */ |
|
121 | public static function detectCmdLocationInPath(string $cmd, string $path) : string |
|
122 | { |
|
123 | $command = $path . DIRECTORY_SEPARATOR . $cmd; |
|
124 | $bin = self::isExecutable($command); |
|
125 | if (empty($bin)) { |
|
126 | throw new RuntimeException(sprintf('wrong path specified for \'%s\': %s', $cmd, $path)); |
|
127 | } |
|
128 | return $bin; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * Detect command location using which cli command. |
|
@@ 156-166 (lines=11) @@ | ||
153 | * @param array $paths |
|
154 | * @return string |
|
155 | */ |
|
156 | public static function detectCmdLocationInPaths($cmd, array $paths) : string |
|
157 | { |
|
158 | foreach ($paths as $path) { |
|
159 | $command = $path . DIRECTORY_SEPARATOR . $cmd; |
|
160 | $bin = self::isExecutable($command); |
|
161 | if (null !== $bin) { |
|
162 | return $bin; |
|
163 | } |
|
164 | } |
|
165 | return ''; |
|
166 | } |
|
167 | ||
168 | /** |
|
169 | * Return local $PATH variable. |