SlugDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 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