Completed
Push — master ( 5d85cb...99533f )
by Pavel
03:42
created

DestinationException::circularInference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
namespace Bankiru\Seo\Exception;
3
4
class DestinationException extends \RuntimeException implements SeoExceptionInterface
5
{
6 7
    public static function normalizationFailed($item, $expected = null)
7
    {
8 7
        $message = sprintf(
9 7
            'Cannot get slug for item of type %s.',
10 7
            is_object($item) ? get_class($item) : gettype($item)
11 7
        );
12 7
        if ($expected) {
13 6
            $message .= sprintf(' Item of type %s expected.', $expected);
14 6
        }
15
16 7
        return new static($message);
17
    }
18
19 1
    public static function inferenceFailed($code, array $item, array $fillers)
20
    {
21 1
        return new static(
22 1
            sprintf(
23 1
                'Unable to infer item code %s from %s (known fillers are %s)',
24 1
                $code,
25 1
                implode(',', array_keys($item)),
26 1
                implode(',', array_keys($fillers))
27 1
            )
28 1
        );
29
    }
30
31 1
    public static function circularInference($code, $visited)
32
    {
33 1
        return new static(sprintf('Circular inference detected: %s <- %s', $code, implode(',', $visited)));
34
    }
35
}
36