LowercaseKeysTransformer::lowercaseKeys()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3
1
<?php
2
3
namespace TreeHouse\Feeder\Modifier\Item\Transformer;
4
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
7 View Code Duplication
class LowercaseKeysTransformer implements TransformerInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @inheritdoc
11
     */
12 2
    public function transform(ParameterBag $item)
13
    {
14 2
        $parameters = $item->all();
15 2
        $this->lowercaseKeys($parameters);
16 2
        $item->replace($parameters);
17 2
    }
18
19
    /**
20
     * @param array $arr
21
     */
22 2
    protected function lowercaseKeys(array &$arr)
23
    {
24 2
        $arr = array_change_key_case($arr, CASE_LOWER);
25
26 2
        foreach ($arr as &$value) {
27 2
            if (is_array($value)) {
28 2
                $this->lowercaseKeys($value);
29 2
            }
30 2
        }
31 2
    }
32
}
33