Conditions | 4 |
Paths | 3 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface |
||
32 | { |
||
33 | $resource = @fopen($filename, $mode); |
||
34 | if (false === $resource) { |
||
35 | if ('' === $mode or false === in_array($mode[0], self::MODES)) { |
||
36 | throw new InvalidArgumentException('The mode ' . $mode . ' is invalid.'); |
||
37 | } |
||
38 | |||
39 | throw new RuntimeException('The file ' . $filename . ' cannot be opened.'); |
||
40 | } |
||
41 | |||
42 | return Stream::new($resource); |
||
43 | } |
||
44 | } |