| Conditions | 7 |
| Paths | 7 |
| Total Lines | 28 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 22 |
| CRAP Score | 7 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 3 | public function map(Item $item, array $data): Item |
|
| 16 | { |
||
| 17 | 3 | $finalData = []; |
|
| 18 | 3 | foreach ($data as $key => $value) { |
|
| 19 | switch ($key) { |
||
| 20 | 3 | case 'activities': |
|
| 21 | 3 | $finalData['activities'] = (new ActivitiesMapper())->map(new Activities(), $value); |
|
| 22 | 3 | break; |
|
| 23 | 3 | case 'attributes': |
|
| 24 | 3 | $finalData['attributes'] = (new AttributesMapper())->map(new Attributes(), $value); |
|
| 25 | 3 | break; |
|
| 26 | 3 | case 'in_stock': |
|
| 27 | 3 | $finalData['variants'] = (bool)$value; |
|
| 28 | 3 | break; |
|
| 29 | 3 | case 'creation': |
|
| 30 | 3 | $finalData['creation'] = new DateTime($value); |
|
| 31 | 3 | break; |
|
| 32 | 3 | case 'modification': |
|
| 33 | 3 | $finalData['modification'] = new DateTime($value); |
|
| 34 | 3 | break; |
|
| 35 | default: |
||
| 36 | 3 | $finalData[$key] = $value; |
|
| 37 | 3 | break; |
|
| 38 | } |
||
| 39 | } |
||
| 40 | 3 | $item->reset($finalData); |
|
| 41 | 3 | return $item; |
|
| 42 | } |
||
| 43 | } |
||
| 44 |