GemberPHP /
event-sourcing
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace Gember\EventSourcing\UseCase; |
||
| 6 | |||
| 7 | use IteratorAggregate; |
||
| 8 | use ArrayIterator; |
||
| 9 | use Override; |
||
| 10 | use Traversable; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @implements IteratorAggregate<string, mixed> |
||
| 14 | */ |
||
| 15 | final readonly class Metadata implements IteratorAggregate |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @param array<string, mixed> $metadata |
||
| 19 | */ |
||
| 20 | 18 | public function __construct( |
|
| 21 | public array $metadata = [], |
||
| 22 | 18 | ) {} |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @param array<string, mixed> $metadata |
||
| 26 | */ |
||
| 27 | 1 | public function addMetadata(array $metadata): self |
|
| 28 | { |
||
| 29 | 1 | return new self([ |
|
| 30 | 1 | ...$this->metadata, |
|
| 31 | 1 | ...$metadata, |
|
| 32 | 1 | ]); |
|
| 33 | } |
||
| 34 | |||
| 35 | 5 | #[Override] |
|
| 36 | public function getIterator(): Traversable |
||
| 37 | { |
||
| 38 | 5 | return new ArrayIterator($this->metadata); |
|
| 39 | } |
||
| 40 | } |
||
| 41 |