|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Event Sourcing implementation. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Maksim Masiukevich <[email protected]> |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types = 1); |
|
12
|
|
|
|
|
13
|
|
|
namespace ServiceBus\EventSourcing\EventStream\Store; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Aggregate event stream data. |
|
17
|
|
|
* |
|
18
|
|
|
* @psalm-immutable |
|
19
|
|
|
*/ |
|
20
|
|
|
final class StoredAggregateEventStream |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* Aggregate id. |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
public $aggregateId; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Aggregate id class. |
|
31
|
|
|
* |
|
32
|
|
|
* @psalm-var class-string<\ServiceBus\EventSourcing\AggregateId> |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
*/ |
|
36
|
|
|
public $aggregateIdClass; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Aggregate class. |
|
40
|
|
|
* |
|
41
|
|
|
* @psalm-var class-string<\ServiceBus\EventSourcing\Aggregate> |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
public $aggregateClass; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Stored events data. |
|
49
|
|
|
* |
|
50
|
|
|
* @psalm-var array<int, \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent> |
|
51
|
|
|
* |
|
52
|
|
|
* @var \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent[] |
|
53
|
|
|
*/ |
|
54
|
|
|
public $storedAggregateEvents; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Stream created at datetime. |
|
58
|
|
|
* |
|
59
|
|
|
* @var string |
|
60
|
|
|
*/ |
|
61
|
|
|
public $createdAt; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Stream closed at datetime. |
|
65
|
|
|
* |
|
66
|
|
|
* @var string|null |
|
67
|
|
|
*/ |
|
68
|
|
|
public $closedAt = null; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @psalm-param class-string<\ServiceBus\EventSourcing\AggregateId> $aggregateIdClass |
|
72
|
|
|
* @psalm-param class-string<\ServiceBus\EventSourcing\Aggregate> $aggregateClass |
|
73
|
|
|
* @psalm-param array<int, \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent> $storedAggregateEvents |
|
74
|
|
|
* |
|
75
|
|
|
* @param \ServiceBus\EventSourcing\EventStream\Store\StoredAggregateEvent[] $storedAggregateEvents |
|
76
|
|
|
*/ |
|
77
|
7 |
|
public function __construct( |
|
78
|
|
|
string $aggregateId, |
|
79
|
|
|
string $aggregateIdClass, |
|
80
|
|
|
string $aggregateClass, |
|
81
|
|
|
array $storedAggregateEvents, |
|
82
|
|
|
string $createdAt, |
|
83
|
|
|
?string $closedAt = null |
|
84
|
|
|
) { |
|
85
|
7 |
|
$this->aggregateId = $aggregateId; |
|
86
|
7 |
|
$this->aggregateIdClass = $aggregateIdClass; |
|
87
|
7 |
|
$this->aggregateClass = $aggregateClass; |
|
88
|
7 |
|
$this->storedAggregateEvents = $storedAggregateEvents; |
|
89
|
7 |
|
$this->createdAt = $createdAt; |
|
90
|
7 |
|
$this->closedAt = $closedAt; |
|
91
|
7 |
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|