1 | <?php |
||
12 | final class Repository implements WriteModelRepository |
||
13 | { |
||
14 | /** @var $entityClass */ |
||
15 | private $entityClass; |
||
16 | |||
17 | /** @var EventStore $eventStore */ |
||
18 | private $eventStore; |
||
19 | |||
20 | /** |
||
21 | * @param string $class |
||
22 | * @param EventStore $eventStore |
||
23 | */ |
||
24 | private function __construct($class, EventStore $eventStore) |
||
29 | |||
30 | /** |
||
31 | * @param $class |
||
32 | * @param EventStore $eventStore |
||
33 | * |
||
34 | * @return Repository |
||
35 | */ |
||
36 | public static function createForWrites($class, EventStore $eventStore) |
||
40 | |||
41 | /** |
||
42 | * @param string $entityIdentifier |
||
43 | * |
||
44 | * @return mixed |
||
45 | */ |
||
46 | public function load($entityIdentifier) |
||
54 | |||
55 | /** |
||
56 | * @param EventSourcedEntity $eventSourcedEntity |
||
57 | * |
||
58 | * @throws \Exception |
||
59 | */ |
||
60 | public function save(EventSourcedEntity $eventSourcedEntity) |
||
68 | |||
69 | /** |
||
70 | * @param string $class |
||
71 | * |
||
72 | * @throws IncorrectEntityClassException |
||
73 | */ |
||
74 | private function enforceTypeConstraint($class) |
||
80 | |||
81 | /** |
||
82 | * @param EventSourcedEntity $eventSourcedEntity |
||
83 | * |
||
84 | * @throws VersionMismatchException |
||
85 | */ |
||
86 | private function enforceVersionMismatchConstraint(EventSourcedEntity $eventSourcedEntity) |
||
96 | } |
||
97 |