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