Completed
Push — master ( e6ba08...9dbf89 )
by Gabriel
02:34
created

AnnotationMapper::map()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 0
cts 13
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 15
nc 4
nop 2
crap 20
1
<?php
2
3
namespace Waredesk\Mappers\Product\Variant;
4
5
use DateTime;
6
use Waredesk\Models\Product\Variant\Annotation;
7
8
class AnnotationMapper
9
{
10
    public function map(Annotation $option, $data): Annotation
11
    {
12
        $finalData = [];
13
        foreach ($data as $key => $value) {
14
            switch ($key) {
15
                case 'creation':
16
                    $finalData['creation'] = new DateTime($value);
17
                    break;
18
                case 'modification':
19
                    $finalData['modification'] = new DateTime($value);
20
                    break;
21
                default:
22
                    $finalData[$key] = $value;
23
                    break;
24
            }
25
        }
26
        $option->reset($finalData);
27
        return $option;
28
    }
29
}
30