Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class Book implements ContainsRecordedMessages |
||
14 | { |
||
15 | use PrivateMessageRecorderCapabilities; |
||
16 | |||
17 | private $id; |
||
18 | private $authorId; |
||
19 | private $title; |
||
20 | private $createdAt; |
||
21 | |||
22 | public function __construct(BookId $id, AuthorId $authorId, string $title) |
||
23 | { |
||
24 | $this->id = (string) $id; |
||
25 | $this->authorId = (string) $authorId; |
||
26 | $this->title = $title; |
||
27 | $this->createdAt = new DateTimeImmutable(); |
||
28 | |||
29 | $this->record(new BookCreated($id, $authorId, $title, $this->createdAt)); |
||
30 | } |
||
31 | |||
32 | public function id(): BookId |
||
33 | { |
||
34 | return BookId::fromString((string) $this->id); |
||
35 | } |
||
36 | |||
37 | public function authorId(): AuthorId |
||
38 | { |
||
39 | return AuthorId::fromString((string) $this->authorId); |
||
40 | } |
||
41 | |||
42 | public function title(): string |
||
43 | { |
||
44 | return $this->title; |
||
45 | } |
||
46 | |||
47 | public function createdAt(): DateTimeInterface |
||
48 | { |
||
49 | return $this->createdAt; |
||
50 | } |
||
52 |