| Conditions | 4 |
| Paths | 4 |
| Total Lines | 26 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 40 | public static function get_executable_path( $paths ) { |
||
| 41 | |||
| 42 | if ( ! function_exists( 'proc_open' ) ) { |
||
| 43 | return false; |
||
| 44 | } |
||
| 45 | |||
| 46 | $paths = array_map( 'wp_normalize_path', $paths ); |
||
| 47 | |||
| 48 | foreach ( $paths as $path ) { |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Attempt to call `--version` on each path, the one which works |
||
| 52 | * must be the correct path. |
||
| 53 | */ |
||
| 54 | $process = new Process( $path . ' --version' ); |
||
| 55 | $process->run(); |
||
| 56 | |||
| 57 | // If the command executed successfully then this must be the correct path |
||
| 58 | if ( $process->isSuccessful() ) { |
||
| 59 | return $path; |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | return false; |
||
| 64 | |||
| 65 | } |
||
| 66 | } |
||
| 67 |