| Conditions | 3 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 37 | private static function openFile(string $filename, string $mode) |
||
| 38 | { |
||
| 39 | try { |
||
| 40 | $resource = @fopen($filename, $mode); |
||
| 41 | 14 | } catch (Throwable $e) { |
|
| 42 | $resource = false; |
||
| 43 | 14 | } |
|
| 44 | |||
| 45 | 14 | if (!is_resource($resource)) { |
|
| 46 | 2 | throw new InvalidArgumentException(sprintf( |
|
| 47 | 2 | 'Unable to open the file "%s" in the mode "%s"', |
|
| 48 | 2 | $filename, |
|
| 49 | 2 | $mode |
|
| 50 | 2 | )); |
|
| 51 | } |
||
| 52 | |||
| 53 | 12 | return $resource; |
|
| 54 | } |
||
| 56 |