Completed
Push — master ( f88f6e...5d85cb )
by Pavel
03:14
created

DestinationException::inferenceFailed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 9
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
crap 2
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
    public static function inferenceFailed($code, array $item, array $fillers)
20
    {
21
        return new static(
22
            sprintf(
23
                'Unable to infer item code %s from %s (known fillers are %s)',
24
                $code,
25
                implode(',', array_keys($item)),
26
                implode(',', array_keys($fillers))
27
            )
28
        );
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