| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Psr7Stream extends Source |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Retrieve the JSON fragments |
||
| 19 | * |
||
| 20 | * @return Traversable<int, string> |
||
| 21 | */ |
||
| 22 | 1 | public function getIterator(): Traversable |
|
| 23 | { |
||
| 24 | 1 | if (!in_array(StreamWrapper::NAME, stream_get_wrappers())) { |
|
| 25 | 1 | stream_wrapper_register(StreamWrapper::NAME, StreamWrapper::class); |
|
| 26 | } |
||
| 27 | |||
| 28 | 1 | $stream = fopen(StreamWrapper::NAME . '://stream', 'rb', false, stream_context_create([ |
|
| 29 | 1 | StreamWrapper::NAME => ['stream' => $this->source], |
|
| 30 | 1 | ])); |
|
| 31 | |||
| 32 | 1 | return new JsonResource($stream, $this->config); |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Determine whether the JSON source can be handled |
||
| 37 | * |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | 2 | public function matches(): bool |
|
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Retrieve the calculated size of the JSON source |
||
| 47 | * |
||
| 48 | * @return int|null |
||
| 49 | */ |
||
| 50 | 1 | protected function calculateSize(): ?int |
|
| 55 |