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

AnnotationMapper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 22
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 19 4
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