/** * @param string $urlSuffixString * @return string * @throws GetRedirectUrlException */ public function get($urlSuffixString) { $shortenedUrlSuffix = $this->shortenedUrlSuffixRepo->findBySuffix($urlSuffixString); if (null === $shortenedUrlSuffix) { throw new GetRedirectUrlException("Url does not exist"); } $this->registerUrlCallService->register($shortenedUrlSuffix); return $this->urlEncoder->decode($shortenedUrlSuffix->getOriginalUrlEncodedLink()); }
/** * @param ShortenedUrlSuffix $shortenedUrlSuffix * @param int $totalExecutions * @param int $totalRedirectsToSameContent * @return ShortenedUrl */ public function create(ShortenedUrlSuffix $shortenedUrlSuffix, $totalExecutions, $totalRedirectsToSameContent) { $link = $this->localUrlAssembler->assemble($shortenedUrlSuffix->getSuffixString()); $originalLink = $this->urlEncoder->decode($shortenedUrlSuffix->getOriginalUrlEncodedLink()); return new ShortenedUrl($link, $originalLink, $shortenedUrlSuffix->getDateCreated(), $totalExecutions, $totalRedirectsToSameContent); }