Passed
Push — master ( a35b5f...c35142 )
by Vitor de
02:29
created

Option   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 20 4
1
<?php
2
3
namespace GFG\Mapper\Data\Type\Assoc;
4
5
use GFG\Mapper\Data\MapperInterface;
6
use GFG\Mapper\Data\Type;
7
8
class Option extends Type\Option
9
{
10 2
    public function run(&$data, $key = null)
11
    {
12 2
        $new = [];
13 2
        foreach ($data as $key => $value) {
14 2
            if (is_array($value)) { // check for option to be sure!
15 2
                $oldKey = $key;
16
17 2
                $key = $this->get($key);
18 2
                if ($this->options['use'] == 'raw') {
19 1
                    parent::run($value, $oldKey);
20 1
                } else {
21 1
                    parent::run($value, $key);
22
                }
23
24 2
                unset($data[$oldKey]);
25 2
                $new[$key] = $value;
26 2
            }
27 2
        }
28 2
        $data += $new; // yep, union operator here!
29 2
    }
30
}
31