SlugDecorator::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Percy\Decorator;
4
5
use Cocur\Slugify\Slugify;
6
use Percy\Entity\EntityInterface;
7
8
class SlugDecorator implements DecoratorInterface
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function __invoke(EntityInterface $entity, array $properties = [])
14
    {
15 1
        $props = [];
16
17 1
        foreach ($properties as $property) {
18 1
            $props[] = $entity[$property];
19 1
        }
20
21 1
        $entity['slug'] = (new Slugify)->slugify(implode('-', $props));
22 1
    }
23
}
24