Conditions | 6 |
Paths | 6 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 6.0131 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
24 | 29 | protected function toStream(string $target, $content) |
|
25 | { |
||
26 | 29 | if (is_null($content)) { |
|
27 | 1 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
|
28 | 28 | } elseif (is_bool($content)) { |
|
29 | 2 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
|
30 | 26 | } elseif (is_object($content)) { |
|
31 | 2 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
|
32 | 24 | } elseif (is_resource($content)) { |
|
33 | 1 | rewind($content); |
|
34 | 1 | return $content; |
|
35 | } else { |
||
36 | 23 | $handle = fopen('php://temp', 'rb+'); |
|
37 | 23 | if (false === fwrite($handle, $content)) { |
|
38 | // @codeCoverageIgnoreStart |
||
39 | // must die something with stream reading |
||
40 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
||
41 | } |
||
42 | // @codeCoverageIgnoreEnd |
||
43 | 23 | return $handle; |
|
44 | } |
||
47 |