Renamed class to a more appropriate name

This commit is contained in:
Alejandro Celaya 2022-01-16 15:41:20 +01:00
parent bfb54189b8
commit 77fee1390f
8 changed files with 18 additions and 18 deletions

View File

@ -33,7 +33,7 @@ return [
Service\ShortUrlService::class => ConfigAbstractFactory::class, Service\ShortUrlService::class => ConfigAbstractFactory::class,
Service\ShortUrl\DeleteShortUrlService::class => ConfigAbstractFactory::class, Service\ShortUrl\DeleteShortUrlService::class => ConfigAbstractFactory::class,
Service\ShortUrl\ShortUrlResolver::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, Tag\TagService::class => ConfigAbstractFactory::class,
@ -97,7 +97,7 @@ return [
ShortUrl\Helper\ShortUrlTitleResolutionHelper::class, ShortUrl\Helper\ShortUrlTitleResolutionHelper::class,
'em', 'em',
ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class, ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class,
Service\ShortUrl\ShortCodeHelper::class, Service\ShortUrl\ShortCodeUniquenessHelper::class,
], ],
Visit\VisitsTracker::class => [ Visit\VisitsTracker::class => [
'em', 'em',
@ -120,7 +120,7 @@ return [
Service\ShortUrl\ShortUrlResolver::class, Service\ShortUrl\ShortUrlResolver::class,
], ],
Service\ShortUrl\ShortUrlResolver::class => ['em'], Service\ShortUrl\ShortUrlResolver::class => ['em'],
Service\ShortUrl\ShortCodeHelper::class => ['em'], Service\ShortUrl\ShortCodeUniquenessHelper::class => ['em'],
Domain\DomainService::class => ['em', 'config.url_shortener.domain.hostname'], Domain\DomainService::class => ['em', 'config.url_shortener.domain.hostname'],
Util\UrlValidator::class => ['httpClient', Options\UrlShortenerOptions::class], Util\UrlValidator::class => ['httpClient', Options\UrlShortenerOptions::class],
@ -165,7 +165,7 @@ return [
Importer\ImportedLinksProcessor::class => [ Importer\ImportedLinksProcessor::class => [
'em', 'em',
ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class, ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class,
Service\ShortUrl\ShortCodeHelper::class, Service\ShortUrl\ShortCodeUniquenessHelper::class,
Util\DoctrineBatchHelper::class, Util\DoctrineBatchHelper::class,
], ],

View File

@ -8,7 +8,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; 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\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface; use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
@ -25,7 +25,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
public function __construct( public function __construct(
private EntityManagerInterface $em, private EntityManagerInterface $em,
private ShortUrlRelationResolverInterface $relationResolver, private ShortUrlRelationResolverInterface $relationResolver,
private ShortCodeHelperInterface $shortCodeHelper, private ShortCodeUniquenessHelperInterface $shortCodeHelper,
private DoctrineBatchHelperInterface $batchHelper, private DoctrineBatchHelperInterface $batchHelper,
) { ) {
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class); $this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);

View File

@ -9,7 +9,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier; use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
class ShortCodeHelper implements ShortCodeHelperInterface // TODO Rename to ShortCodeUniquenessHelper class ShortCodeUniquenessHelper implements ShortCodeUniquenessHelperInterface
{ {
public function __construct(private EntityManagerInterface $em) public function __construct(private EntityManagerInterface $em)
{ {

View File

@ -6,7 +6,7 @@ namespace Shlinkio\Shlink\Core\Service\ShortUrl;
use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\ShortUrl;
interface ShortCodeHelperInterface // TODO Rename to ShortCodeUniquenessHelperInterface interface ShortCodeUniquenessHelperInterface
{ {
public function ensureShortCodeUniqueness(ShortUrl $shortUrlToBeCreated, bool $hasCustomSlug): bool; public function ensureShortCodeUniqueness(ShortUrl $shortUrlToBeCreated, bool $hasCustomSlug): bool;
} }

View File

@ -10,7 +10,7 @@ use Shlinkio\Shlink\Core\Exception\InvalidUrlException;
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; 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\Helper\ShortUrlTitleResolutionHelperInterface;
use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface; use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
@ -20,7 +20,7 @@ class UrlShortener implements UrlShortenerInterface
private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper, private ShortUrlTitleResolutionHelperInterface $titleResolutionHelper,
private EntityManagerInterface $em, private EntityManagerInterface $em,
private ShortUrlRelationResolverInterface $relationResolver, private ShortUrlRelationResolverInterface $relationResolver,
private ShortCodeHelperInterface $shortCodeHelper, private ShortCodeUniquenessHelperInterface $shortCodeHelper,
) { ) {
} }

View File

@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\Importer\ImportedLinksProcessor; use Shlinkio\Shlink\Core\Importer\ImportedLinksProcessor;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepositoryInterface; 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\ShortUrl\Resolver\SimpleShortUrlRelationResolver;
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl; use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
@ -46,7 +46,7 @@ class ImportedLinksProcessorTest extends TestCase
$this->repo = $this->prophesize(ShortUrlRepositoryInterface::class); $this->repo = $this->prophesize(ShortUrlRepositoryInterface::class);
$this->em->getRepository(ShortUrl::class)->willReturn($this->repo->reveal()); $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 = $this->prophesize(DoctrineBatchHelperInterface::class);
$batchHelper->wrapIterable(Argument::cetera())->willReturnArgument(0); $batchHelper->wrapIterable(Argument::cetera())->willReturnArgument(0);

View File

@ -12,20 +12,20 @@ use Shlinkio\Shlink\Core\Entity\Domain;
use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier; use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; 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; use ProphecyTrait;
private ShortCodeHelper $helper; private ShortCodeUniquenessHelper $helper;
private ObjectProphecy $em; private ObjectProphecy $em;
private ObjectProphecy $shortUrl; private ObjectProphecy $shortUrl;
protected function setUp(): void protected function setUp(): void
{ {
$this->em = $this->prophesize(EntityManagerInterface::class); $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 = $this->prophesize(ShortUrl::class);
$this->shortUrl->getShortCode()->willReturn('abc123'); $this->shortUrl->getShortCode()->willReturn('abc123');

View File

@ -14,7 +14,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl;
use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException; use Shlinkio\Shlink\Core\Exception\NonUniqueSlugException;
use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository; 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\Service\UrlShortener;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelperInterface; use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlTitleResolutionHelperInterface;
use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver; use Shlinkio\Shlink\Core\ShortUrl\Resolver\SimpleShortUrlRelationResolver;
@ -48,7 +48,7 @@ class UrlShortenerTest extends TestCase
$repo = $this->prophesize(ShortUrlRepository::class); $repo = $this->prophesize(ShortUrlRepository::class);
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal()); $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->shortCodeHelper->ensureShortCodeUniqueness(Argument::cetera())->willReturn(true);
$this->urlShortener = new UrlShortener( $this->urlShortener = new UrlShortener(