urlShortener = $urlShortener; $this->domainConfig = $domainConfig; } public function handle(Request $request): Response { $shortUrlData = $this->buildShortUrlData($request); $longUrl = $shortUrlData->getLongUrl(); $tags = $shortUrlData->getTags(); $shortUrlMeta = $shortUrlData->getMeta(); $shortUrl = $this->urlShortener->urlToShortCode($longUrl, $tags, $shortUrlMeta); $transformer = new ShortUrlDataTransformer($this->domainConfig); return new JsonResponse($transformer->transform($shortUrl)); } /** * @throws ValidationException */ abstract protected function buildShortUrlData(Request $request): CreateShortUrlData; }