1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ups\Entity; |
4
|
|
|
|
5
|
|
|
use DOMDocument; |
6
|
|
|
|
7
|
|
|
class ItemizedPaymentInformation |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @var ShipmentCharge |
12
|
|
|
*/ |
13
|
|
|
private $transporation; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var ShipmentCharge |
17
|
|
|
*/ |
18
|
|
|
private $dutyAndTax; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var bool |
22
|
|
|
*/ |
23
|
|
|
private $splitDutyVATIndicator; |
24
|
|
|
|
25
|
|
|
public function __construct($attributes = null) |
26
|
|
|
{ |
27
|
|
|
if (isset($attributes->ShipmentCharges)) { |
28
|
|
|
foreach ($attributes->ShipmentCharges as $shipmentCharge) { |
29
|
|
|
if (!isset($shipmentCharge->Type)) { |
30
|
|
|
continue; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
if ($shipmentCharge->Type === ShipmentCharge::TYPE_TRANSPORTATION) { |
34
|
|
|
$this->setTransportation(new ShipmentCharge($shipmentCharge)); |
35
|
|
|
} elseif ($shipmentCharge->Type === ShipmentCharge::TYPE_DUTY_AND_TAX) { |
36
|
|
|
$this->setDutyAndTax(new ShipmentCharge($shipmentCharge)); |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (isset($attributes->SplitDutyVATIndicator)) { |
42
|
|
|
$this->setSplitDutyVATIndicator($attributes->SplitDutyVATIndicator); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param null|DOMDocument $document |
48
|
|
|
* |
49
|
|
|
* @return DOMElement |
50
|
|
|
*/ |
51
|
|
|
public function toNode(DOMDocument $document = null) |
52
|
|
|
{ |
53
|
|
|
if (is_null($document)) { |
54
|
|
|
$document = new DOMDocument(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
$node = $document->createElement('ItemizedPaymentInformation'); |
58
|
|
|
if ($this->getTransportation()) { |
59
|
|
|
$node->appendChild($this->getTransportation()->toNode($document)); |
60
|
|
|
} |
61
|
|
|
if ($this->getDutyAndTax()) { |
62
|
|
|
$node->appendChild($this->getDutyAndTax()->toNode($document)); |
63
|
|
|
} |
64
|
|
|
if ($this->getSplitDutyVATIndicator()) { |
65
|
|
|
$node->appendChild($document->createElement('SplitDutyVATIndicator')); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $node; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return ShipmentCharge |
73
|
|
|
*/ |
74
|
|
|
public function getTransportation() |
75
|
|
|
{ |
76
|
|
|
return $this->transportation; |
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param ShipmentCharge $transportation |
81
|
|
|
* |
82
|
|
|
* @return ItemizedPaymentInformation |
83
|
|
|
*/ |
84
|
|
|
public function setTransportation(ShipmentCharge $transportation) |
85
|
|
|
{ |
86
|
|
|
$this->transportation = $transportation; |
|
|
|
|
87
|
|
|
|
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return ShipmentCharge |
93
|
|
|
*/ |
94
|
|
|
public function getDutyAndTax() |
95
|
|
|
{ |
96
|
|
|
return $this->dutyAndTax; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param ShipmentCharge $dutyAndTax |
101
|
|
|
* |
102
|
|
|
* @return ItemizedPaymentInformation |
103
|
|
|
*/ |
104
|
|
|
public function setDutyAndTax(ShipmentCharge $dutyAndTax) |
105
|
|
|
{ |
106
|
|
|
$this->dutyAndTax = $dutyAndTax; |
107
|
|
|
|
108
|
|
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @return bool |
113
|
|
|
*/ |
114
|
|
|
public function getSplitDutyVATIndicator() |
115
|
|
|
{ |
116
|
|
|
return $this->splitDutyVATIndicator; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param bool $splitDutyVATIndicator |
121
|
|
|
* |
122
|
|
|
* @return ItemizedPaymentInformation |
123
|
|
|
*/ |
124
|
|
|
public function setSplityDutyVATIndicator($splitDutyVATIndicator) |
125
|
|
|
{ |
126
|
|
|
$this->splitDutyVATIndicator = $splitDutyVATIndicator; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.