| Total Complexity | 8 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 3 |
| 1 | <?php |
||
| 13 | final class ArrayAddingIterator implements AddingIterator |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Ctor. |
||
| 18 | * |
||
| 19 | * @phpstan-param array<TKey, TValue> $added |
||
| 20 | * @param mixed[] $added added values. |
||
| 21 | */ |
||
| 22 | public function __construct( |
||
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * {@inheritDoc} |
||
| 34 | */ |
||
| 35 | public function from(Iterator $source): AddingIterator |
||
| 36 | { |
||
| 37 | return new self( |
||
| 38 | array_merge( |
||
| 39 | $this->added, |
||
| 40 | (isset($this->added[$source->key()])) |
||
| 41 | ? [] |
||
| 42 | : [$source->key() => $source->current()] |
||
| 43 | ) |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritDoc} |
||
| 49 | */ |
||
| 50 | public function current(): mixed |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * {@inheritDoc} |
||
| 57 | * @phpstan-return int|string|null |
||
| 58 | */ |
||
| 59 | public function key(): mixed |
||
| 60 | { |
||
| 61 | return key($this->added); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * {@inheritDoc} |
||
| 66 | */ |
||
| 67 | public function next(): void |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritDoc} |
||
| 74 | */ |
||
| 75 | public function valid(): bool |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * {@inheritDoc} |
||
| 82 | */ |
||
| 83 | public function rewind(): void |
||
| 86 | } |
||
| 87 | } |
||
| 88 |