Replaced the use of EntityDoesNotExistException by ShorturlNotFoundException where applicable

This commit is contained in:
Alejandro Celaya
2019-11-25 18:54:25 +01:00
parent 310032e303
commit 0c5eec7e95
17 changed files with 60 additions and 109 deletions

View File

@@ -19,11 +19,7 @@ class NonUniqueSlugException extends InvalidArgumentException implements Problem
public static function fromSlug(string $slug, ?string $domain): self
{
$suffix = '';
if ($domain !== null) {
$suffix = sprintf(' for domain "%s"', $domain);
}
$suffix = $domain === null ? '' : sprintf(' for domain "%s"', $domain);
$e = new self(sprintf('Provided slug "%s" is already in use%s.', $slug, $suffix));
$e->detail = $e->getMessage();

View File

@@ -17,9 +17,10 @@ class ShortUrlNotFoundException extends DomainException implements ProblemDetail
private const TITLE = 'Short URL not found';
public const TYPE = 'INVALID_SHORTCODE';
public static function fromNotFoundShortCode(string $shortCode): self
public static function fromNotFoundShortCode(string $shortCode, ?string $domain = null): self
{
$e = new self(sprintf('No URL found for short code "%s"', $shortCode));
$suffix = $domain === null ? '' : sprintf(' for domain "%s"', $domain);
$e = new self(sprintf('No URL found with short code "%s"%s', $shortCode, $suffix));
$e->detail = $e->getMessage();
$e->title = self::TITLE;