| Conditions | 4 |
| Paths | 6 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | private static function createStream($file = 'php://temp', $mode = 'r+') |
||
| 22 | { |
||
| 23 | $factory = Middleware::getStreamFactory(); |
||
| 24 | $replacing = null; |
||
| 25 | |||
| 26 | if ($file instanceof StreamInterface) { |
||
| 27 | $replacing = $file; |
||
| 28 | $file = 'php://temp'; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($factory === null) { |
||
| 32 | if (class_exists('Zend\\Diactoros\\Stream')) { |
||
| 33 | return new \Zend\Diactoros\Stream($file, $mode); |
||
| 34 | } |
||
| 35 | |||
| 36 | throw new \RuntimeException('Unable to create a stream. No stream factory defined'); |
||
| 37 | } |
||
| 38 | |||
| 39 | return call_user_func($factory, $file, $mode, $replacing); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |