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 string |
19
|
|
|
*/ |
20
|
|
|
private $type; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var BillShipper |
24
|
|
|
*/ |
25
|
|
|
private $billShipper; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var BillReceiver |
29
|
|
|
* TODO not implemented yet |
30
|
|
|
*/ |
31
|
|
|
private $billReceiver; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var BillThirdParty |
35
|
|
|
*/ |
36
|
|
|
private $billThirdParty; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var bool |
40
|
|
|
*/ |
41
|
|
|
private $consigneeBilled; |
42
|
|
|
|
43
|
|
|
public function __construct($type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION, $bill_type = self::TYPE_BILL_SHIPPER, $attributes = null) |
44
|
|
|
{ |
45
|
|
|
switch ($type) { |
46
|
|
|
case self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION: |
47
|
|
|
$this->type = self::SHIPMENT_CHARGE_TYPE_TRANSPORTATION; |
48
|
|
|
break; |
49
|
|
|
case self::SHIPMENT_CHARGE_TYPE_DUTIES: |
50
|
|
|
$this->type = self::SHIPMENT_CHARGE_TYPE_DUTIES; |
51
|
|
|
break; |
52
|
|
|
default: |
53
|
|
|
throw new LogicException(sprintf('Unknown ShipmentCharge charge type requested: "%s"', $type)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
switch ($bill_type) { |
57
|
|
|
case self::TYPE_BILL_SHIPPER: |
58
|
|
|
$this->billShipper = new BillShipper($attributes); |
59
|
|
|
break; |
60
|
|
|
/* TODO |
|
|
|
|
61
|
|
|
case self::TYPE_BILL_RECEIVER: |
62
|
|
|
$this->billReceiver = new BillReceiver($attributes); |
63
|
|
|
break; |
64
|
|
|
*/ |
65
|
|
|
case self::TYPE_BILL_THIRD_PARTY: |
66
|
|
|
$this->billThirdParty = new BillThirdParty($attributes); |
67
|
|
|
break; |
68
|
|
|
case self::TYPE_CONSIGNEE_BILLED: |
69
|
|
|
$this->consigneeBilled = true; |
70
|
|
|
break; |
71
|
|
|
default: |
72
|
|
|
throw new LogicException(sprintf('Unknown ShipmentCharge type requested: "%s"', $type)); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return BillShipper |
78
|
|
|
*/ |
79
|
|
|
public function getBillShipper() |
80
|
|
|
{ |
81
|
|
|
return $this->billShipper; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param BillShipper $billShipper |
86
|
|
|
* @return ShipmentCharge |
87
|
|
|
*/ |
88
|
|
|
public function setBillShipper(BillShipper $billShipper) |
89
|
|
|
{ |
90
|
|
|
$this->billShipper = $billShipper; |
91
|
|
|
|
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @return BillReceiver |
97
|
|
|
*/ |
98
|
|
|
public function getBillReceiver() |
99
|
|
|
{ |
100
|
|
|
return $this->billReceiver; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param BillReceiver $billReceiver |
105
|
|
|
* @return ShipmentCharge |
106
|
|
|
*/ |
107
|
|
|
public function setBillReceiver(BillReceiver $billReceiver= null) |
108
|
|
|
{ |
109
|
|
|
$this->billReceiver = $billReceiver; |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return BillThirdParty |
116
|
|
|
*/ |
117
|
|
|
public function getBillThirdParty() |
118
|
|
|
{ |
119
|
|
|
return $this->billThirdParty; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param BillThirdParty $billThirdParty |
124
|
|
|
* @return ShipmentCharge |
125
|
|
|
*/ |
126
|
|
|
public function setBillThirdParty(BillThirdParty $billThirdParty = null) |
127
|
|
|
{ |
128
|
|
|
$this->billThirdParty = $billThirdParty; |
129
|
|
|
|
130
|
|
|
return $this; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @return bool |
135
|
|
|
*/ |
136
|
|
|
public function getConsigneeBilled() |
137
|
|
|
{ |
138
|
|
|
return $this->consigneeBilled; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param bool $consigneeBilled |
143
|
|
|
* @return ShipmentCharge |
144
|
|
|
*/ |
145
|
|
|
public function setConsigneeBilled($consigneeBilled) |
146
|
|
|
{ |
147
|
|
|
$this->consigneeBilled = $consigneeBilled; |
148
|
|
|
|
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return string |
154
|
|
|
*/ |
155
|
|
|
public function getType() |
156
|
|
|
{ |
157
|
|
|
return $this->type; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.