Allowed to resolve title during short URL edition if it has to

This commit is contained in:
Alejandro Celaya
2021-02-04 23:02:26 +01:00
parent ed18f10b94
commit 71e91a541f
4 changed files with 47 additions and 16 deletions

View File

@@ -27,6 +27,7 @@ final class ShortUrlEdit
private array $tags = [];
private bool $titlePropWasProvided = false;
private ?string $title = null;
private bool $titleWasAutoResolved = false;
private ?bool $validateUrl = null;
private function __construct()
@@ -74,7 +75,7 @@ final class ShortUrlEdit
return $this->longUrl;
}
public function hasLongUrl(): bool
public function longUrlWasProvided(): bool
{
return $this->longUrlPropWasProvided && $this->longUrl !== null;
}
@@ -84,7 +85,7 @@ final class ShortUrlEdit
return $this->validSince;
}
public function hasValidSince(): bool
public function validSinceWasProvided(): bool
{
return $this->validSincePropWasProvided;
}
@@ -94,7 +95,7 @@ final class ShortUrlEdit
return $this->validUntil;
}
public function hasValidUntil(): bool
public function validUntilWasProvided(): bool
{
return $this->validUntilPropWasProvided;
}
@@ -104,7 +105,7 @@ final class ShortUrlEdit
return $this->maxVisits;
}
public function hasMaxVisits(): bool
public function maxVisitsWasProvided(): bool
{
return $this->maxVisitsPropWasProvided;
}
@@ -117,7 +118,7 @@ final class ShortUrlEdit
return $this->tags;
}
public function hasTags(): bool
public function tagsWereProvided(): bool
{
return $this->tagsPropWasProvided;
}
@@ -127,11 +128,25 @@ final class ShortUrlEdit
return $this->title;
}
public function hasTitle(): bool
public function titleWasProvided(): bool
{
return $this->titlePropWasProvided;
}
public function titleWasAutoResolved(): bool
{
return $this->titleWasAutoResolved;
}
public function withResolvedTitle(string $title): self
{
$copy = clone $this;
$copy->title = $title;
$copy->titleWasAutoResolved = true;
return $copy;
}
public function doValidateUrl(): ?bool
{
return $this->validateUrl;