findById($id); if (!$comment) { throw new BadRequestException('comment.not_found'); } return $comment; } public function checkChapter($chapterId) { $chapterRepo = new ChapterRepo(); $chapter = $chapterRepo->findById($chapterId); if (!$chapter) { throw new BadRequestException('comment.invalid_chapter_id'); } return $chapter; } public function checkParent($parentId) { $commentRepo = new CourseRepo(); $parent = $commentRepo->findById($parentId); if (!$parent) { throw new BadRequestException('comment.invalid_parent_id'); } return $parent; } public function checkContent($content) { $value = $this->filter->sanitize($content, ['trim', 'string']); $length = kg_strlen($value); if ($length < 1) { throw new BadRequestException('comment.content_too_short'); } if ($length > 1000) { throw new BadRequestException('comment.content_too_long'); } return $value; } public function checkMentions($mentions) { } public function checkPublishStatus($status) { if (!in_array($status, [0, 1])) { throw new BadRequestException('consult.invalid_publish_status'); } return $status; } }