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

SluggableNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalize() 0 9 2
A supports() 0 4 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