| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 60% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class JsonResource extends Source |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Retrieve the JSON fragments |
||
| 19 | * |
||
| 20 | * @return Traversable<int, string> |
||
| 21 | */ |
||
| 22 | 2 | public function getIterator(): Traversable |
|
| 23 | { |
||
| 24 | 2 | while (!feof($this->source)) { |
|
| 25 | 2 | if (is_string($chunk = fread($this->source, $this->config->bytes))) { |
|
| 26 | 2 | yield $chunk; |
|
| 27 | } |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Determine whether the JSON source can be handled |
||
| 33 | * |
||
| 34 | * @return bool |
||
| 35 | */ |
||
| 36 | 1 | public function matches(): bool |
|
| 37 | { |
||
| 38 | 1 | return is_resource($this->source); |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Retrieve the calculated size of the JSON source |
||
| 43 | * |
||
| 44 | * @return int|null |
||
| 45 | */ |
||
| 46 | protected function calculateSize(): ?int |
||
| 52 | } |
||
| 53 | } |
||
| 54 |