*/ final readonly class AddCommentToArticleHandler implements CommandHandler { public function __construct( public UserRepository $userRepository, public ArticleRepository $articleRepository, public CommentRepository $commentRepository ) { } public function __invoke(AddCommentToArticle $comment): void { $user = $this->userRepository->getById($comment->userId); $article = $this->articleRepository->getById($comment->articleId); $comment = Comment::create($user, $article, $comment->content); $this->commentRepository->add($comment); } }