2017-10-21 18:18:57 +03:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Shlinkio\Shlink\Core\Exception;
|
|
|
|
|
2018-10-28 10:34:02 +03:00
|
|
|
use function sprintf;
|
|
|
|
|
2017-10-21 18:18:57 +03:00
|
|
|
class NonUniqueSlugException extends InvalidArgumentException
|
|
|
|
{
|
2019-10-01 22:42:35 +03:00
|
|
|
public static function fromSlug(string $slug, ?string $domain): self
|
2017-10-21 18:18:57 +03:00
|
|
|
{
|
2019-10-01 22:42:35 +03:00
|
|
|
$suffix = '';
|
|
|
|
if ($domain !== null) {
|
|
|
|
$suffix = sprintf(' for domain "%s"', $domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new self(sprintf('Provided slug "%s" is not unique%s.', $slug, $suffix));
|
2017-10-21 18:18:57 +03:00
|
|
|
}
|
|
|
|
}
|