1 | <?php |
||
9 | class ProjectionBuilder |
||
10 | { |
||
11 | /** |
||
12 | * @var EventStoreInterface |
||
13 | */ |
||
14 | private $eventStore; |
||
15 | |||
16 | /** |
||
17 | * @var callable |
||
18 | */ |
||
19 | private $stateInitializer; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $from; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $forEachStream; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $eventHandlers; |
||
35 | |||
36 | /** |
||
37 | * @var Projector |
||
38 | */ |
||
39 | private $projector; |
||
40 | |||
41 | /** |
||
42 | * @param EventStoreInterface $eventStore |
||
43 | */ |
||
44 | 8 | public function __construct(EventStoreInterface $eventStore) |
|
53 | |||
54 | /** |
||
55 | * @param callable $stateInitializer |
||
56 | * @return $this |
||
57 | */ |
||
58 | 4 | public function init(callable $stateInitializer) |
|
63 | |||
64 | /** |
||
65 | * @param string $streamId |
||
66 | * @return $this |
||
67 | */ |
||
68 | 8 | public function from($streamId) |
|
73 | |||
74 | /** |
||
75 | * @return $this |
||
76 | */ |
||
77 | 2 | public function fromAll() |
|
82 | |||
83 | /** |
||
84 | * @return $this |
||
85 | */ |
||
86 | 2 | public function forEachStream() |
|
91 | |||
92 | /** |
||
93 | * @param string $eventClass |
||
94 | * @param callable $eventHandler |
||
95 | * @return $this |
||
96 | */ |
||
97 | 6 | public function when($eventClass, callable $eventHandler) |
|
102 | |||
103 | /** |
||
104 | * @return \stdClass |
||
105 | */ |
||
106 | 8 | public function execute() |
|
123 | |||
124 | /** |
||
125 | * @return \DDDominio\EventSourcing\Common\EventStreamInterface |
||
126 | */ |
||
127 | 6 | private function executeStreamEventsQuery() |
|
133 | |||
134 | /** |
||
135 | * @param EventStreamInterface $stream |
||
136 | * @return \stdClass |
||
137 | */ |
||
138 | 7 | private function runStreamProjection($stream) |
|
149 | |||
150 | /** |
||
151 | * @return \stdClass |
||
152 | */ |
||
153 | 8 | private function initState() |
|
158 | } |
||
159 |