Completed
Push — master ( 038254...115ca0 )
by Alejandro
06:27
created

InvalidShortCodeException::fromNotFoundShortCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\Core\Exception;
6
7
use Throwable;
8
9
use function sprintf;
10
11
class InvalidShortCodeException extends RuntimeException
12
{
13 2
    public static function fromCharset(string $shortCode, string $charSet, ?Throwable $previous = null): self
14
    {
15 2
        $code = $previous !== null ? $previous->getCode() : -1;
16 2
        return new static(
17 2
            sprintf('Provided short code "%s" does not match the char set "%s"', $shortCode, $charSet),
18 2
            $code,
19 2
            $previous
20
        );
21
    }
22
23 2
    public static function fromNotFoundShortCode(string $shortCode): self
24
    {
25 2
        return new static(sprintf('Provided short code "%s" does not belong to a short URL', $shortCode));
26
    }
27
}
28