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
|
|
|
|
|
|
|
|
class InvalidShortCodeException extends RuntimeException
|
|
|
|
|
{
|
2016-08-21 16:52:26 +02:00
|
|
|
public static function fromCharset($shortCode, $charSet, \Exception $previous = null)
|
2016-04-17 13:42:52 +02:00
|
|
|
{
|
2018-09-15 11:54:58 +02:00
|
|
|
$code = $previous !== null ? $previous->getCode() : -1;
|
2016-04-17 13:42:52 +02:00
|
|
|
return new static(
|
2018-09-15 11:54:58 +02:00
|
|
|
\sprintf('Provided short code "%s" does not match the char set "%s"', $shortCode, $charSet),
|
2016-04-17 13:42:52 +02:00
|
|
|
$code,
|
|
|
|
|
$previous
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-08-21 16:52:26 +02:00
|
|
|
|
|
|
|
|
public static function fromNotFoundShortCode($shortCode)
|
|
|
|
|
{
|
2018-09-15 11:54:58 +02:00
|
|
|
return new static(\sprintf('Provided short code "%s" does not belong to a short URL', $shortCode));
|
2016-08-21 16:52:26 +02:00
|
|
|
}
|
2016-04-17 13:42:52 +02:00
|
|
|
}
|