Refactored UrlShortener public method to receibe DTOs instead of primitive params

This commit is contained in:
Alejandro Celaya
2019-01-29 13:55:47 +01:00
parent 5756609531
commit d61f5faf59
9 changed files with 74 additions and 78 deletions

View File

@@ -17,11 +17,11 @@ final class CreateShortUrlData
public function __construct(
UriInterface $longUrl,
array $tags = [],
ShortUrlMeta $meta = null
?ShortUrlMeta $meta = null
) {
$this->longUrl = $longUrl;
$this->tags = $tags;
$this->meta = $meta ?? ShortUrlMeta::createFromParams();
$this->meta = $meta ?? ShortUrlMeta::createEmpty();
}
/**

View File

@@ -138,4 +138,12 @@ final class ShortUrlMeta
{
return $this->maxVisits !== null;
}
public function withCustomSlug(string $customSlug): self
{
$clone = clone $this;
$clone->customSlug = $customSlug;
return $clone;
}
}