Normalized some filtering

This commit is contained in:
Alejandro Celaya
2021-01-30 18:24:14 +01:00
parent 07b12fac3c
commit 903ef8e249
4 changed files with 28 additions and 9 deletions

View File

@@ -25,7 +25,6 @@ final class ShortUrlEdit
private ?int $maxVisits = null;
private ?bool $validateUrl = null;
// Enforce named constructors
private function __construct()
{
}

View File

@@ -27,18 +27,18 @@ final class ShortUrlMeta
private int $shortCodeLength = 5;
private ?bool $validateUrl = null;
private ?ApiKey $apiKey = null;
private array $tags = [];
// Enforce named constructors
private function __construct()
{
}
public static function createEmpty(): self
{
$meta = new self();
$meta->longUrl = '';
$instance = new self();
$instance->longUrl = '';
return $meta;
return $instance;
}
/**
@@ -48,6 +48,7 @@ final class ShortUrlMeta
{
$instance = new self();
$instance->validateAndInit($data);
return $instance;
}
@@ -74,6 +75,7 @@ final class ShortUrlMeta
ShortUrlMetaInputFilter::SHORT_CODE_LENGTH,
) ?? DEFAULT_SHORT_CODES_LENGTH;
$this->apiKey = $inputFilter->getValue(ShortUrlMetaInputFilter::API_KEY);
$this->tags = $inputFilter->getValue(ShortUrlMetaInputFilter::TAGS);
}
public function getLongUrl(): string
@@ -150,4 +152,12 @@ final class ShortUrlMeta
{
return $this->apiKey;
}
/**
* @return string[]
*/
public function getTags(): array
{
return $this->tags;
}
}