| Conditions | 3 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3.054 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 45 | 5 | private static function openFile(string $filename, string $mode) |
|
| 46 | { |
||
| 47 | try { |
||
| 48 | 5 | $resource = @fopen($filename, $mode); |
|
| 49 | } catch (Throwable $e) { |
||
| 50 | $resource = false; |
||
| 51 | } |
||
| 52 | |||
| 53 | 5 | if (!is_resource($resource)) { |
|
| 54 | 1 | throw new InvalidArgumentException(sprintf( |
|
| 55 | 1 | 'Unable to open the file "%s" in the mode "%s"', |
|
| 56 | 1 | $filename, |
|
| 57 | 1 | $mode, |
|
| 58 | 1 | )); |
|
| 59 | } |
||
| 60 | |||
| 61 | 4 | return $resource; |
|
| 62 | } |
||
| 64 |