Conditions | 5 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | 9 | public function createStream($body = null) |
|
22 | 2 | { |
|
23 | if ($body instanceof StreamInterface) { |
||
24 | return $body; |
||
25 | 7 | } |
|
26 | 3 | ||
27 | if (is_resource($body)) { |
||
28 | return new Stream($body); |
||
29 | 4 | } |
|
30 | 4 | ||
31 | 4 | $resource = fopen('php://memory', 'r+'); |
|
32 | 2 | $stream = new Stream($resource); |
|
|
|||
33 | if (null !== $body && '' !== $body) { |
||
34 | $stream->write((string) $body); |
||
35 | 4 | } |
|
36 | |||
37 | return $stream; |
||
38 | } |
||
40 |