From 77fee1390fd5b3925741faf585d5d37f6c0b90f5 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 16 Jan 2022 15:41:20 +0100 Subject: [PATCH] Renamed class to a more appropriate name --- module/Core/config/dependencies.config.php | 8 ++++---- module/Core/src/Importer/ImportedLinksProcessor.php | 4 ++-- ...{ShortCodeHelper.php => ShortCodeUniquenessHelper.php} | 2 +- ...terface.php => ShortCodeUniquenessHelperInterface.php} | 2 +- module/Core/src/Service/UrlShortener.php | 4 ++-- module/Core/test/Importer/ImportedLinksProcessorTest.php | 4 ++-- ...deHelperTest.php => ShortCodeUniquenessHelperTest.php} | 8 ++++---- module/Core/test/Service/UrlShortenerTest.php | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) rename module/Core/src/Service/ShortUrl/{ShortCodeHelper.php => ShortCodeUniquenessHelper.php} (90%) rename module/Core/src/Service/ShortUrl/{ShortCodeHelperInterface.php => ShortCodeUniquenessHelperInterface.php} (72%) rename module/Core/test/Service/ShortUrl/{ShortCodeHelperTest.php => ShortCodeUniquenessHelperTest.php} (91%) diff --git a/module/Core/config/dependencies.config.php b/module/Core/config/dependencies.config.php index 90931c11..516ad8a1 100644 --- a/module/Core/config/dependencies.config.php +++ b/module/Core/config/dependencies.config.php @@ -33,7 +33,7 @@ return [ Service\ShortUrlService::class => ConfigAbstractFactory::class, Service\ShortUrl\DeleteShortUrlService::class => ConfigAbstractFactory::class, Service\ShortUrl\ShortUrlResolver::class => ConfigAbstractFactory::class, - Service\ShortUrl\ShortCodeHelper::class => ConfigAbstractFactory::class, + Service\ShortUrl\ShortCodeUniquenessHelper::class => ConfigAbstractFactory::class, Tag\TagService::class => ConfigAbstractFactory::class, @@ -97,7 +97,7 @@ return [ ShortUrl\Helper\ShortUrlTitleResolutionHelper::class, 'em', ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class, - Service\ShortUrl\ShortCodeHelper::class, + Service\ShortUrl\ShortCodeUniquenessHelper::class, ], Visit\VisitsTracker::class => [ 'em', @@ -120,7 +120,7 @@ return [ Service\ShortUrl\ShortUrlResolver::class, ], Service\ShortUrl\ShortUrlResolver::class => ['em'], - Service\ShortUrl\ShortCodeHelper::class => ['em'], + Service\ShortUrl\ShortCodeUniquenessHelper::class => ['em'], Domain\DomainService::class => ['em', 'config.url_shortener.domain.hostname'], Util\UrlValidator::class => ['httpClient', Options\UrlShortenerOptions::class], @@ -165,7 +165,7 @@ return [ Importer\ImportedLinksProcessor::class => [ 'em', ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class, - Service\ShortUrl\ShortCodeHelper::class, + Service\ShortUrl\ShortCodeUniquenessHelper::class, Util\DoctrineBatchHelper::class, ], diff --git a/module/Core/src/Importer/ImportedLinksProcessor.php b/module/Core/src/Importer/ImportedLinksProcessor.php index cddfbb88..fe4f24df 100644 --- a/module/Core/src/Importer/ImportedLinksProcessor.php +++ b/module/Core/src/Importer/ImportedLinksProcessor.php @@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManagerInterface; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; -use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeHelperInterface; +use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeUniquenessHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface; use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface; @@ -25,7 +25,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface public function __construct( private EntityManagerInterface $em, private ShortUrlRelationResolverInterface $relationResolver, - private ShortCodeHelperInterface $shortCodeHelper, + private ShortCodeUniquenessHelperInterface $shortCodeHelper, private DoctrineBatchHelperInterface $batchHelper, ) { $this->shortUrlRepo = $this->em->getRepository(ShortUrl::class); diff --git a/module/Core/src/Service/ShortUrl/ShortCodeHelper.php b/module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelper.php similarity index 90% rename from module/Core/src/Service/ShortUrl/ShortCodeHelper.php rename to module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelper.php index 5bb992c5..461a14b6 100644 --- a/module/Core/src/Service/ShortUrl/ShortCodeHelper.php +++ b/module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelper.php @@ -9,7 +9,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; -class ShortCodeHelper implements ShortCodeHelperInterface // TODO Rename to ShortCodeUniquenessHelper +class ShortCodeUniquenessHelper implements ShortCodeUniquenessHelperInterface { public function __construct(private EntityManagerInterface $em) { diff --git a/module/Core/src/Service/ShortUrl/ShortCodeHelperInterface.php b/module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelperInterface.php similarity index 72% rename from module/Core/src/Service/ShortUrl/ShortCodeHelperInterface.php rename to module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelperInterface.php index a020a30c..975a2b8b 100644 --- a/module/Core/src/Service/ShortUrl/ShortCodeHelperInterface.php +++ b/module/Core/src/Service/ShortUrl/ShortCodeUniquenessHelperInterface.php @@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\Core\Service\ShortUrl; use Shlinkio\Shlink\Core\Entity\ShortUrl; -interface ShortCodeHelperInterface // TODO Rename to ShortCodeUniquenessHelperInterface +interface ShortCodeUniquenessHelperInterface { public function ensureShortCodeUniqueness(ShortUrl $shortUrlToBeCreated, bool $hasCustomSlug): bool; } diff --git a/module/Core/src/Service/UrlShortener.php b/module/Core/src/Service/UrlShortener.php index 41779715..8fa54493 100644 --- a/module/Core/src/Service/UrlShortener.php +++ b/module/Core/src/Service/UrlShortener.php @@ -10,7 +10,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidUrlException; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; -use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeHelperInterface; +use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeUniquenessHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface; @@ -20,7 +20,7 @@ class UrlShortener implements UrlShortenerInterface private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper, private EntityManagerInterface $em, private ShortUrlRelationResolverInterface $relationResolver, - private ShortCodeHelperInterface $shortCodeHelper, + private ShortCodeUniquenessHelperInterface $shortCodeHelper, ) { } diff --git a/module/Core/test/Importer/ImportedLinksProcessorTest.php b/module/Core/test/Importer/ImportedLinksProcessorTest.php index 1a4a4de1..70662bb1 100644 --- a/module/Core/test/Importer/ImportedLinksProcessorTest.php +++ b/module/Core/test/Importer/ImportedLinksProcessorTest.php @@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\Importer\ImportedLinksProcessor; use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; -use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeHelperInterface; +use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeUniquenessHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver; use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl; @@ -46,7 +46,7 @@ class ImportedLinksProcessorTest extends TestCase $this->repo = $this->prophesize(ShortUrlRepositoryInterface::class); $this->em->getRepository(ShortUrl::class)->willReturn($this->repo->reveal()); - $this->shortCodeHelper = $this->prophesize(ShortCodeHelperInterface::class); + $this->shortCodeHelper = $this->prophesize(ShortCodeUniquenessHelperInterface::class); $batchHelper = $this->prophesize(DoctrineBatchHelperInterface::class); $batchHelper->wrapIterable(Argument::cetera())->willReturnArgument(0); diff --git a/module/Core/test/Service/ShortUrl/ShortCodeHelperTest.php b/module/Core/test/Service/ShortUrl/ShortCodeUniquenessHelperTest.php similarity index 91% rename from module/Core/test/Service/ShortUrl/ShortCodeHelperTest.php rename to module/Core/test/Service/ShortUrl/ShortCodeUniquenessHelperTest.php index b30f8cab..7e962dc8 100644 --- a/module/Core/test/Service/ShortUrl/ShortCodeHelperTest.php +++ b/module/Core/test/Service/ShortUrl/ShortCodeUniquenessHelperTest.php @@ -12,20 +12,20 @@ use Shlinkio\Shlink\Core\Entity\Domain; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; -use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeHelper; +use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeUniquenessHelper; -class ShortCodeHelperTest extends TestCase +class ShortCodeUniquenessHelperTest extends TestCase { use ProphecyTrait; - private ShortCodeHelper $helper; + private ShortCodeUniquenessHelper $helper; private ObjectProphecy $em; private ObjectProphecy $shortUrl; protected function setUp(): void { $this->em = $this->prophesize(EntityManagerInterface::class); - $this->helper = new ShortCodeHelper($this->em->reveal()); + $this->helper = new ShortCodeUniquenessHelper($this->em->reveal()); $this->shortUrl = $this->prophesize(ShortUrl::class); $this->shortUrl->getShortCode()->willReturn('abc123'); diff --git a/module/Core/test/Service/UrlShortenerTest.php b/module/Core/test/Service/UrlShortenerTest.php index 6bac432e..bdd508b4 100644 --- a/module/Core/test/Service/UrlShortenerTest.php +++ b/module/Core/test/Service/UrlShortenerTest.php @@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; -use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeHelperInterface; +use Shlinkio\Shlink\Core\Service\ShortUrl\ShortCodeUniquenessHelperInterface; use Shlinkio\Shlink\Core\Service\UrlShortener; use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver; @@ -48,7 +48,7 @@ class UrlShortenerTest extends TestCase $repo = $this->prophesize(ShortUrlRepository::class); $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal()); - $this->shortCodeHelper = $this->prophesize(ShortCodeHelperInterface::class); + $this->shortCodeHelper = $this->prophesize(ShortCodeUniquenessHelperInterface::class); $this->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true); $this->urlShortener = new UrlShortener(