1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
4
|
|
|
* |
5
|
|
|
* NOTICE OF LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* @copyright Copyright (c) 2013-2015 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace eBayEnterprise\RetailOrderManagement\Payload\Order\Detail; |
17
|
|
|
|
18
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayload; |
19
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap; |
20
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator; |
21
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator; |
22
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\TPayload; |
23
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\PayloadFactory; |
24
|
|
|
use Psr\Log\LoggerInterface; |
25
|
|
|
use Psr\Log\NullLogger; |
26
|
|
|
|
27
|
|
|
class CustomerCareOrderItemTotals implements ICustomerCareOrderItemTotals |
28
|
|
|
{ |
29
|
|
|
use TPayload; |
30
|
|
|
|
31
|
|
|
/** @var float */ |
32
|
|
|
protected $charges; |
33
|
|
|
/** @var float */ |
34
|
|
|
protected $discount; |
35
|
|
|
/** @var float */ |
36
|
|
|
protected $extendedPrice; |
37
|
|
|
/** @var float */ |
38
|
|
|
protected $lineTotal; |
39
|
|
|
/** @var float */ |
40
|
|
|
protected $lineTotalWithoutTax; |
41
|
|
|
/** @var float */ |
42
|
|
|
protected $pricingQty; |
43
|
|
|
/** @var float */ |
44
|
|
|
protected $shippingCharges; |
45
|
|
|
/** @var float */ |
46
|
|
|
protected $shippingDiscount; |
47
|
|
|
/** @var float */ |
48
|
|
|
protected $shippingTotal; |
49
|
|
|
/** @var float */ |
50
|
|
|
protected $tax; |
51
|
|
|
/** @var float */ |
52
|
|
|
protected $unitPrice; |
53
|
|
|
/** @var string */ |
54
|
|
|
protected $minLineStatus; |
55
|
|
|
/** @var string */ |
56
|
|
|
protected $minLineStatusDescription; |
57
|
|
|
/** @var string */ |
58
|
|
|
protected $maxLineStatus; |
59
|
|
|
/** @var string */ |
60
|
|
|
protected $maxLineStatusDescription; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param IValidatorIterator |
64
|
|
|
* @param ISchemaValidator |
65
|
|
|
* @param IPayloadMap |
66
|
|
|
* @param LoggerInterface |
67
|
|
|
* @param IPayload |
68
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
69
|
|
|
*/ |
70
|
|
|
public function __construct( |
71
|
|
|
IValidatorIterator $validators, |
72
|
|
|
ISchemaValidator $schemaValidator, |
73
|
|
|
IPayloadMap $payloadMap, |
74
|
|
|
LoggerInterface $logger, |
75
|
|
|
IPayload $parentPayload = null |
76
|
|
|
) { |
77
|
|
|
$this->logger = $logger; |
|
|
|
|
78
|
|
|
$this->validators = $validators; |
79
|
|
|
$this->schemaValidator = $schemaValidator; |
80
|
|
|
$this->parentPayload = $parentPayload; |
81
|
|
|
$this->payloadMap = $payloadMap; |
82
|
|
|
$this->payloadFactory = $this->getNewPayloadFactory(); |
83
|
|
|
$this->isSerializeEmptyNode = false; |
84
|
|
|
$this->initOptionalExtractPaths(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Initialize the protected class property array self::optionalExtractionPaths with xpath |
89
|
|
|
* key/value pairs. |
90
|
|
|
* |
91
|
|
|
* @return self |
92
|
|
|
*/ |
93
|
|
|
protected function initOptionalExtractPaths() |
94
|
|
|
{ |
95
|
|
|
$this->optionalExtractionPaths = [ |
96
|
|
|
'charges' => 'x:Charges', |
97
|
|
|
'discount' => 'x:Discount', |
98
|
|
|
'extendedPrice' => 'x:ExtendedPrice', |
99
|
|
|
'lineTotal' => 'x:LineTotal', |
100
|
|
|
'lineTotalWithoutTax' => 'x:LineTotalWithoutTax', |
101
|
|
|
'pricingQty' => 'x:PricingQty', |
102
|
|
|
'shippingCharges' => 'x:ShippingCharges', |
103
|
|
|
'shippingDiscount' => 'x:ShippingDiscount', |
104
|
|
|
'shippingTotal' => 'x:ShippingTotal', |
105
|
|
|
'tax' => 'x:Tax', |
106
|
|
|
'unitPrice' => 'x:UnitPrice', |
107
|
|
|
'minLineStatus' => 'x:MinLineStatus', |
108
|
|
|
'minLineStatusDescription' => 'x:MinLineStatus/@description', |
109
|
|
|
'maxLineStatus' => 'x:MaxLineStatus', |
110
|
|
|
'maxLineStatusDescription' => 'x:MaxLineStatus/@description', |
111
|
|
|
]; |
112
|
|
|
return $this; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @see ICustomerCareOrderItemTotals::getCharges() |
117
|
|
|
*/ |
118
|
|
|
public function getCharges() |
119
|
|
|
{ |
120
|
|
|
return $this->charges; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @see ICustomerCareOrderItemTotals::setCharges() |
125
|
|
|
* @codeCoverageIgnore |
126
|
|
|
*/ |
127
|
|
|
public function setCharges($charges) |
128
|
|
|
{ |
129
|
|
|
$this->charges = $charges; |
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @see ICustomerCareOrderItemTotals::getDiscount() |
135
|
|
|
*/ |
136
|
|
|
public function getDiscount() |
137
|
|
|
{ |
138
|
|
|
return $this->discount; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @see ICustomerCareOrderItemTotals::setDiscount() |
143
|
|
|
* @codeCoverageIgnore |
144
|
|
|
*/ |
145
|
|
|
public function setDiscount($discount) |
146
|
|
|
{ |
147
|
|
|
$this->discount = $discount; |
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @see ICustomerCareOrderItemTotals::getExtendedPrice() |
153
|
|
|
*/ |
154
|
|
|
public function getExtendedPrice() |
155
|
|
|
{ |
156
|
|
|
return $this->extendedPrice; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @see ICustomerCareOrderItemTotals::setExtendedPrice() |
161
|
|
|
* @codeCoverageIgnore |
162
|
|
|
*/ |
163
|
|
|
public function setExtendedPrice($extendedPrice) |
164
|
|
|
{ |
165
|
|
|
$this->extendedPrice = $extendedPrice; |
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @see ICustomerCareOrderItemTotals::getLineTotal() |
171
|
|
|
*/ |
172
|
|
|
public function getLineTotal() |
173
|
|
|
{ |
174
|
|
|
return $this->lineTotal; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @see ICustomerCareOrderItemTotals::setLineTotal() |
179
|
|
|
* @codeCoverageIgnore |
180
|
|
|
*/ |
181
|
|
|
public function setLineTotal($lineTotal) |
182
|
|
|
{ |
183
|
|
|
$this->lineTotal = $lineTotal; |
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* @see ICustomerCareOrderItemTotals::getLineTotalWithoutTax() |
189
|
|
|
*/ |
190
|
|
|
public function getLineTotalWithoutTax() |
191
|
|
|
{ |
192
|
|
|
return $this->lineTotalWithoutTax; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @see ICustomerCareOrderItemTotals::setLineTotalWithoutTax() |
197
|
|
|
* @codeCoverageIgnore |
198
|
|
|
*/ |
199
|
|
|
public function setLineTotalWithoutTax($lineTotalWithoutTax) |
200
|
|
|
{ |
201
|
|
|
$this->lineTotalWithoutTax = $lineTotalWithoutTax; |
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* @see ICustomerCareOrderItemTotals::getPricingQty() |
207
|
|
|
*/ |
208
|
|
|
public function getPricingQty() |
209
|
|
|
{ |
210
|
|
|
return $this->pricingQty; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* @see ICustomerCareOrderItemTotals::setPricingQty() |
215
|
|
|
* @codeCoverageIgnore |
216
|
|
|
*/ |
217
|
|
|
public function setPricingQty($pricingQty) |
218
|
|
|
{ |
219
|
|
|
$this->pricingQty = $pricingQty; |
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @see ICustomerCareOrderItemTotals::getShippingCharges() |
225
|
|
|
*/ |
226
|
|
|
public function getShippingCharges() |
227
|
|
|
{ |
228
|
|
|
return $this->shippingCharges; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @see ICustomerCareOrderItemTotals::setShippingCharges() |
233
|
|
|
* @codeCoverageIgnore |
234
|
|
|
*/ |
235
|
|
|
public function setShippingCharges($shippingCharges) |
236
|
|
|
{ |
237
|
|
|
$this->shippingCharges = $shippingCharges; |
238
|
|
|
return $this; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @see ICustomerCareOrderItemTotals::getShippingDiscount() |
243
|
|
|
*/ |
244
|
|
|
public function getShippingDiscount() |
245
|
|
|
{ |
246
|
|
|
return $this->shippingDiscount; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @see ICustomerCareOrderItemTotals::setShippingDiscount() |
251
|
|
|
* @codeCoverageIgnore |
252
|
|
|
*/ |
253
|
|
|
public function setShippingDiscount($shippingDiscount) |
254
|
|
|
{ |
255
|
|
|
$this->shippingDiscount = $shippingDiscount; |
256
|
|
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @see ICustomerCareOrderItemTotals::getShippingTotal() |
261
|
|
|
*/ |
262
|
|
|
public function getShippingTotal() |
263
|
|
|
{ |
264
|
|
|
return $this->shippingTotal; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* @see ICustomerCareOrderItemTotals::setShippingTotal() |
269
|
|
|
* @codeCoverageIgnore |
270
|
|
|
*/ |
271
|
|
|
public function setShippingTotal($shippingTotal) |
272
|
|
|
{ |
273
|
|
|
$this->shippingTotal = $shippingTotal; |
274
|
|
|
return $this; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @see ICustomerCareOrderItemTotals::getTax() |
279
|
|
|
*/ |
280
|
|
|
public function getTax() |
281
|
|
|
{ |
282
|
|
|
return $this->tax; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @see ICustomerCareOrderItemTotals::setTax() |
287
|
|
|
* @codeCoverageIgnore |
288
|
|
|
*/ |
289
|
|
|
public function setTax($tax) |
290
|
|
|
{ |
291
|
|
|
$this->tax = $tax; |
292
|
|
|
return $this; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* @see ICustomerCareOrderItemTotals::getUnitPrice() |
297
|
|
|
*/ |
298
|
|
|
public function getUnitPrice() |
299
|
|
|
{ |
300
|
|
|
return $this->unitPrice; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* @see ICustomerCareOrderItemTotals::setUnitPrice() |
305
|
|
|
* @codeCoverageIgnore |
306
|
|
|
*/ |
307
|
|
|
public function setUnitPrice($unitPrice) |
308
|
|
|
{ |
309
|
|
|
$this->unitPrice = $unitPrice; |
310
|
|
|
return $this; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
/** |
314
|
|
|
* @see ICustomerCareOrderItemTotals::getMinLineStatus() |
315
|
|
|
*/ |
316
|
|
|
public function getMinLineStatus() |
317
|
|
|
{ |
318
|
|
|
return $this->minLineStatus; |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* @see ICustomerCareOrderItemTotals::setMinLineStatus() |
323
|
|
|
* @codeCoverageIgnore |
324
|
|
|
*/ |
325
|
|
|
public function setMinLineStatus($minLineStatus) |
326
|
|
|
{ |
327
|
|
|
$this->minLineStatus = $minLineStatus; |
328
|
|
|
return $this; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @see ICustomerCareOrderItemTotals::getMinLineStatusDescription() |
333
|
|
|
*/ |
334
|
|
|
public function getMinLineStatusDescription() |
335
|
|
|
{ |
336
|
|
|
return $this->minLineStatusDescription; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @see ICustomerCareOrderItemTotals::setMinLineStatusDescription() |
341
|
|
|
* @codeCoverageIgnore |
342
|
|
|
*/ |
343
|
|
|
public function setMinLineStatusDescription($minLineStatusDescription) |
344
|
|
|
{ |
345
|
|
|
$this->minLineStatusDescription = $minLineStatusDescription; |
346
|
|
|
return $this; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* @see ICustomerCareOrderItemTotals::getMaxLineStatus() |
351
|
|
|
*/ |
352
|
|
|
public function getMaxLineStatus() |
353
|
|
|
{ |
354
|
|
|
return $this->maxLineStatus; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
/** |
358
|
|
|
* @see ICustomerCareOrderItemTotals::setMaxLineStatus() |
359
|
|
|
* @codeCoverageIgnore |
360
|
|
|
*/ |
361
|
|
|
public function setMaxLineStatus($maxLineStatus) |
362
|
|
|
{ |
363
|
|
|
$this->maxLineStatus = $maxLineStatus; |
364
|
|
|
return $this; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @see ICustomerCareOrderItemTotals::getMaxLineStatusDescription() |
369
|
|
|
*/ |
370
|
|
|
public function getMaxLineStatusDescription() |
371
|
|
|
{ |
372
|
|
|
return $this->maxLineStatusDescription; |
373
|
|
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* @see ICustomerCareOrderItemTotals::setMaxLineStatusDescription() |
377
|
|
|
* @codeCoverageIgnore |
378
|
|
|
*/ |
379
|
|
|
public function setMaxLineStatusDescription($maxLineStatusDescription) |
380
|
|
|
{ |
381
|
|
|
$this->maxLineStatusDescription = $maxLineStatusDescription; |
382
|
|
|
return $this; |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* @see TPayload::serializeContents() |
387
|
|
|
*/ |
388
|
|
|
protected function serializeContents() |
389
|
|
|
{ |
390
|
|
|
return $this->serializeOptionalNumericValue('Charges', $this->getCharges()) |
391
|
|
|
. $this->serializeOptionalNumericValue('Discount', $this->getDiscount()) |
392
|
|
|
. $this->serializeOptionalNumericValue('ExtendedPrice', $this->getExtendedPrice()) |
393
|
|
|
. $this->serializeOptionalNumericValue('LineTotal', $this->getLineTotal()) |
394
|
|
|
. $this->serializeOptionalNumericValue('LineTotalWithoutTax', $this->getLineTotalWithoutTax()) |
395
|
|
|
. $this->serializeOptionalNumericValue('PricingQty', $this->getLineTotalWithoutTax()) |
396
|
|
|
. $this->serializeOptionalNumericValue('ShippingCharges', $this->getShippingCharges()) |
397
|
|
|
. $this->serializeOptionalNumericValue('ShippingDiscount', $this->getShippingDiscount()) |
398
|
|
|
. $this->serializeOptionalNumericValue('ShippingTotal', $this->getShippingTotal()) |
399
|
|
|
. $this->serializeOptionalNumericValue('Tax', $this->getTax()) |
400
|
|
|
. $this->serializeOptionalNumericValue('UnitPrice', $this->getUnitPrice()) |
401
|
|
|
. $this->serializeLineStatusValue('MinLineStatus', $this->getMinLineStatus(), $this->getMinLineStatusDescription()) |
402
|
|
|
. $this->serializeLineStatusValue('MaxLineStatus', $this->getMaxLineStatus(), $this->getMaxLineStatusDescription()); |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Serialize optional node of type Numeric values, which include |
407
|
|
|
* string with digits, int, and float data types. |
408
|
|
|
* |
409
|
|
|
* @param string |
410
|
|
|
* @param mixed |
411
|
|
|
* @return string | null |
412
|
|
|
*/ |
413
|
|
|
protected function serializeOptionalNumericValue($nodeName, $value) |
414
|
|
|
{ |
415
|
|
|
return is_numeric($value) ? $this->serializeRequiredValue($nodeName, $value) : null; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
/** |
419
|
|
|
* Serialize Min/Max line status XML node. |
420
|
|
|
* |
421
|
|
|
* @param string |
422
|
|
|
* @param string |
423
|
|
|
* @param string |
424
|
|
|
* @return string | null |
425
|
|
|
*/ |
426
|
|
|
protected function serializeLineStatusValue($nodeName, $value, $description) |
427
|
|
|
{ |
428
|
|
|
$descriptionAttribute = $this->serializeOptionalAttribute('description', $description); |
429
|
|
|
return $value |
430
|
|
|
? sprintf('<%s %s>%s</%1$s>', $nodeName, $descriptionAttribute, $this->xmlEncode($value)) : null; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
/** |
434
|
|
|
* @see TPayload::getRootNodeName() |
435
|
|
|
*/ |
436
|
|
|
protected function getRootNodeName() |
437
|
|
|
{ |
438
|
|
|
return static::ROOT_NODE; |
439
|
|
|
} |
440
|
|
|
|
441
|
|
|
/** |
442
|
|
|
* @see TPayload::getXmlNamespace() |
443
|
|
|
*/ |
444
|
|
|
protected function getXmlNamespace() |
445
|
|
|
{ |
446
|
|
|
return self::XML_NS; |
447
|
|
|
} |
448
|
|
|
} |
449
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..