Passed
Push — master ( bd41e0...b80a23 )
by Gabriel
02:52
created

ActivityMapper::map()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 22
Code Lines 18

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 8.6737
c 0
b 0
f 0
cc 5
eloc 18
nc 5
nop 2
1
<?php
2
3
namespace Waredesk\Mappers\Inventory\Item;
4
5
use Waredesk\Mapper;
6
use DateTime;
7
use Waredesk\Models\Inventory\Item\Activity;
8
9 View Code Duplication
class ActivityMapper extends Mapper
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...
10
{
11
    public function map(Activity $activity, array $data): Activity
12
    {
13
        $finalData = [];
14
        foreach ($data as $key => $value) {
15
            switch ($key) {
16
                case 'date':
17
                    $finalData['date'] = new DateTime($value);
18
                    break;
19
                case 'creation':
20
                    $finalData['creation'] = new DateTime($value);
21
                    break;
22
                case 'modification':
23
                    $finalData['modification'] = new DateTime($value);
24
                    break;
25
                default:
26
                    $finalData[$key] = $value;
27
                    break;
28
            }
29
        }
30
        $activity->reset($finalData);
31
        return $activity;
32
    }
33
}
34