commentId <= 0) { throw new BadRequestException('commentId must be positive'); } if ($request->requesterId <= 0) { throw new BadRequestException('requesterId must be positive'); } $comment = $this->commentRepo->find($request->commentId); if ($comment === null) { return; } $isAuthor = $comment->getUserId() === $request->requesterId; if (! $isAuthor && ! $request->requesterIsAdmin) { throw new ForbiddenException( 'requester is not allowed to delete this comment' ); } $this->commentRepo->delete($request->commentId); } }