Total Complexity | 9 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 77.78% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | abstract class Collection implements \IteratorAggregate, \Countable |
||
12 | { |
||
13 | protected array $items; |
||
14 | |||
15 | 6 | final public function __construct(iterable $items) |
|
16 | { |
||
17 | 6 | $this->items = $items instanceof \Traversable ? iterator_to_array($items) : $items; |
|
18 | 6 | $this->assertType(); |
|
19 | 5 | } |
|
20 | |||
21 | public function getItems(): array |
||
22 | { |
||
23 | return $this->items; |
||
24 | } |
||
25 | |||
26 | 2 | public function count(): int |
|
29 | } |
||
30 | |||
31 | public function isEmpty(): bool |
||
34 | } |
||
35 | |||
36 | 1 | public function filter(callable $filter): static |
|
37 | { |
||
38 | 1 | return new static(array_filter($this->items, $filter)); |
|
39 | } |
||
40 | |||
41 | 3 | public function getIterator(): \ArrayIterator |
|
44 | } |
||
45 | |||
46 | abstract protected function getType(): string; |
||
47 | |||
48 | 6 | private function assertType(): void |
|
54 | } |
||
55 | 5 | } |
|
57 |