1 | <?php |
||
11 | abstract class BaseAggregateRoot implements AggregateRoot |
||
12 | { |
||
13 | /** |
||
14 | * Some functionality is coming from traits :) |
||
15 | */ |
||
16 | use Reconstitution; |
||
17 | use EventSourced; |
||
18 | use ConventionBasedWhen; |
||
19 | |||
20 | /** |
||
21 | * @var Identity |
||
22 | */ |
||
23 | private $identity; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | private $version = 0; |
||
29 | |||
30 | /** |
||
31 | * @param Identity $id |
||
32 | */ |
||
33 | protected function __construct(Identity $id) |
||
37 | |||
38 | /** |
||
39 | * Gets the identity |
||
40 | * |
||
41 | * @param Identity $id |
||
42 | * @return static |
||
43 | */ |
||
44 | public static function fromIdentity(Identity $id) |
||
48 | |||
49 | /** |
||
50 | * Get the identity |
||
51 | * |
||
52 | * @return Identity |
||
53 | */ |
||
54 | public function getIdentity() |
||
58 | |||
59 | /** |
||
60 | * Increment the aggregate's version |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | protected function bumpVersion() |
||
70 | |||
71 | /** |
||
72 | * Get aggregate version |
||
73 | * |
||
74 | * @return int |
||
75 | */ |
||
76 | public function getVersion() |
||
80 | } |
||
81 |