*/ private array $comments = []; public function getCommentForUser(User $user): string { return $this->comments[$user->getId()] ?? ''; } public function getComments(): ?array { return $this->comments; } public function hasCommentForUser(User $user): bool { return array_key_exists($user->getId(), $this->comments) && '' !== $this->comments[$user->getId()]; } public function merge(PrivateCommentEmbeddable $newComment): self { $currentComments = null === $this->getComments() ? [] : $this->getComments(); $mergedComments = $newComment->getComments() + $currentComments; $this->setComments($mergedComments); return $this; } public function setCommentForUser(User $user, string $content): self { $this->comments[$user->getId()] = trim($content); return $this; } public function setComments($comments) { $this->comments = $comments; return $this; } }