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': |
|
|
|
|
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
|
|
|
|
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.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.