Conditions | 6 |
Paths | 6 |
Total Lines | 25 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
12 | 2 | public function map(Variable $variable, array $data): Variable |
|
13 | { |
||
14 | 2 | $finalData = []; |
|
15 | 2 | foreach ($data as $key => $value) { |
|
16 | switch ($key) { |
||
17 | 2 | case 'quantity': |
|
18 | $finalData['quantity'] = (int)$value; |
||
19 | break; |
||
20 | 2 | case 'elements': |
|
21 | 2 | $finalData['elements'] = (new ElementsMapper())->map($variable->getElements(), $value); |
|
22 | 2 | break; |
|
23 | 2 | case 'creation': |
|
24 | 2 | $finalData['creation'] = new DateTime($value); |
|
25 | 2 | break; |
|
26 | 2 | case 'modification': |
|
27 | 2 | $finalData['modification'] = new DateTime($value); |
|
28 | 2 | break; |
|
29 | default: |
||
30 | 2 | $finalData[$key] = $value; |
|
31 | 2 | break; |
|
32 | } |
||
33 | } |
||
34 | 2 | $variable->reset($finalData); |
|
35 | 2 | return $variable; |
|
36 | } |
||
37 | } |
||
38 |