| Conditions | 3 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 44 | 3 | public function getIterator(): Traversable |
|
| 45 | { |
||
| 46 | 3 | yield from new ClosureIteratorAggregate( |
|
| 47 | /** |
||
| 48 | * @param resource $resource |
||
| 49 | * |
||
| 50 | * @return Generator<int, string, mixed, void> |
||
| 51 | */ |
||
| 52 | 3 | static function ($resource, bool $closeResource = false): Generator { |
|
| 53 | try { |
||
| 54 | 3 | while (false !== $chunk = fgetc($resource)) { |
|
| 55 | 3 | yield $chunk; |
|
| 56 | } |
||
| 57 | 3 | } finally { |
|
| 58 | 3 | if ($closeResource) { |
|
| 59 | 3 | fclose($resource); |
|
| 60 | } |
||
| 61 | } |
||
| 62 | 3 | }, |
|
| 63 | 3 | [$this->resource, $this->closeResource] |
|
| 64 | ); |
||
| 67 |