| Total Complexity | 9 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 88.24% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class Collection implements \IteratorAggregate, \Countable |
||
| 8 | { |
||
| 9 | protected array $items; |
||
| 10 | |||
| 11 | 5 | final public function __construct(iterable $items) |
|
| 12 | { |
||
| 13 | 5 | $this->items = $items instanceof \Traversable ? iterator_to_array($items) : $items; |
|
| 14 | 5 | $this->assertType(); |
|
| 15 | 4 | } |
|
| 16 | |||
| 17 | public function getItems(): array |
||
| 20 | } |
||
| 21 | |||
| 22 | 2 | public function count(): int |
|
| 23 | { |
||
| 24 | 2 | return count($this->items); |
|
| 25 | } |
||
| 26 | |||
| 27 | 1 | public function filter(callable $filter): static |
|
| 28 | { |
||
| 29 | 1 | return new static(array_filter($this->items, $filter)); |
|
| 30 | } |
||
| 31 | |||
| 32 | 2 | public function getIterator(): \ArrayIterator |
|
| 35 | } |
||
| 36 | |||
| 37 | abstract protected function getType(): string; |
||
| 38 | |||
| 39 | 5 | private function assertType(): void |
|
| 46 | } |
||
| 47 | } |
||
| 50 |