Completed
Push — master ( c3c281...ab94e9 )
by Gabriel
03:37
created

PriceMapper   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 29
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C map() 0 26 8
1
<?php
2
3
namespace Waredesk\Mappers\Product\Variant;
4
5
use DateTime;
6
use Waredesk\Models\Product\Variant\Option;
7
use Waredesk\Models\Product\Variant\Price;
8
9
class PriceMapper
10
{
11
    public function map(Price $price, $data): Price
12
    {
13
        foreach ($data as $key => $value) {
14
            switch ($key) {
15
                case 'id':
16
                    $price->setId((int)$value);
17
                    break;
18
                case 'price_list_id':
19
                    $price->setPriceListId((int)$value);
20
                    break;
21
                case 'currency':
22
                    $price->setCurrency($value);
23
                    break;
24
                case 'price':
25
                    $price->setPrice((int)$value);
26
                    break;
27
                case 'creation_datetime':
28
                    $price->setCreationDatetime(new DateTime($value));
29
                    break;
30
                case 'modification_datetime':
31
                    $price->setModificationDatetime(new DateTime($value));
32
                    break;
33
            }
34
        }
35
        return $price;
36
    }
37
}
38