Conditions | 6 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public function ensureIsExecutable(string $binaryFile): void |
||
17 | { |
||
18 | // Case of binary (no path given), we cannot tell |
||
19 | if (basename($binaryFile) === $binaryFile) { |
||
20 | $exists = true; // assume it exists |
||
21 | $executable = true; |
||
22 | } else { |
||
23 | $exists = file_exists($binaryFile); |
||
24 | $executable = is_executable($binaryFile); |
||
25 | } |
||
26 | |||
27 | if (!$exists || !$executable) { |
||
28 | throw new MissingBinaryException(sprintf( |
||
29 | 'Missing \'%s\' binary: (exists: %s, executable: %s)', |
||
30 | $binaryFile, |
||
31 | $exists ? 'true' : 'false', |
||
32 | $executable ? 'true' : 'false' |
||
33 | )); |
||
37 |