Total Complexity | 8 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
19 | final class Agenda implements ContainsRecordedEventsInterface |
||
20 | { |
||
21 | use EventRecorder; |
||
22 | |||
23 | private $identity; |
||
24 | private $user; |
||
25 | private $name; |
||
26 | |||
27 | 7 | private function __construct(Identity $identity, User $user, Name $name) |
|
28 | { |
||
29 | 7 | $this->identity = $identity; |
|
30 | 7 | $this->user = $user; |
|
31 | 7 | $this->name = $name; |
|
32 | 7 | } |
|
33 | |||
34 | 7 | public static function add(Identity $identity, User $user, Name $name): self |
|
40 | } |
||
41 | |||
42 | 3 | public function identity(): Identity |
|
45 | } |
||
46 | |||
47 | 2 | public function user(): User |
|
48 | { |
||
49 | 2 | return $this->user; |
|
50 | } |
||
51 | |||
52 | 5 | public function name(): Name |
|
53 | { |
||
54 | 5 | return $this->name; |
|
55 | } |
||
56 | |||
57 | 3 | public function rename(Name $name): self |
|
58 | { |
||
59 | 3 | if ($name->equals($this->name)) { |
|
60 | 1 | return $this; |
|
61 | } |
||
62 | |||
63 | 2 | $this->name = $name; |
|
64 | 2 | $this->record(new AgendaWasRenamed($this->identity, $name)); |
|
65 | |||
66 | 2 | return $this; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * Last method that can be called, here only to record the event |
||
71 | */ |
||
72 | 2 | public function delete(): void |
|
75 | 2 | } |
|
76 | } |
||
77 |