1 | <?php |
||
12 | final class Repository |
||
13 | { |
||
14 | /** @var EventSourcedEntity $entityClass */ |
||
15 | private $entityClass; |
||
16 | |||
17 | /** @var EventStore $eventStore */ |
||
18 | private $eventStore; |
||
19 | |||
20 | /** |
||
21 | * @param EventSourcedEntity $class |
||
22 | * @param EventStore $eventStore |
||
23 | */ |
||
24 | private function __construct(EventSourcedEntity $class, EventStore $eventStore) |
||
29 | |||
30 | /** |
||
31 | * @param $class |
||
32 | * @param EventStore $eventStore |
||
33 | * @return Repository |
||
34 | */ |
||
35 | public static function createForType($class, EventStore $eventStore) |
||
40 | |||
41 | /** |
||
42 | * @param $identifier |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function load($identifier) |
||
52 | |||
53 | /** |
||
54 | * @param EventSourcedEntity $class |
||
55 | * @throws IncorrectEntityException |
||
56 | */ |
||
57 | public function save(EventSourcedEntity $class) |
||
62 | |||
63 | /** |
||
64 | * @param EventSourcedEntity $entity |
||
65 | * @throws IncorrectEntityException |
||
66 | */ |
||
67 | private function enforceTypeConstraint(EventSourcedEntity $entity) |
||
73 | } |
||
74 |