'Deleted Comment', 'message' => 'You have successfully deleted a Comment' ]; } /** @var CanDeleteComment */ private $canDeleteComment; /** @var DeletesComment */ private $deletesComment; /** @var FetchesComment */ private $fetchesComment; /** * DeleteCommentControllerLogic constructor. * @param CanDeleteComment $canDeleteComment * @param DeletesComment $deletesComment * @param FetchesComment $fetchesComment */ public function __construct(CanDeleteComment $canDeleteComment, DeletesComment $deletesComment, FetchesComment $fetchesComment) { $this->canDeleteComment = $canDeleteComment; $this->deletesComment = $deletesComment; $this->fetchesComment = $fetchesComment; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $this->canDeleteComment->passes(); $query = $this->fetchesComment->execute(['id' => $request->route('id')]); $this->deletesComment->execute($query); return $this->response([]); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }