| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3.0987 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 10 | public function createStream(string $stringToConvert) |
|
| 18 | { |
||
| 19 | 10 | $stream = fopen('php://memory', 'w+'); |
|
| 20 | 10 | if (!is_resource($stream)) { |
|
| 21 | throw new \RuntimeException("Failed to create stream"); |
||
| 22 | } |
||
| 23 | |||
| 24 | 10 | $wrote = fwrite($stream, $stringToConvert); |
|
| 25 | 10 | if ($wrote !== strlen($stringToConvert)) { |
|
| 26 | throw new \RuntimeException("Failed to write to stream"); |
||
| 27 | } |
||
| 28 | |||
| 29 | 10 | rewind($stream); |
|
| 30 | 10 | return $stream; |
|
| 31 | } |
||
| 47 |