1 | <?php |
||
34 | class Comment |
||
35 | { |
||
36 | /** |
||
37 | * @var CommentId |
||
38 | */ |
||
39 | private $id; |
||
40 | |||
41 | /** |
||
42 | * @var Post |
||
43 | */ |
||
44 | private $post; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $content; |
||
50 | |||
51 | /** |
||
52 | * @var DateTimeImmutable |
||
53 | */ |
||
54 | private $publishedAt; |
||
55 | |||
56 | /** |
||
57 | * @var UserId |
||
58 | */ |
||
59 | private $authorId; |
||
60 | |||
61 | public function __construct(string $content = '') |
||
67 | |||
68 | /** |
||
69 | * Used for validation, in config/validator/validation.yaml:14 |
||
70 | */ |
||
71 | public function isLegitComment(): bool |
||
77 | |||
78 | public function getId(): CommentId |
||
82 | |||
83 | public function getContent(): ?string |
||
87 | |||
88 | /** |
||
89 | * This is needed for the $form->handleRequest() in the CommentController. |
||
90 | * We shouldn't have this method here just because the framework needs it, but to remove it we need to change our |
||
91 | * strategy for creating entities from forms. We will do that when we integrate a command bus. |
||
92 | */ |
||
93 | public function setContent(string $content): void |
||
97 | |||
98 | public function getPublishedAt(): DateTimeImmutable |
||
102 | |||
103 | public function setPublishedAt(DateTimeImmutable $publishedAt): void |
||
107 | |||
108 | public function getAuthorId(): UserId |
||
112 | |||
113 | public function setAuthorId(UserId $authorId): void |
||
117 | |||
118 | public function setPost(Post $post): void |
||
122 | } |
||
123 |