Conditions | 39 |
Paths | > 20000 |
Total Lines | 124 |
Code Lines | 83 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
41 | public function __construct($response = null) |
||
42 | { |
||
43 | $this->Shipper = new Shipper(); |
||
44 | $this->ReferenceNumber = new ReferenceNumber(); |
||
45 | $this->Service = new Service(); |
||
46 | $this->ShipmentServiceOptions = new ShipmentServiceOptions(); |
||
47 | $this->CustomsValue = new CustomsValue(); |
||
48 | $this->BillToAccount = new BillToAccount(); |
||
49 | $this->UAPAddress = new Address(); |
||
50 | |||
51 | if (null != $response) { |
||
52 | if (isset($response->Shipper)) { |
||
53 | $this->Shipper = new Shipper($response->Shipper); |
||
54 | } |
||
55 | if (isset($response->ShipTo)) { |
||
56 | $this->ShipTo = new ShipTo($response->ShipTo); |
||
57 | } |
||
58 | if (isset($response->ReferenceNumber)) { |
||
59 | if (is_array($response->ReferenceNumber)) { |
||
60 | foreach ($response->ReferenceNumber as $ReferenceNumber) { |
||
61 | $this->ReferenceNumber[] = new ReferenceNumber($ReferenceNumber); |
||
62 | } |
||
63 | } else { |
||
64 | $this->ReferenceNumber[] = new ReferenceNumber($response->ReferenceNumber); |
||
65 | } |
||
66 | } |
||
67 | if (isset($response->Service)) { |
||
68 | $this->Service = new Service($response->Service); |
||
69 | } |
||
70 | if (isset($response->PickupDate)) { |
||
71 | $this->PickupDate = $response->PickupDate; |
||
72 | } |
||
73 | if (isset($response->ScheduledDeliveryDate)) { |
||
74 | $this->ScheduledDeliveryDate = $response->ScheduledDeliveryDate; |
||
75 | } |
||
76 | if (isset($response->ScheduledDeliveryTime)) { |
||
77 | $this->ScheduledDeliveryTime = $response->ScheduledDeliveryTime; |
||
78 | } |
||
79 | if (isset($response->DocumentsOnly)) { |
||
80 | $this->DocumentsOnly = $response->DocumentsOnly; |
||
81 | } |
||
82 | if (isset($response->Package)) { |
||
83 | if (is_array($response->Package)) { |
||
84 | foreach ($response->Package as $Package) { |
||
85 | $this->Package[] = new Package($Package); |
||
86 | } |
||
87 | } else { |
||
88 | $this->Package[] = new Package($response->Package); |
||
89 | } |
||
90 | } |
||
91 | if (isset($response->ShipmentServiceOptions)) { |
||
92 | $this->ShipmentServiceOptions = new ShipmentServiceOptions($response->ShipmentServiceOptions); |
||
93 | } |
||
94 | if (isset($response->ManufactureCountry)) { |
||
95 | $this->ManufactureCountry = $response->ManufactureCountry; |
||
96 | } |
||
97 | if (isset($response->HarmonizedCode)) { |
||
98 | $this->HarmonizedCode = $response->HarmonizedCode; |
||
99 | } |
||
100 | if (isset($response->CustomsValue)) { |
||
101 | $this->CustomsValue = new CustomsValue($response->CustomsValue); |
||
102 | } |
||
103 | if (isset($response->SpecialInstructions)) { |
||
104 | $this->SpecialInstructions = $response->SpecialInstructions; |
||
105 | } |
||
106 | if (isset($response->ShipmentChargeType)) { |
||
107 | $this->ShipmentChargeType = $response->ShipmentChargeType; |
||
108 | } |
||
109 | if (isset($response->BillToAccount)) { |
||
110 | $this->BillToAccount = new BillToAccount($response->BillToAccount); |
||
111 | } |
||
112 | if (isset($response->ConsigneeBillIndicator)) { |
||
113 | $this->ConsigneeBillIndicator = $response->ConsigneeBillIndicator; |
||
114 | } |
||
115 | if (isset($response->CollectBillIndicator)) { |
||
116 | $this->CollectBillIndicator = $response->CollectBillIndicator; |
||
117 | } |
||
118 | if (isset($response->LocationAssured)) { |
||
119 | $this->LocationAssured = $response->LocationAssured; |
||
120 | } |
||
121 | if (isset($response->ImportControl)) { |
||
122 | $this->ImportControl = $response->ImportControl; |
||
123 | } |
||
124 | if (isset($response->LabelDeliveryMethod)) { |
||
125 | $this->LabelDeliveryMethod = $response->LabelDeliveryMethod; |
||
126 | } |
||
127 | if (isset($response->CommercialInvoiceRemoval)) { |
||
128 | $this->CommercialInvoiceRemoval = $response->CommercialInvoiceRemoval; |
||
129 | } |
||
130 | if (isset($response->PostalServiceTrackingID)) { |
||
131 | $this->PostalServiceTrackingID = $response->PostalServiceTrackingID; |
||
132 | } |
||
133 | if (isset($response->ReturnsFlexibleAccess)) { |
||
134 | $this->ReturnsFlexibleAccess = $response->ReturnsFlexibleAccess; |
||
135 | } |
||
136 | if (isset($response->UPScarbonneutral)) { |
||
137 | $this->UPScarbonneutral = $response->UPScarbonneutral; |
||
138 | } |
||
139 | if (isset($response->Product)) { |
||
140 | $this->Product = $response->Product; |
||
141 | } |
||
142 | if (isset($response->UPSReturnsExchange)) { |
||
143 | $this->UPSReturnsExchange = $response->UPSReturnsExchange; |
||
144 | } |
||
145 | if (isset($response->LiftGateOnDelivery)) { |
||
146 | $this->LiftGateOnDelivery = $response->LiftGateOnDelivery; |
||
147 | } |
||
148 | if (isset($response->LiftGateOnPickUp)) { |
||
149 | $this->LiftGateOnPickUp = $response->LiftGateOnPickUp; |
||
150 | } |
||
151 | if (isset($response->PickupPreference)) { |
||
152 | $this->PickupPreference = $response->PickupPreference; |
||
153 | } |
||
154 | if (isset($response->DeliveryPreference)) { |
||
155 | $this->DeliveryPreference = $response->DeliveryPreference; |
||
156 | } |
||
157 | if (isset($response->HoldForPickupAtUPSAccessPoint)) { |
||
158 | $this->HoldForPickupAtUPSAccessPoint = $response->HoldForPickupAtUPSAccessPoint; |
||
159 | } |
||
160 | if (isset($response->UAPAddress)) { |
||
161 | $this->UAPAddress = new Address($response->UAPAddress); |
||
162 | } |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 |