mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Added logic to check if a short code is in use and regenerate it otherwise
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user