1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace Korobovn\CloudPayments\Message\Receipt; |
6
|
|
|
|
7
|
|
|
use Korobovn\CloudPayments\Message\Reference\Vat; |
8
|
|
|
use Korobovn\CloudPayments\Message\Reference\PaymentType; |
9
|
|
|
use Korobovn\CloudPayments\Message\Reference\PaymentObject; |
10
|
|
|
|
11
|
|
|
class Item |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Product name |
15
|
|
|
* |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $label; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Price. |
22
|
|
|
* |
23
|
|
|
* @var float |
24
|
|
|
*/ |
25
|
|
|
protected $price; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Quantity |
29
|
|
|
* |
30
|
|
|
* @var float |
31
|
|
|
*/ |
32
|
|
|
protected $quantity; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Amount. |
36
|
|
|
* |
37
|
|
|
* @var float |
38
|
|
|
*/ |
39
|
|
|
protected $amount; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* VAT rate. |
43
|
|
|
* |
44
|
|
|
* @see Vat |
45
|
|
|
* |
46
|
|
|
* @var int|null |
47
|
|
|
*/ |
48
|
|
|
protected $vat; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* A sign of a calculation method is a sign of a calculation method. |
52
|
|
|
* |
53
|
|
|
* @see PaymentType |
54
|
|
|
* |
55
|
|
|
* @var int |
56
|
|
|
*/ |
57
|
|
|
protected $method; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Sign of the subject of calculation - a sign of the subject of goods, work, services, payment, payment, other subject of calculation. |
61
|
|
|
* |
62
|
|
|
* @see PaymentObject |
63
|
|
|
* |
64
|
|
|
* @var int |
65
|
|
|
*/ |
66
|
|
|
protected $object; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Unit of measurement. |
70
|
|
|
* |
71
|
|
|
* @var string |
72
|
|
|
*/ |
73
|
|
|
protected $measurement_unit; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Product name. |
77
|
|
|
* |
78
|
|
|
* @param string $label |
79
|
|
|
* |
80
|
|
|
* @return Item |
81
|
|
|
*/ |
82
|
|
|
public function setLabel(string $label): self |
83
|
|
|
{ |
84
|
|
|
$this->label = $label; |
85
|
|
|
|
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Price. |
91
|
|
|
* |
92
|
|
|
* @param float $price |
93
|
|
|
* |
94
|
|
|
* @return Item |
95
|
|
|
*/ |
96
|
|
|
public function setPrice(float $price): self |
97
|
|
|
{ |
98
|
|
|
$this->price = $price; |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Quantity. |
105
|
|
|
* |
106
|
|
|
* @param float $quantity |
107
|
|
|
* |
108
|
|
|
* @return Item |
109
|
|
|
*/ |
110
|
|
|
public function setQuantity(float $quantity): self |
111
|
|
|
{ |
112
|
|
|
$this->quantity = $quantity; |
113
|
|
|
|
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Amount. |
119
|
|
|
* |
120
|
|
|
* @param float $amount |
121
|
|
|
* |
122
|
|
|
* @return Item |
123
|
|
|
*/ |
124
|
|
|
public function setAmount(float $amount): self |
125
|
|
|
{ |
126
|
|
|
$this->amount = $amount; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* VAT rate. |
133
|
|
|
* |
134
|
|
|
* @param int|null $vat |
135
|
|
|
* |
136
|
|
|
* @return Item |
137
|
|
|
*/ |
138
|
|
|
public function setVat(?int $vat): self |
139
|
|
|
{ |
140
|
|
|
$this->vat = $vat; |
141
|
|
|
|
142
|
|
|
return $this; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* A sign of a calculation method is a sign of a calculation method. |
147
|
|
|
* |
148
|
|
|
* @param int $method |
149
|
|
|
* |
150
|
|
|
* @see PaymentType |
151
|
|
|
* |
152
|
|
|
* @return Item |
153
|
|
|
*/ |
154
|
|
|
public function setMethod(int $method): self |
155
|
|
|
{ |
156
|
|
|
$this->method = $method; |
157
|
|
|
|
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Sign of the subject of calculation - a sign of the subject of goods, work, services, payment, payment, other subject of calculation. |
163
|
|
|
* |
164
|
|
|
* @param int $object |
165
|
|
|
* |
166
|
|
|
* @return Item |
167
|
|
|
*/ |
168
|
|
|
public function setObject(int $object): self |
169
|
|
|
{ |
170
|
|
|
$this->object = $object; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Unit of measurement. |
177
|
|
|
* |
178
|
|
|
* @param string $measurement_unit |
179
|
|
|
* |
180
|
|
|
* @return Item |
181
|
|
|
*/ |
182
|
|
|
public function setMeasurementUnit(string $measurement_unit): self |
183
|
|
|
{ |
184
|
|
|
$this->measurement_unit = $measurement_unit; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @return array |
191
|
|
|
*/ |
192
|
|
|
public function toArray(): array |
193
|
|
|
{ |
194
|
|
|
return \array_filter([ |
195
|
|
|
'label' => $this->label, |
196
|
|
|
'price' => $this->price, |
197
|
|
|
'quantity' => $this->quantity, |
198
|
|
|
'amount' => $this->amount, |
199
|
|
|
'vat' => $this->vat, |
200
|
|
|
'method' => $this->method, |
201
|
|
|
'object' => $this->object, |
202
|
|
|
'measurementUnit' => $this->measurement_unit, |
203
|
|
|
]); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|