StripCommentsTransformer::transformRecursive()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 10
cts 10
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 3
nop 1
crap 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