| Conditions | 7 |
| Paths | 7 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 7.0957 |
| Changes | 2 | ||
| 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 === $handle) { |
|
| 38 | // @codeCoverageIgnoreStart |
||
| 39 | // must die something with stream reading |
||
| 40 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
||
| 41 | } |
||
| 42 | // @codeCoverageIgnoreEnd |
||
| 43 | 23 | if (false === fwrite($handle, $content)) { |
|
| 44 | // @codeCoverageIgnoreStart |
||
| 45 | // must die something with stream reading |
||
| 46 | throw new FilesException($this->getLang()->flCannotLoadFile($target)); |
||
| 47 | } |
||
| 48 | // @codeCoverageIgnoreEnd |
||
| 49 | 23 | return $handle; |
|
| 50 | } |
||
| 53 |