StripCommentsTransformer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 29
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 6 2
A transformRecursive() 0 14 4
1
<?php
2
3
namespace TreeHouse\Feeder\Modifier\Item\Transformer;
4
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
7
class StripCommentsTransformer implements TransformerInterface
8
{
9 4
    public function transform(ParameterBag $item)
10
    {
11 4
        foreach ($item->all() as $key => $value) {
12 4
            $item->set($key, $this->transformRecursive($value));
13 4
        }
14 4
    }
15
16
    /**
17
     * @param mixed $value
18
     *
19
     * @return mixed
20
     */
21 4
    protected function transformRecursive($value)
22
    {
23 4
        if (is_array($value)) {
24 4
            if (array_key_exists('#comment', $value)) {
25 4
                unset($value['#comment']);
26 4
            }
27
28 4
            foreach ($value as &$subvalue) {
29 2
                $subvalue = $this->transformRecursive($subvalue);
30 4
            }
31 4
        }
32
33 4
        return $value;
34
    }
35
}
36