1 | <?php |
||
8 | class OrderLine extends Payload implements OrderLineInterface |
||
9 | { |
||
10 | const GOODS_TYPE_SHIPMENT = 'shipment'; |
||
11 | const GOODS_TYPE_HANDLING = 'handling'; |
||
12 | const GOODS_TYPE_ITEM = 'item'; |
||
13 | const GOODS_TYPE_REFUND = 'refund'; |
||
14 | |||
15 | /** |
||
16 | * Used to create Money objects |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $currency; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $description; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $itemId; |
||
31 | |||
32 | /** |
||
33 | * @var float |
||
34 | */ |
||
35 | protected $quantity; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $unitPrice; |
||
41 | |||
42 | /** |
||
43 | * @var float |
||
44 | */ |
||
45 | protected $taxPercent; |
||
46 | |||
47 | /** |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $taxAmount; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $unitCode; |
||
56 | |||
57 | /** |
||
58 | * @var int |
||
59 | */ |
||
60 | protected $discount; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $goodsType; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $imageUrl; |
||
71 | |||
72 | 15 | public function __construct(string $description, string $itemId, float $quantity, Money $unitPrice) |
|
81 | |||
82 | 3 | public function getPayload() : array |
|
101 | |||
102 | 3 | public function validate() |
|
115 | |||
116 | /** |
||
117 | * @return array |
||
118 | */ |
||
119 | 6 | public static function getGoodsTypes() : array |
|
128 | |||
129 | /** |
||
130 | * @return string |
||
131 | */ |
||
132 | 3 | public function getDescription() : string |
|
136 | |||
137 | /** |
||
138 | * @param string $description |
||
139 | * @return OrderLine |
||
140 | */ |
||
141 | 15 | public function setDescription(string $description) : self |
|
146 | |||
147 | /** |
||
148 | * @return string |
||
149 | */ |
||
150 | 3 | public function getItemId() : string |
|
154 | |||
155 | /** |
||
156 | * @param string $itemId |
||
157 | * @return OrderLine |
||
158 | */ |
||
159 | 15 | public function setItemId(string $itemId) : self |
|
164 | |||
165 | /** |
||
166 | * @return float |
||
167 | */ |
||
168 | 3 | public function getQuantity() : float |
|
172 | |||
173 | /** |
||
174 | * @param float $quantity |
||
175 | * @return OrderLine |
||
176 | */ |
||
177 | 15 | public function setQuantity(float $quantity) : self |
|
182 | |||
183 | /** |
||
184 | * @return Money |
||
185 | */ |
||
186 | 6 | public function getUnitPrice() : ?Money |
|
190 | |||
191 | /** |
||
192 | * @param Money $unitPrice |
||
193 | * @return OrderLine |
||
194 | */ |
||
195 | 15 | public function setUnitPrice(Money $unitPrice) : self |
|
204 | |||
205 | /** |
||
206 | * @return float |
||
207 | */ |
||
208 | 3 | public function getTaxPercent() : ?float |
|
212 | |||
213 | /** |
||
214 | * @param float $taxPercent |
||
215 | * @return OrderLine |
||
216 | */ |
||
217 | 3 | public function setTaxPercent(float $taxPercent) : self |
|
222 | |||
223 | /** |
||
224 | * @return Money |
||
225 | */ |
||
226 | 6 | public function getTaxAmount() : ?Money |
|
234 | |||
235 | /** |
||
236 | * @param Money $taxAmount |
||
237 | * @return OrderLine |
||
238 | */ |
||
239 | 6 | public function setTaxAmount(Money $taxAmount) : self |
|
248 | |||
249 | /** |
||
250 | * @return string |
||
251 | */ |
||
252 | 3 | public function getUnitCode() : ?string |
|
256 | |||
257 | /** |
||
258 | * @param string $unitCode |
||
259 | * @return OrderLine |
||
260 | */ |
||
261 | 6 | public function setUnitCode(string $unitCode) : self |
|
266 | |||
267 | /** |
||
268 | * @return Money |
||
269 | */ |
||
270 | 6 | public function getDiscount() : ?Money |
|
278 | |||
279 | /** |
||
280 | * @param Money $discount |
||
281 | * @return OrderLine |
||
282 | */ |
||
283 | 3 | public function setDiscount(Money $discount) : self |
|
292 | |||
293 | /** |
||
294 | * @return string |
||
295 | */ |
||
296 | 3 | public function getGoodsType() : ?string |
|
300 | |||
301 | /** |
||
302 | * @param string $goodsType |
||
303 | * @return OrderLine |
||
304 | */ |
||
305 | 6 | public function setGoodsType(string $goodsType) : self |
|
310 | |||
311 | /** |
||
312 | * @return string |
||
313 | */ |
||
314 | 3 | public function getImageUrl() : ?string |
|
318 | |||
319 | /** |
||
320 | * @param string $imageUrl |
||
321 | * @return OrderLine |
||
322 | */ |
||
323 | 3 | public function setImageUrl(string $imageUrl) : self |
|
328 | } |
||
329 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.