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

SluggableNormalizer::supports()   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 1
crap 1
1
<?php
2
3
namespace Bankiru\Seo\Destination\Normalizer;
4
5
use Bankiru\Seo\Destination\DestinationNormalizer;
6
use Bankiru\Seo\Entity\Sluggable;
7
use Bankiru\Seo\Exception\DestinationException;
8
9
final class SluggableNormalizer implements DestinationNormalizer
10
{
11
    /** {@inheritdoc} */
12 5
    public function normalize($item)
13
    {
14 5
        if (!$this->supports($item)) {
15 4
            throw DestinationException::normalizationFailed($item, Sluggable::class);
16
        }
17
18
        /** @var Sluggable $item */
19 1
        return $item->getSlug();
20
    }
21
22
    /** {@inheritdoc} */
23 5
    public function supports($item)
24
    {
25 5
        return $item instanceof Sluggable;
26
    }
27
}
28