'Retrieved Segment', 'message' => 'You have successfully retrieved a segment' ]; } /** @var CanFetchSegment */ private $canFetchSegment; /** @var FetchesSegment */ private $fetchesSegment; /** * FetchSegmentLogic constructor. * @param CanFetchSegment $canFetchSegment * @param FetchesSegment $fetchesSegment */ public function __construct(CanFetchSegment $canFetchSegment, FetchesSegment $fetchesSegment) { $this->canFetchSegment = $canFetchSegment; $this->fetchesSegment = $fetchesSegment; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { $this->canFetchSegment->passes(); $query = $this->fetchesSegment->execute(['id' => $request->route('id')]); return $this->resourceResponse(new SegmentResource($query)); } }