1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ups\Entity; |
4
|
|
|
|
5
|
|
|
use LogicException; |
6
|
|
|
|
7
|
|
|
class ShipmentCharge |
8
|
|
|
{ |
9
|
|
|
const SHIPMENT_CHARGE_TYPE_TRANSPORTATION = '01'; |
10
|
|
|
const SHIPMENT_CHARGE_TYPE_DUTIES = '02'; |
11
|
|
|
|
12
|
|
|
const TYPE_BILL_SHIPPER = 'billShipper'; |
13
|
|
|
const TYPE_BILL_RECEIVER = 'billReceiver'; |
14
|
|
|
const TYPE_BILL_THIRD_PARTY = 'billThirdParty'; |
15
|
|
|
const TYPE_CONSIGNEE_BILLED = 'consigneeBilled'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var type |
19
|
|
|
*/ |
20
|
|
|
private $type; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var billShipper |
24
|
|
|
*/ |
25
|
|
|
private $billShipper; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var billReceiver |
29
|
|
|
*/ |
30
|
|
|
private $billReceiver; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var BillThirdParty |
34
|
|
|
*/ |
35
|
|
|
private $billThirdParty; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
private $consigneeBilled; |
41
|
|
|
|
42
|
|
|
public function __construct($type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION, $bill_type = self::TYPE_BILL_SHIPPER, $attributes = null) |
43
|
|
|
{ |
44
|
|
|
switch ($type) { |
45
|
|
|
case self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION: |
46
|
|
|
$this->type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION; |
|
|
|
|
47
|
|
|
break; |
48
|
|
|
case self::SHIPMENT_CHARGE_TYPE_DUTIES: |
49
|
|
|
$this->type = self::SHIPMENT_CHARGE_TYPE_DUTIES; |
|
|
|
|
50
|
|
|
break; |
51
|
|
|
default: |
52
|
|
|
throw new LogicException(sprintf('Unknown ShipmentCharge charge type requested: "%s"', $type)); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
switch ($bill_type) { |
56
|
|
|
case self::TYPE_BILL_SHIPPER: |
57
|
|
|
$this->billShipper = new BillShipper($attributes); |
58
|
|
|
break; |
59
|
|
|
/* TODO |
|
|
|
|
60
|
|
|
case self::TYPE_BILL_RECEIVER: |
61
|
|
|
$this->billReceiver = new BillReceiver($attributes); |
62
|
|
|
break; |
63
|
|
|
*/ |
64
|
|
|
case self::TYPE_BILL_THIRD_PARTY: |
65
|
|
|
$this->billThirdParty = new BillThirdParty($attributes); |
66
|
|
|
break; |
67
|
|
|
case self::TYPE_CONSIGNEE_BILLED: |
68
|
|
|
$this->consigneeBilled = true; |
69
|
|
|
break; |
70
|
|
|
default: |
71
|
|
|
throw new LogicException(sprintf('Unknown ShipmentCharge type requested: "%s"', $type)); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return BillShipper |
77
|
|
|
*/ |
78
|
|
|
public function getBillShipper() |
79
|
|
|
{ |
80
|
|
|
return $this->billShipper; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param BillShipper $billShipper |
85
|
|
|
* @return ShipmentCharge |
86
|
|
|
*/ |
87
|
|
|
public function setBillShipper(BillShipper $billShipper= null) |
88
|
|
|
{ |
89
|
|
|
$this->billShipper = $billShipper; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return BillReceiver |
96
|
|
|
*/ |
97
|
|
|
public function getBillReceiver() |
98
|
|
|
{ |
99
|
|
|
return $this->billReceiver; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param BillReceiver $billReceiver |
104
|
|
|
* @return ShipmentCharge |
105
|
|
|
*/ |
106
|
|
|
public function setBillReceiver(BillReceiver $billReceiver= null) |
107
|
|
|
{ |
108
|
|
|
$this->billReceiver = $billReceiver; |
109
|
|
|
|
110
|
|
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return BillThirdParty |
115
|
|
|
*/ |
116
|
|
|
public function getBillThirdParty() |
117
|
|
|
{ |
118
|
|
|
return $this->billThirdParty; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param BillThirdParty $billThirdParty |
123
|
|
|
* @return ShipmentCharge |
124
|
|
|
*/ |
125
|
|
|
public function setBillThirdParty(BillThirdParty $billThirdParty = null) |
126
|
|
|
{ |
127
|
|
|
$this->billThirdParty = $billThirdParty; |
128
|
|
|
|
129
|
|
|
return $this; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return bool |
134
|
|
|
*/ |
135
|
|
|
public function getConsigneeBilled() |
136
|
|
|
{ |
137
|
|
|
return $this->consigneeBilled; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param bool $consigneeBilled |
142
|
|
|
* @return ShipmentCharge |
143
|
|
|
*/ |
144
|
|
|
public function setConsigneeBilled($consigneeBilled) |
145
|
|
|
{ |
146
|
|
|
$this->consigneeBilled = $consigneeBilled; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return String |
153
|
|
|
*/ |
154
|
|
|
public function getType() |
155
|
|
|
{ |
156
|
|
|
return $this->type; |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|
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..