Completed
Push — master ( 59a2ac...5b5abc )
by Phil
06:25
created

SlugDecorator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

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
    public function __invoke(EntityInterface $entity, array $properties = [])
14
    {
15
        $props = [];
16
17
        foreach ($properties as $property) {
18
            $props[] = $entity[$property];
19
        }
20
21
        $entity['slug'] = (new Slugify)->slugify(implode('-', $props));
22
    }
23
}
24