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); |
||
37 | 5 | private static function openFile(string $filename, string $mode) |
|
38 | { |
||
39 | try { |
||
40 | 5 | $resource = @fopen($filename, $mode); |
|
41 | } catch (Throwable $e) { |
||
42 | $resource = false; |
||
43 | } |
||
44 | |||
45 | 5 | if (!is_resource($resource)) { |
|
46 | 1 | throw new InvalidArgumentException(sprintf( |
|
47 | 1 | 'Unable to open the file "%s" in the mode "%s"', |
|
48 | 1 | $filename, |
|
49 | 1 | $mode |
|
50 | 1 | )); |
|
51 | } |
||
52 | |||
53 | 4 | return $resource; |
|
54 | } |
||
56 |