1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ups\Entity; |
4
|
|
|
|
5
|
|
|
class Delivery |
6
|
|
|
{ |
7
|
|
|
public $PackageReferenceNumber; |
8
|
|
|
public $ShipmentReferenceNumber; |
9
|
|
|
public $TrackingNumber; |
10
|
|
|
public $ShipperNumber; |
11
|
|
|
public $Date; |
12
|
|
|
public $Time; |
13
|
|
|
public $DriverRelease; |
14
|
|
|
public $ActivityLocation; |
15
|
|
|
public $DeliveryLocation; |
16
|
|
|
public $COD; |
17
|
|
|
public $BillToAccount; |
18
|
|
|
|
19
|
|
|
public function __construct($response = null) |
20
|
|
|
{ |
21
|
|
|
$this->ShipmentReferenceNumber = new ShipmentReferenceNumber(); |
22
|
|
|
$this->PackageReferenceNumber = new PackageReferenceNumber(); |
23
|
|
|
$this->ActivityLocation = new ActivityLocation(); |
24
|
|
|
$this->DeliveryLocation = new DeliveryLocation(); |
25
|
|
|
$this->COD = new COD(); |
26
|
|
|
$this->BillToAccount = new BillToAccount(); |
27
|
|
|
|
28
|
|
|
if (null != $response) { |
29
|
|
View Code Duplication |
if (isset($response->PackageReferenceNumber)) { |
|
|
|
|
30
|
|
|
if (is_array($response->PackageReferenceNumber)) { |
31
|
|
|
foreach ($response->PackageReferenceNumber as $PackageReferenceNumber) { |
32
|
|
|
$this->PackageReferenceNumber[] = new PackageReferenceNumber($PackageReferenceNumber); |
33
|
|
|
} |
34
|
|
|
} else { |
35
|
|
|
$this->PackageReferenceNumber[] = new PackageReferenceNumber($response->PackageReferenceNumber); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
View Code Duplication |
if (isset($response->ShipmentReferenceNumber)) { |
|
|
|
|
39
|
|
|
if (is_array($response->ShipmentReferenceNumber)) { |
40
|
|
|
foreach ($response->ShipmentReferenceNumber as $ShipmentReferenceNumber) { |
41
|
|
|
$this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($ShipmentReferenceNumber); |
42
|
|
|
} |
43
|
|
|
} else { |
44
|
|
|
$this->ShipmentReferenceNumber[] = new ShipmentReferenceNumber($response->ShipmentReferenceNumber); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
if (isset($response->TrackingNumber)) { |
48
|
|
|
$this->TrackingNumber = $response->TrackingNumber; |
49
|
|
|
} |
50
|
|
|
if (isset($response->ShipperNumber)) { |
51
|
|
|
$this->ShipperNumber = $response->ShipperNumber; |
52
|
|
|
} |
53
|
|
|
if (isset($response->Date)) { |
54
|
|
|
$this->Date = $response->Date; |
55
|
|
|
} |
56
|
|
|
if (isset($response->Time)) { |
57
|
|
|
$this->Time = $response->Time; |
58
|
|
|
} |
59
|
|
|
if (isset($response->DriverRelease)) { |
60
|
|
|
$this->DriverRelease = $response->DriverRelease; |
61
|
|
|
} |
62
|
|
|
if (isset($response->ActivityLocation)) { |
63
|
|
|
$this->ActivityLocation = new ActivityLocation($response->ActivityLocation); |
64
|
|
|
} |
65
|
|
|
if (isset($response->DeliveryLocation)) { |
66
|
|
|
$this->DeliveryLocation = new DeliveryLocation($response->DeliveryLocation); |
67
|
|
|
} |
68
|
|
|
if (isset($response->COD)) { |
69
|
|
|
$this->COD = new COD($response->COD); |
70
|
|
|
} |
71
|
|
|
if (isset($response->BillToAccount)) { |
72
|
|
|
$this->BillToAccount = new BillToAccount($response->BillToAccount); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.