Added more tests for new logics

This commit is contained in:
Alejandro Celaya
2019-10-11 11:28:53 +02:00
parent 9538f474de
commit 5bd7b53e0a
3 changed files with 84 additions and 12 deletions

View File

@@ -6,24 +6,13 @@ namespace Shlinkio\Shlink\Core\Exception;
class ShortCodeCannotBeRegeneratedException extends RuntimeException
{
/** @var @bool */
private $reasonIsSlug = false;
public static function forShortUrlWithCustomSlug(): self
{
$e = new self('The short code cannot be regenerated on ShortUrls where a custom slug was provided.');
$e->reasonIsSlug = true;
return $e;
return new self('The short code cannot be regenerated on ShortUrls where a custom slug was provided.');
}
public static function forShortUrlAlreadyPersisted(): self
{
return new self('The short code can be regenerated only on new ShortUrls which have not been persisted yet.');
}
public function reasonIsSlug(): bool
{
return $this->reasonIsSlug;
}
}