Total Complexity | 10 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class Message |
||
10 | { |
||
11 | /** |
||
12 | * @var object |
||
13 | */ |
||
14 | private $event; |
||
15 | |||
16 | /** |
||
17 | * @var array |
||
18 | */ |
||
19 | private $headers; |
||
20 | |||
21 | 24 | public function __construct(object $event, array $headers = []) |
|
22 | { |
||
23 | 24 | $this->event = $event; |
|
24 | 24 | $this->headers = $headers; |
|
25 | 24 | } |
|
26 | |||
27 | 4 | public function withHeader(string $key, $value): Message |
|
28 | { |
||
29 | 4 | $clone = clone $this; |
|
30 | 4 | $clone->headers[$key] = $value; |
|
31 | |||
32 | 4 | return $clone; |
|
33 | } |
||
34 | |||
35 | 14 | public function withHeaders(array $headers): Message |
|
36 | { |
||
37 | 14 | $clone = clone $this; |
|
38 | 14 | $clone->headers = $headers + $clone->headers; |
|
39 | |||
40 | 14 | return $clone; |
|
41 | } |
||
42 | |||
43 | 7 | public function aggregateVersion(): int |
|
52 | } |
||
53 | |||
54 | 1 | public function aggregateRootId(): ?AggregateRootId |
|
55 | { |
||
56 | 1 | return $this->headers[Header::AGGREGATE_ROOT_ID] ?? null; |
|
57 | } |
||
58 | |||
59 | 9 | public function timeOfRecording(): PointInTime |
|
62 | } |
||
63 | |||
64 | 12 | public function header(string $key) |
|
65 | { |
||
66 | 12 | return $this->headers[$key] ?? null; |
|
67 | } |
||
68 | |||
69 | 20 | public function headers(): array |
|
70 | { |
||
71 | 20 | return $this->headers; |
|
72 | } |
||
73 | |||
74 | public function event(): object |
||
77 | } |
||
78 | } |
||
79 |