'Retrieved Company', 'message' => 'You have successfully retrieved a Company' ]; } /** @var CanFetchCompany */ private $canFetchCompany; /** @var FetchesCompany */ private $fetchesCompany; /** * FetchCompanyControllerLogic constructor. * @param CanFetchCompany $canFetchCompany * @param FetchesCompany $fetchesCompany */ public function __construct(CanFetchCompany $canFetchCompany, FetchesCompany $fetchesCompany) { $this->canFetchCompany = $canFetchCompany; $this->fetchesCompany = $fetchesCompany; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { try { $this->canFetchCompany->passes(); $query = $this->fetchesCompany->execute(['id' => $request->route('id')]); return $this->resourceResponse(new CompanyResource($query)); } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); } } }