Renamed ShortUrl::fromMeta to ShortUrl::create

This commit is contained in:
Alejandro Celaya
2022-12-11 18:24:47 +01:00
parent 201f25e0ad
commit c4f28b3a32
17 changed files with 94 additions and 82 deletions

View File

@@ -57,15 +57,15 @@ class ShortUrl extends AbstractEntity
public static function createEmpty(): self
{
return self::fromMeta(ShortUrlCreation::createEmpty());
return self::create(ShortUrlCreation::createEmpty());
}
public static function withLongUrl(string $longUrl): self
{
return self::fromMeta(ShortUrlCreation::fromRawData([ShortUrlInputFilter::LONG_URL => $longUrl]));
return self::create(ShortUrlCreation::fromRawData([ShortUrlInputFilter::LONG_URL => $longUrl]));
}
public static function fromMeta( // TODO Rename to create(...)
public static function create(
ShortUrlCreation $creation,
?ShortUrlRelationResolverInterface $relationResolver = null,
): self {
@@ -109,7 +109,7 @@ class ShortUrl extends AbstractEntity
$meta[ShortUrlInputFilter::CUSTOM_SLUG] = $url->shortCode;
}
$instance = self::fromMeta(ShortUrlCreation::fromRawData($meta), $relationResolver);
$instance = self::create(ShortUrlCreation::fromRawData($meta), $relationResolver);
$instance->importSource = $url->source->value;
$instance->importOriginalShortCode = $url->shortCode;

View File

@@ -44,7 +44,7 @@ class UrlShortener implements UrlShortenerInterface
/** @var ShortUrl $newShortUrl */
$newShortUrl = $this->em->wrapInTransaction(function () use ($meta) {
$shortUrl = ShortUrl::fromMeta($meta, $this->relationResolver);
$shortUrl = ShortUrl::create($meta, $this->relationResolver);
$this->verifyShortCodeUniqueness($meta, $shortUrl);
$this->em->persist($shortUrl);