urlShortener = $urlShortener; $this->domainConfig = $domainConfig; } /** * @throws InvalidArgumentException */ public function handle(Request $request): Response { $shortCode = $request->getAttribute('shortCode'); $domain = $request->getQueryParams()['domain'] ?? null; $transformer = new ShortUrlDataTransformer($this->domainConfig); $url = $this->urlShortener->shortCodeToUrl($shortCode, $domain); return new JsonResponse($transformer->transform($url)); } }