Issues (77)

src/UseCase/Metadata.php (1 issue)

Labels
Severity
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
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 15 at column 6
Loading history...
16
{
17
    /**
18
     * @param array<string, mixed> $metadata
19
     */
20 15
    public function __construct(
21
        public array $metadata = [],
22 15
    ) {}
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