Total Complexity | 7 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | class Unit implements Aggregate |
||
19 | { |
||
20 | use TraitAggregate; |
||
21 | |||
22 | /** @var Uuid */ |
||
23 | private $uuid; |
||
24 | |||
25 | /** @var Key */ |
||
26 | private $key; |
||
27 | |||
28 | /** @var Profile */ |
||
29 | private $profile; |
||
30 | |||
31 | /** @var Data */ |
||
32 | private $data; |
||
33 | |||
34 | private function __construct(Uuid $uuid, Key $key, Profile $profile, Data $data) |
||
35 | { |
||
36 | $this->uuid = $uuid; |
||
37 | $this->key = $key; |
||
38 | $this->profile = $profile; |
||
39 | $this->data = $data; |
||
40 | |||
41 | $this->pushEvent(new UnitCreatedEvent($this)); |
||
42 | } |
||
43 | |||
44 | public static function createFromBoard(Board $board, Transformation $transformation): self |
||
45 | { |
||
46 | if (!$board->isStepReadyForNextTransformation()) { |
||
47 | throw new UnfinishedStepPassedForTransformationException(); |
||
48 | } |
||
49 | |||
50 | return new Unit( |
||
51 | $board->getUuid(), |
||
52 | $board->getKey(), |
||
53 | $board->getProfile(), |
||
54 | $transformation->process($board->getStep()) |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | public function getUuid(): Uuid |
||
59 | { |
||
60 | return $this->uuid; |
||
61 | } |
||
62 | |||
63 | public function getKey(): Key |
||
66 | } |
||
67 | |||
68 | public function getProfile(): Profile |
||
71 | } |
||
72 | |||
73 | public function getData(): Data |
||
76 | } |
||
77 | } |
||
78 |