Lines
71.42%
5 / 7
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Stream | 71.42% | 5 / 7 | 0.00% | 0 / 1 | 5.58 | 0.00% | 0 / 1 | |||
| __construct | 71.42% | 5 / 7 | 0.00% | 0 / 1 | 5.58 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsclient\Psr7; | |
| 4 | ||
| 5 | /** | |
| 6 | * Layer to change PSR7 implementation if necessary | |
| 7 | * @psalm-suppress PropertyNotSetInConstructor | |
| 8 | */ | |
| 9 | class Stream extends \Slim\Psr7\Stream implements \Psr\Http\Message\StreamInterface | |
| 10 | { | |
| 11 | public function __construct(mixed $stream = null) | |
| 12 | { | |
| 13 | if (null === $stream) { | |
| 14 | $stream = fopen('php://memory', 'w+b'); | |
| 15 | } | |
| 16 | if (!is_resource($stream)) { | |
| 17 | $stream = fopen(is_string($stream) ? $stream : 'php://memory', 'w+b'); | |
| 18 | } | |
| 19 | if (!is_resource($stream)) { | |
| 20 | throw new \RuntimeException('Unable to open stream'); | |
| 21 | } | |
| 22 | parent::__construct($stream); | |
| 23 | } | |
| 24 | } |