Files
shlink/module/Core/src/Exception/InvalidShortCodeException.php

26 lines
737 B
PHP
Raw Normal View History

2016-04-17 13:42:52 +02:00
<?php
2017-10-12 10:13:20 +02:00
declare(strict_types=1);
2016-07-19 18:01:39 +02:00
namespace Shlinkio\Shlink\Core\Exception;
2016-04-17 13:42:52 +02:00
2019-02-17 20:28:34 +01:00
use Throwable;
use function sprintf;
2016-04-17 13:42:52 +02:00
class InvalidShortCodeException extends RuntimeException
{
2019-02-17 20:28:34 +01:00
public static function fromCharset(string $shortCode, string $charSet, ?Throwable $previous = null): self
2016-04-17 13:42:52 +02:00
{
$code = $previous !== null ? $previous->getCode() : -1;
2016-04-17 13:42:52 +02:00
return new static(
sprintf('Provided short code "%s" does not match the char set "%s"', $shortCode, $charSet),
2016-04-17 13:42:52 +02:00
$code,
$previous
);
}
2018-11-17 19:23:25 +01:00
public static function fromNotFoundShortCode(string $shortCode): self
{
return new static(sprintf('Provided short code "%s" does not belong to a short URL', $shortCode));
}
2016-04-17 13:42:52 +02:00
}