Conditions | 56 |
Paths | 0 |
Total Lines | 169 |
Code Lines | 112 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
198 | public function normalize($object, $format = null, array $context = array()) |
||
199 | { |
||
200 | $data = new \stdClass(); |
||
201 | if (null !== $object->getOrderId()) { |
||
202 | $data->{'orderId'} = $object->getOrderId(); |
||
203 | } |
||
204 | if (null !== $object->getModifiedAt()) { |
||
205 | $data->{'modifiedAt'} = $object->getModifiedAt(); |
||
206 | } |
||
207 | if (null !== $object->getBaseCurrencyCode()) { |
||
208 | $data->{'baseCurrencyCode'} = $object->getBaseCurrencyCode(); |
||
209 | } |
||
210 | if (null !== $object->getShopCountryCode()) { |
||
211 | $data->{'shopCountryCode'} = $object->getShopCountryCode(); |
||
212 | } |
||
213 | if (null !== $object->getTotalAmount()) { |
||
214 | $data->{'totalAmount'} = $object->getTotalAmount(); |
||
215 | } |
||
216 | if (null !== $object->getTotalVat()) { |
||
217 | $data->{'totalVat'} = $object->getTotalVat(); |
||
218 | } |
||
219 | if (null !== $object->getAmountToPay()) { |
||
220 | $data->{'amountToPay'} = $object->getAmountToPay(); |
||
221 | } |
||
222 | if (null !== $object->getTotalAmountInBaseCurrency()) { |
||
223 | $data->{'totalAmountInBaseCurrency'} = $object->getTotalAmountInBaseCurrency(); |
||
224 | } |
||
225 | if (null !== $object->getTotalVatInBaseCurrency()) { |
||
226 | $data->{'totalVatInBaseCurrency'} = $object->getTotalVatInBaseCurrency(); |
||
227 | } |
||
228 | if (null !== $object->getAmountToPayInBaseCurrency()) { |
||
229 | $data->{'amountToPayInBaseCurrency'} = $object->getAmountToPayInBaseCurrency(); |
||
230 | } |
||
231 | if (null !== $object->getCreatedAt()) { |
||
232 | $data->{'createdAt'} = $object->getCreatedAt(); |
||
233 | } |
||
234 | if (null !== $object->getCustomerId()) { |
||
235 | $data->{'customerId'} = $object->getCustomerId(); |
||
236 | } |
||
237 | if (null !== $object->getStatusId()) { |
||
238 | $data->{'statusId'} = $object->getStatusId(); |
||
239 | } |
||
240 | if (null !== $object->getOnOrderStatusChangeSendEmail()) { |
||
241 | $data->{'onOrderStatusChangeSendEmail'} = $object->getOnOrderStatusChangeSendEmail(); |
||
242 | } |
||
243 | if (null !== $object->getOnOrderStatusChangeProcessPayment()) { |
||
244 | $data->{'onOrderStatusChangeProcessPayment'} = $object->getOnOrderStatusChangeProcessPayment(); |
||
245 | } |
||
246 | if (null !== $object->getSendEmailsOnStatusChange()) { |
||
247 | $data->{'sendEmailsOnStatusChange'} = $object->getSendEmailsOnStatusChange(); |
||
248 | } |
||
249 | if (null !== $object->getShippingMethodId()) { |
||
250 | $data->{'shippingMethodId'} = $object->getShippingMethodId(); |
||
251 | } |
||
252 | if (null !== $object->getPaymentMethodId()) { |
||
253 | $data->{'paymentMethodId'} = $object->getPaymentMethodId(); |
||
254 | } |
||
255 | if (null !== $object->getPaymentMethodIdCode()) { |
||
256 | $data->{'paymentMethodIdCode'} = $object->getPaymentMethodIdCode(); |
||
257 | } |
||
258 | if (null !== $object->getPaymentMethodName()) { |
||
259 | $data->{'paymentMethodName'} = $object->getPaymentMethodName(); |
||
260 | } |
||
261 | if (null !== $object->getPaymentFee()) { |
||
262 | $data->{'paymentFee'} = $object->getPaymentFee(); |
||
263 | } |
||
264 | if (null !== $object->getPaymentVatRate()) { |
||
265 | $data->{'paymentVatRate'} = $object->getPaymentVatRate(); |
||
266 | } |
||
267 | if (null !== $object->getShippingMethodName()) { |
||
268 | $data->{'shippingMethodName'} = $object->getShippingMethodName(); |
||
269 | } |
||
270 | if (null !== $object->getShippingCost()) { |
||
271 | $data->{'shippingCost'} = $object->getShippingCost(); |
||
272 | } |
||
273 | if (null !== $object->getShippingVatRate()) { |
||
274 | $data->{'shippingVatRate'} = $object->getShippingVatRate(); |
||
275 | } |
||
276 | if (null !== $object->getTotalWeight()) { |
||
277 | $data->{'totalWeight'} = $object->getTotalWeight(); |
||
278 | } |
||
279 | if (null !== $object->getCustomInfo1()) { |
||
280 | $data->{'customInfo1'} = $object->getCustomInfo1(); |
||
281 | } |
||
282 | if (null !== $object->getCustomInfo2()) { |
||
283 | $data->{'customInfo2'} = $object->getCustomInfo2(); |
||
284 | } |
||
285 | if (null !== $object->getCustomInfo3()) { |
||
286 | $data->{'customInfo3'} = $object->getCustomInfo3(); |
||
287 | } |
||
288 | if (null !== $object->getCustomInfo4()) { |
||
289 | $data->{'customInfo4'} = $object->getCustomInfo4(); |
||
290 | } |
||
291 | if (null !== $object->getDiscountCode()) { |
||
292 | $data->{'discountCode'} = $object->getDiscountCode(); |
||
293 | } |
||
294 | if (null !== $object->getAmountPaid()) { |
||
295 | $data->{'amountPaid'} = $object->getAmountPaid(); |
||
296 | } |
||
297 | if (null !== $object->getAmountPaidInBaseCurrency()) { |
||
298 | $data->{'amountPaidInBaseCurrency'} = $object->getAmountPaidInBaseCurrency(); |
||
299 | } |
||
300 | if (null !== $object->getIsComplete()) { |
||
301 | $data->{'isComplete'} = $object->getIsComplete(); |
||
302 | } |
||
303 | if (null !== $object->getCurrencyCode()) { |
||
304 | $data->{'currencyCode'} = $object->getCurrencyCode(); |
||
305 | } |
||
306 | if (null !== $object->getCurrencyExchangeRate()) { |
||
307 | $data->{'currencyExchangeRate'} = $object->getCurrencyExchangeRate(); |
||
308 | } |
||
309 | if (null !== $object->getCurrencyPrecision()) { |
||
310 | $data->{'currencyPrecision'} = $object->getCurrencyPrecision(); |
||
311 | } |
||
312 | if (null !== $object->getLangCode()) { |
||
313 | $data->{'langCode'} = $object->getLangCode(); |
||
314 | } |
||
315 | if (null !== $object->getPaymentReference()) { |
||
316 | $data->{'paymentReference'} = $object->getPaymentReference(); |
||
317 | } |
||
318 | if (null !== $object->getPaymentStatus()) { |
||
319 | $data->{'paymentStatus'} = $object->getPaymentStatus(); |
||
320 | } |
||
321 | if (null !== $object->getIsRead()) { |
||
322 | $data->{'isRead'} = $object->getIsRead(); |
||
323 | } |
||
324 | if (null !== $object->getHasComments()) { |
||
325 | $data->{'hasComments'} = $object->getHasComments(); |
||
326 | } |
||
327 | if (null !== $object->getInternalComment()) { |
||
328 | $data->{'internalComment'} = $object->getInternalComment(); |
||
329 | } |
||
330 | if (null !== $object->getShippingTrackerType()) { |
||
331 | $data->{'shippingTrackerType'} = $object->getShippingTrackerType(); |
||
332 | } |
||
333 | if (null !== $object->getShippingTrackingNo()) { |
||
334 | $data->{'shippingTrackingNo'} = $object->getShippingTrackingNo(); |
||
335 | } |
||
336 | if (null !== $object->getOriginalCustomerEmail()) { |
||
337 | $data->{'originalCustomerEmail'} = $object->getOriginalCustomerEmail(); |
||
338 | } |
||
339 | if (null !== $object->getOriginalCustomerNationalIdNo()) { |
||
340 | $data->{'originalCustomerNationalIdNo'} = $object->getOriginalCustomerNationalIdNo(); |
||
341 | } |
||
342 | if (null !== $object->getOriginalCustomerVatNo()) { |
||
343 | $data->{'originalCustomerVatNo'} = $object->getOriginalCustomerVatNo(); |
||
344 | } |
||
345 | if (null !== $object->getOriginalCustomerCustomInfo1()) { |
||
346 | $data->{'originalCustomerCustomInfo1'} = $object->getOriginalCustomerCustomInfo1(); |
||
347 | } |
||
348 | if (null !== $object->getOriginalCustomerCustomInfo2()) { |
||
349 | $data->{'originalCustomerCustomInfo2'} = $object->getOriginalCustomerCustomInfo2(); |
||
350 | } |
||
351 | if (null !== $object->getItems()) { |
||
352 | $data->{'items'} = $this->normalizer->normalize($object->getItems(), 'json', $context); |
||
353 | } |
||
354 | if (null !== $object->getAddresses()) { |
||
355 | $data->{'addresses'} = $this->normalizer->normalize($object->getAddresses(), 'json', $context); |
||
356 | } |
||
357 | if (null !== $object->getExternalServices()) { |
||
358 | $data->{'externalServices'} = $this->normalizer->normalize($object->getExternalServices(), 'json', $context); |
||
359 | } |
||
360 | if (null !== $object->getCustomer()) { |
||
361 | $data->{'customer'} = $this->normalizer->normalize($object->getCustomer(), 'json', $context); |
||
362 | } |
||
363 | if (null !== $object->getStatus()) { |
||
364 | $data->{'status'} = $this->normalizer->normalize($object->getStatus(), 'json', $context); |
||
365 | } |
||
366 | return $data; |
||
367 | } |
||
368 | } |