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 | 11 | public function createStream(string $stringToConvert) |
|
18 | { |
||
19 | 11 | $stream = fopen('php://memory', 'w+'); |
|
20 | 11 | if (!is_resource($stream)) { |
|
21 | throw new \RuntimeException("Failed to create stream"); |
||
22 | } |
||
23 | |||
24 | 11 | $wrote = fwrite($stream, $stringToConvert); |
|
25 | 11 | if ($wrote !== strlen($stringToConvert)) { |
|
26 | throw new \RuntimeException("Failed to write to stream"); |
||
27 | } |
||
28 | |||
29 | 11 | rewind($stream); |
|
30 | 11 | return $stream; |
|
31 | } |
||
47 |