Completed
Push — master ( b2620d...cacd0e )
by Gabriel
02:27
created

Price   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 19
lcom 1
cbo 0
dl 0
loc 92
ccs 0
cts 47
cp 0
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getPriceListId() 0 4 1
A getCurrency() 0 4 1
A getPrice() 0 4 1
A getCreationDatetime() 0 4 1
A getModificationDatetime() 0 4 1
D reset() 0 27 9
A setPriceList() 0 4 1
A setCurrency() 0 4 1
A setPrice() 0 4 1
A jsonSerialize() 0 8 1
1
<?php
2
3
namespace Waredesk\Models\Product\Variant;
4
5
use DateTime;
6
use JsonSerializable;
7
8
class Price implements JsonSerializable
9
{
10
    private $id;
11
    private $price_list_id;
12
    private $currency;
13
    private $price;
14
    private $creation_datetime;
15
    private $modification_datetime;
16
17
    public function getId(): ?int
18
    {
19
        return $this->id;
20
    }
21
22
    public function getPriceListId(): ?int
23
    {
24
        return $this->price_list_id;
25
    }
26
27
    public function getCurrency(): ?string
28
    {
29
        return $this->currency;
30
    }
31
32
    public function getPrice(): ?int
33
    {
34
        return $this->price;
35
    }
36
37
    public function getCreationDatetime(): ?DateTime
38
    {
39
        return $this->creation_datetime;
40
    }
41
42
    public function getModificationDatetime(): ?DateTime
43
    {
44
        return $this->modification_datetime;
45
    }
46
47
48
    public function reset(array $data = null)
49
    {
50
        if ($data) {
51
            foreach ($data as $key => $value) {
52
                switch ($key) {
53
                    case 'id':
0 ignored issues
show
Coding Style introduced by
case statements should be defined using a colon.

As per the PSR-2 coding standard, case statements should not be wrapped in curly braces. There is no need for braces, since each case is terminated by the next break.

There is also the option to use a semicolon instead of a colon, this is discouraged because many programmers do not even know it works and the colon is universal between programming languages.

switch ($expr) {
    case "A": { //wrong
        doSomething();
        break;
    }
    case "B"; //wrong
        doSomething();
        break;
    case "C": //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
54
                        $this->id = $value;
55
                        break;
56
                    case 'price_list_id':
57
                        $this->price_list_id = $value;
58
                        break;
59
                    case 'currency':
60
                        $this->currency = $value;
61
                        break;
62
                    case 'price':
63
                        $this->price = $value;
64
                        break;
65
                    case 'creation_datetime':
66
                        $this->creation_datetime = $value;
67
                        break;
68
                    case 'modification_datetime':
69
                        $this->modification_datetime = $value;
70
                        break;
71
                }
72
            }
73
        }
74
    }
75
76
    public function setPriceList(int $price_list_id)
77
    {
78
        $this->price_list_id = $price_list_id;
79
    }
80
81
    public function setCurrency(string $currency)
82
    {
83
        $this->currency = $currency;
84
    }
85
86
    public function setPrice(int $price)
87
    {
88
        $this->price = $price;
89
    }
90
91
    public function jsonSerialize()
92
    {
93
        return [
94
            'price_list_id' => $this->getPriceListId(),
95
            'currency' => $this->getCurrency(),
96
            'price' => $this->getPrice(),
97
        ];
98
    }
99
}
100