| Total Complexity | 7 |
| Total Lines | 68 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 4 |
| 1 | <?php |
||
| 14 | final class OpenAddingIterator implements AddingIterator |
||
| 15 | { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Ctor. |
||
| 19 | * |
||
| 20 | * @phpstan-param Iterator<TKey, TValue>&ArrayAccess<TKey, TValue> $added |
||
| 21 | * @param Iterator&ArrayAccess $added iterator with stored values. |
||
| 22 | */ |
||
| 23 | public function __construct( |
||
| 24 | /** |
||
| 25 | * Iterator with stored values. |
||
| 26 | * |
||
| 27 | * @phpstan-var Iterator<TKey, TValue>&ArrayAccess<TKey, TValue> |
||
| 28 | * @var Iterator&ArrayAccess |
||
| 29 | */ |
||
| 30 | private Iterator|ArrayAccess $added |
||
| 31 | ) { |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritDoc} |
||
| 36 | */ |
||
| 37 | public function from(Iterator $source): AddingIterator |
||
| 38 | { |
||
| 39 | $updated = clone $this->added; |
||
| 40 | $updated[$source->key()] ??= $source->current(); |
||
| 41 | return new self($updated); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * {@inheritDoc} |
||
| 46 | */ |
||
| 47 | public function current(): mixed |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * {@inheritDoc} |
||
| 54 | */ |
||
| 55 | public function key(): mixed |
||
| 56 | { |
||
| 57 | return $this->added->key(); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * {@inheritDoc} |
||
| 62 | */ |
||
| 63 | public function next(): void |
||
| 64 | { |
||
| 65 | $this->added->next(); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * {@inheritDoc} |
||
| 70 | */ |
||
| 71 | public function valid(): bool |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * {@inheritDoc} |
||
| 78 | */ |
||
| 79 | public function rewind(): void |
||
| 82 | } |
||
| 83 | } |
||
| 84 |