| Conditions | 6 |
| Paths | 6 |
| Total Lines | 21 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.0131 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | 11 | protected function toString($content): string |
|
| 24 | { |
||
| 25 | 11 | if (is_null($content)) { |
|
| 26 | 1 | throw new MenuException($this->getMnLang()->mnProblematicData()); |
|
| 27 | 10 | } elseif (is_bool($content)) { |
|
| 28 | 2 | throw new MenuException($this->getMnLang()->mnProblematicData()); |
|
| 29 | 8 | } elseif (is_resource($content)) { |
|
| 30 | 1 | rewind($content); |
|
| 31 | 1 | $data = stream_get_contents($content, -1, 0); |
|
| 32 | 1 | if (false === $data) { |
|
| 33 | // @codeCoverageIgnoreStart |
||
| 34 | // must die something with stream reading |
||
| 35 | throw new MenuException($this->getMnLang()->mnCannotOpen()); |
||
| 36 | } |
||
| 37 | // @codeCoverageIgnoreEnd |
||
| 38 | 1 | return strval($data); |
|
| 39 | } else { |
||
| 40 | try { |
||
| 41 | 7 | return strval($content); |
|
| 42 | 1 | } catch (\Error $ex) { |
|
| 43 | 1 | throw new MenuException($ex->getMessage(), $ex->getCode(), $ex); |
|
| 44 | } |
||
| 48 |