'Fetch System\'s primary currency', 'message' => 'You have successfully retrieved a Currency' ]; } /** @var CanFetchCurrency */ private $canFetchCurrency; /** @var FetchesConstant*/ private $fetchesConstant; /** @var FetchesCurrency */ private $fetchesCurrency; /** * FetchSystemPrimaryCurrencyLogic constructor. * @param CanFetchCurrency $canFetchCurrency * @param FetchesConstant $fetchesConstant * @param FetchesCurrency $fetchesCurrency */ public function __construct(CanFetchCurrency $canFetchCurrency, FetchesConstant $fetchesConstant, FetchesCurrency $fetchesCurrency) { $this->canFetchCurrency = $canFetchCurrency; $this->fetchesConstant = $fetchesConstant; $this->fetchesCurrency = $fetchesCurrency; } /** * @param Request $request * @return JsonResponse * @throws \App\Classes\Exceptions\AccessForbiddenException * @throws \App\Classes\Exceptions\RequestValidationException */ public function logic(Request $request) : JsonResponse { $this->canFetchCurrency->passes(); $constant = $this->fetchesConstant->execute(['reference' => SegmentConstants::SYSTEM_PRIMARY_CURRENCY]); /** @var Currency $currency */ $currency = $this->fetchesCurrency->execute(['id' => $constant->detail->id]); return $this->resourceResponse(new CurrencyResource($currency)); } }