Total Complexity | 7 |
Total Lines | 71 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 3 |
1 | <?php |
||
13 | final class ValidAddingIterator implements AddingIterator |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Ctor. |
||
18 | * |
||
19 | * @phpstan-param AddingIterator<TKey, TValue> $origin |
||
20 | * @param AddingIterator $origin original adding iterator. |
||
21 | */ |
||
22 | public function __construct( |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * {@inheritDoc} |
||
35 | * Only adds values if source is valid. |
||
36 | */ |
||
37 | public function from(Iterator $source): AddingIterator |
||
38 | { |
||
39 | return (new ValidTernary( |
||
40 | $source, |
||
41 | fn (Iterator $iter) => new self($this->origin->from($iter)), |
||
42 | fn () => $this |
||
43 | ))->value(); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritDoc} |
||
48 | */ |
||
49 | public function current(): mixed |
||
50 | { |
||
51 | return $this->origin->current(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritDoc} |
||
56 | */ |
||
57 | public function key(): mixed |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * {@inheritDoc} |
||
64 | */ |
||
65 | public function next(): void |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | public function valid(): bool |
||
74 | { |
||
75 | return $this->origin->valid(); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * {@inheritDoc} |
||
80 | */ |
||
81 | public function rewind(): void |
||
84 | } |
||
85 | } |
||
86 |