| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public static function getFileContents(string $file): string |
||
| 22 | { |
||
| 23 | if (!is_readable($file)) { |
||
| 24 | throw new RuntimeException(sprintf( |
||
| 25 | 'File "%s" does not exist or is not readable', |
||
| 26 | $file, |
||
| 27 | )); |
||
| 28 | } |
||
| 29 | |||
| 30 | $contents = file_get_contents($file); |
||
| 31 | if ($contents === false) { |
||
| 32 | throw new RuntimeException(sprintf( |
||
| 33 | 'Could not read from existing and readable file "%s"', |
||
| 34 | $file, |
||
| 35 | )); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $contents; |
||
| 39 | } |
||
| 41 |