Total Complexity | 49 |
Total Lines | 681 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like PickupRequestDetailsResponse often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PickupRequestDetailsResponse, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
17 | class PickupRequestDetailsResponse implements PaazlResultInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var errorType |
||
21 | */ |
||
22 | protected $error = null; |
||
23 | |||
24 | /** |
||
25 | * @var \DateTime |
||
26 | */ |
||
27 | protected $createDate = null; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $internalReference = null; |
||
33 | |||
34 | /** |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $externalReference = null; |
||
38 | |||
39 | /** |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $webshop = null; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $contract = null; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | */ |
||
52 | protected $pickupRequestOption = null; |
||
53 | |||
54 | /** |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $distributor = null; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $orderReference = null; |
||
63 | |||
64 | /** |
||
65 | * @var int |
||
66 | */ |
||
67 | protected $pieceCount = null; |
||
68 | |||
69 | /** |
||
70 | * @var \DateTime |
||
71 | */ |
||
72 | protected $pickupDate = null; |
||
73 | |||
74 | /** |
||
75 | * @var time |
||
76 | */ |
||
77 | protected $pickupWindowStart = null; |
||
78 | |||
79 | /** |
||
80 | * @var time |
||
81 | */ |
||
82 | protected $pickupWindowEnd = null; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | protected $pickupCompanyName = null; |
||
88 | |||
89 | /** |
||
90 | * @var string |
||
91 | */ |
||
92 | protected $pickupContactName = null; |
||
93 | |||
94 | /** |
||
95 | * @var addressType |
||
96 | */ |
||
97 | protected $pickupAddress = null; |
||
98 | |||
99 | /** |
||
100 | * @var bool |
||
101 | */ |
||
102 | protected $residentialPickup = null; |
||
103 | |||
104 | /** |
||
105 | * @var string |
||
106 | */ |
||
107 | protected $pickupPhoneNumber = null; |
||
108 | |||
109 | /** |
||
110 | * @var string |
||
111 | */ |
||
112 | protected $pickupEmailAddress = null; |
||
113 | |||
114 | /** |
||
115 | * @var addressType |
||
116 | */ |
||
117 | protected $deliveryAddress = null; |
||
118 | |||
119 | /** |
||
120 | * @var string |
||
121 | */ |
||
122 | protected $deliveryEmailAddress = null; |
||
123 | |||
124 | /** |
||
125 | * @var pickupRequestStatusType |
||
126 | */ |
||
127 | protected $status = null; |
||
128 | |||
129 | /** |
||
130 | * @var \DateTime |
||
131 | */ |
||
132 | protected $statusDate = null; |
||
133 | |||
134 | /** |
||
135 | * @var string |
||
136 | */ |
||
137 | protected $additionalInstruction = null; |
||
138 | |||
139 | /** |
||
140 | * Constructor. |
||
141 | * |
||
142 | * @var errorType |
||
143 | * @var \DateTime $createDate |
||
144 | * @var string $internalReference |
||
145 | * @var string $externalReference |
||
146 | * @var int $webshop |
||
147 | * @var string $contract |
||
148 | * @var string $pickupRequestOption |
||
149 | * @var string $distributor |
||
150 | * @var string $orderReference |
||
151 | * @var int $pieceCount |
||
152 | * @var \DateTime $pickupDate |
||
153 | * @var time $pickupWindowStart |
||
154 | * @var time $pickupWindowEnd |
||
155 | * @var string $pickupCompanyName |
||
156 | * @var string $pickupContactName |
||
157 | * @var addressType $pickupAddress |
||
158 | * @var bool $residentialPickup |
||
159 | * @var string $pickupPhoneNumber |
||
160 | * @var string $pickupEmailAddress |
||
161 | * @var addressType $deliveryAddress |
||
162 | * @var string $deliveryEmailAddress |
||
163 | * @var pickupRequestStatusType $status |
||
164 | * @var \DateTime $statusDate |
||
165 | * @var string $additionalInstruction |
||
166 | * |
||
167 | * @param mixed $error |
||
168 | * @param mixed $createDate |
||
169 | * @param mixed $internalReference |
||
170 | * @param mixed $externalReference |
||
171 | * @param mixed $webshop |
||
172 | * @param mixed $contract |
||
173 | * @param mixed $pickupRequestOption |
||
174 | * @param mixed $distributor |
||
175 | * @param mixed $orderReference |
||
176 | * @param mixed $pieceCount |
||
177 | * @param mixed $pickupDate |
||
178 | * @param mixed $pickupWindowStart |
||
179 | * @param mixed $pickupWindowEnd |
||
180 | * @param mixed $pickupCompanyName |
||
181 | * @param mixed $pickupContactName |
||
182 | * @param mixed $pickupAddress |
||
183 | * @param mixed $residentialPickup |
||
184 | * @param mixed $pickupPhoneNumber |
||
185 | * @param mixed $pickupEmailAddress |
||
186 | * @param mixed $deliveryAddress |
||
187 | * @param mixed $deliveryEmailAddress |
||
188 | * @param mixed $status |
||
189 | * @param mixed $statusDate |
||
190 | * @param mixed $additionalInstruction |
||
191 | */ |
||
192 | public function __construct($error, $createDate, $internalReference, $externalReference, $webshop, $contract, $pickupRequestOption, $distributor, $orderReference, $pieceCount, $pickupDate, $pickupWindowStart, $pickupWindowEnd, $pickupCompanyName, $pickupContactName, $pickupAddress, $residentialPickup, $pickupPhoneNumber, $pickupEmailAddress, $deliveryAddress, $deliveryEmailAddress, $status, $statusDate, $additionalInstruction) |
||
193 | { |
||
194 | $this->error = $error; |
||
|
|||
195 | $this->createDate = $createDate; |
||
196 | $this->internalReference = $internalReference; |
||
197 | $this->externalReference = $externalReference; |
||
198 | $this->webshop = $webshop; |
||
199 | $this->contract = $contract; |
||
200 | $this->pickupRequestOption = $pickupRequestOption; |
||
201 | $this->distributor = $distributor; |
||
202 | $this->orderReference = $orderReference; |
||
203 | $this->pieceCount = $pieceCount; |
||
204 | $this->pickupDate = $pickupDate; |
||
205 | $this->pickupWindowStart = $pickupWindowStart; |
||
206 | $this->pickupWindowEnd = $pickupWindowEnd; |
||
207 | $this->pickupCompanyName = $pickupCompanyName; |
||
208 | $this->pickupContactName = $pickupContactName; |
||
209 | $this->pickupAddress = $pickupAddress; |
||
210 | $this->residentialPickup = $residentialPickup; |
||
211 | $this->pickupPhoneNumber = $pickupPhoneNumber; |
||
212 | $this->pickupEmailAddress = $pickupEmailAddress; |
||
213 | $this->deliveryAddress = $deliveryAddress; |
||
214 | $this->deliveryEmailAddress = $deliveryEmailAddress; |
||
215 | $this->status = $status; |
||
216 | $this->statusDate = $statusDate; |
||
217 | $this->additionalInstruction = $additionalInstruction; |
||
218 | } |
||
219 | |||
220 | /** |
||
221 | * @return errorType |
||
222 | */ |
||
223 | public function getError() |
||
224 | { |
||
225 | return $this->error; |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * @param errorType $error |
||
230 | * |
||
231 | * @return $this |
||
232 | */ |
||
233 | public function setError($error) |
||
234 | { |
||
235 | $this->error = $error; |
||
236 | |||
237 | return $this; |
||
238 | } |
||
239 | |||
240 | /** |
||
241 | * @return \DateTime |
||
242 | */ |
||
243 | public function getCreateDate() |
||
244 | { |
||
245 | return $this->createDate; |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * @param \DateTime $createDate |
||
250 | * |
||
251 | * @return $this |
||
252 | */ |
||
253 | public function setCreateDate($createDate) |
||
254 | { |
||
255 | $this->createDate = $createDate; |
||
256 | |||
257 | return $this; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * @return string |
||
262 | */ |
||
263 | public function getInternalReference() |
||
264 | { |
||
265 | return $this->internalReference; |
||
266 | } |
||
267 | |||
268 | /** |
||
269 | * @param string $internalReference |
||
270 | * |
||
271 | * @return $this |
||
272 | */ |
||
273 | public function setInternalReference($internalReference) |
||
274 | { |
||
275 | $this->internalReference = $internalReference; |
||
276 | |||
277 | return $this; |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * @return string |
||
282 | */ |
||
283 | public function getExternalReference() |
||
284 | { |
||
285 | return $this->externalReference; |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * @param string $externalReference |
||
290 | * |
||
291 | * @return $this |
||
292 | */ |
||
293 | public function setExternalReference($externalReference) |
||
294 | { |
||
295 | $this->externalReference = $externalReference; |
||
296 | |||
297 | return $this; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * @return int |
||
302 | */ |
||
303 | public function getWebshop() |
||
304 | { |
||
305 | return $this->webshop; |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * @param int $webshop |
||
310 | * |
||
311 | * @return $this |
||
312 | */ |
||
313 | public function setWebshop($webshop) |
||
314 | { |
||
315 | $this->webshop = $webshop; |
||
316 | |||
317 | return $this; |
||
318 | } |
||
319 | |||
320 | /** |
||
321 | * @return string |
||
322 | */ |
||
323 | public function getContract() |
||
324 | { |
||
325 | return $this->contract; |
||
326 | } |
||
327 | |||
328 | /** |
||
329 | * @param string $contract |
||
330 | * |
||
331 | * @return $this |
||
332 | */ |
||
333 | public function setContract($contract) |
||
334 | { |
||
335 | $this->contract = $contract; |
||
336 | |||
337 | return $this; |
||
338 | } |
||
339 | |||
340 | /** |
||
341 | * @return string |
||
342 | */ |
||
343 | public function getPickupRequestOption() |
||
344 | { |
||
345 | return $this->pickupRequestOption; |
||
346 | } |
||
347 | |||
348 | /** |
||
349 | * @param string $pickupRequestOption |
||
350 | * |
||
351 | * @return $this |
||
352 | */ |
||
353 | public function setPickupRequestOption($pickupRequestOption) |
||
354 | { |
||
355 | $this->pickupRequestOption = $pickupRequestOption; |
||
356 | |||
357 | return $this; |
||
358 | } |
||
359 | |||
360 | /** |
||
361 | * @return string |
||
362 | */ |
||
363 | public function getDistributor() |
||
364 | { |
||
365 | return $this->distributor; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * @param string $distributor |
||
370 | * |
||
371 | * @return $this |
||
372 | */ |
||
373 | public function setDistributor($distributor) |
||
374 | { |
||
375 | $this->distributor = $distributor; |
||
376 | |||
377 | return $this; |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * @return string |
||
382 | */ |
||
383 | public function getOrderReference() |
||
384 | { |
||
385 | return $this->orderReference; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * @param string $orderReference |
||
390 | * |
||
391 | * @return $this |
||
392 | */ |
||
393 | public function setOrderReference($orderReference) |
||
394 | { |
||
395 | $this->orderReference = $orderReference; |
||
396 | |||
397 | return $this; |
||
398 | } |
||
399 | |||
400 | /** |
||
401 | * @return int |
||
402 | */ |
||
403 | public function getPieceCount() |
||
404 | { |
||
405 | return $this->pieceCount; |
||
406 | } |
||
407 | |||
408 | /** |
||
409 | * @param int $pieceCount |
||
410 | * |
||
411 | * @return $this |
||
412 | */ |
||
413 | public function setPieceCount($pieceCount) |
||
414 | { |
||
415 | $this->pieceCount = $pieceCount; |
||
416 | |||
417 | return $this; |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * @return \DateTime |
||
422 | */ |
||
423 | public function getPickupDate() |
||
424 | { |
||
425 | return $this->pickupDate; |
||
426 | } |
||
427 | |||
428 | /** |
||
429 | * @param \DateTime $pickupDate |
||
430 | * |
||
431 | * @return $this |
||
432 | */ |
||
433 | public function setPickupDate($pickupDate) |
||
434 | { |
||
435 | $this->pickupDate = $pickupDate; |
||
436 | |||
437 | return $this; |
||
438 | } |
||
439 | |||
440 | /** |
||
441 | * @return time |
||
442 | */ |
||
443 | public function getPickupWindowStart() |
||
444 | { |
||
445 | return $this->pickupWindowStart; |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * @param time $pickupWindowStart |
||
450 | * |
||
451 | * @return $this |
||
452 | */ |
||
453 | public function setPickupWindowStart($pickupWindowStart) |
||
454 | { |
||
455 | $this->pickupWindowStart = $pickupWindowStart; |
||
456 | |||
457 | return $this; |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * @return time |
||
462 | */ |
||
463 | public function getPickupWindowEnd() |
||
464 | { |
||
465 | return $this->pickupWindowEnd; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * @param time $pickupWindowEnd |
||
470 | * |
||
471 | * @return $this |
||
472 | */ |
||
473 | public function setPickupWindowEnd($pickupWindowEnd) |
||
474 | { |
||
475 | $this->pickupWindowEnd = $pickupWindowEnd; |
||
476 | |||
477 | return $this; |
||
478 | } |
||
479 | |||
480 | /** |
||
481 | * @return string |
||
482 | */ |
||
483 | public function getPickupCompanyName() |
||
484 | { |
||
485 | return $this->pickupCompanyName; |
||
486 | } |
||
487 | |||
488 | /** |
||
489 | * @param string $pickupCompanyName |
||
490 | * |
||
491 | * @return $this |
||
492 | */ |
||
493 | public function setPickupCompanyName($pickupCompanyName) |
||
498 | } |
||
499 | |||
500 | /** |
||
501 | * @return string |
||
502 | */ |
||
503 | public function getPickupContactName() |
||
504 | { |
||
505 | return $this->pickupContactName; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * @param string $pickupContactName |
||
510 | * |
||
511 | * @return $this |
||
512 | */ |
||
513 | public function setPickupContactName($pickupContactName) |
||
514 | { |
||
515 | $this->pickupContactName = $pickupContactName; |
||
516 | |||
517 | return $this; |
||
518 | } |
||
519 | |||
520 | /** |
||
521 | * @return addressType |
||
522 | */ |
||
523 | public function getPickupAddress() |
||
524 | { |
||
525 | return $this->pickupAddress; |
||
526 | } |
||
527 | |||
528 | /** |
||
529 | * @param addressType $pickupAddress |
||
530 | * |
||
531 | * @return $this |
||
532 | */ |
||
533 | public function setPickupAddress($pickupAddress) |
||
534 | { |
||
535 | $this->pickupAddress = $pickupAddress; |
||
536 | |||
537 | return $this; |
||
538 | } |
||
539 | |||
540 | /** |
||
541 | * @return bool |
||
542 | */ |
||
543 | public function getResidentialPickup() |
||
544 | { |
||
545 | return $this->residentialPickup; |
||
546 | } |
||
547 | |||
548 | /** |
||
549 | * @param bool $residentialPickup |
||
550 | * |
||
551 | * @return $this |
||
552 | */ |
||
553 | public function setResidentialPickup($residentialPickup) |
||
554 | { |
||
555 | $this->residentialPickup = $residentialPickup; |
||
556 | |||
557 | return $this; |
||
558 | } |
||
559 | |||
560 | /** |
||
561 | * @return string |
||
562 | */ |
||
563 | public function getPickupPhoneNumber() |
||
564 | { |
||
565 | return $this->pickupPhoneNumber; |
||
566 | } |
||
567 | |||
568 | /** |
||
569 | * @param string $pickupPhoneNumber |
||
570 | * |
||
571 | * @return $this |
||
572 | */ |
||
573 | public function setPickupPhoneNumber($pickupPhoneNumber) |
||
574 | { |
||
575 | $this->pickupPhoneNumber = $pickupPhoneNumber; |
||
576 | |||
577 | return $this; |
||
578 | } |
||
579 | |||
580 | /** |
||
581 | * @return string |
||
582 | */ |
||
583 | public function getPickupEmailAddress() |
||
586 | } |
||
587 | |||
588 | /** |
||
589 | * @param string $pickupEmailAddress |
||
590 | * |
||
591 | * @return $this |
||
592 | */ |
||
593 | public function setPickupEmailAddress($pickupEmailAddress) |
||
594 | { |
||
595 | $this->pickupEmailAddress = $pickupEmailAddress; |
||
596 | |||
597 | return $this; |
||
598 | } |
||
599 | |||
600 | /** |
||
601 | * @return addressType |
||
602 | */ |
||
603 | public function getDeliveryAddress() |
||
604 | { |
||
605 | return $this->deliveryAddress; |
||
606 | } |
||
607 | |||
608 | /** |
||
609 | * @param addressType $deliveryAddress |
||
610 | * |
||
611 | * @return $this |
||
612 | */ |
||
613 | public function setDeliveryAddress($deliveryAddress) |
||
614 | { |
||
615 | $this->deliveryAddress = $deliveryAddress; |
||
616 | |||
617 | return $this; |
||
618 | } |
||
619 | |||
620 | /** |
||
621 | * @return string |
||
622 | */ |
||
623 | public function getDeliveryEmailAddress() |
||
624 | { |
||
625 | return $this->deliveryEmailAddress; |
||
626 | } |
||
627 | |||
628 | /** |
||
629 | * @param string $deliveryEmailAddress |
||
630 | * |
||
631 | * @return $this |
||
632 | */ |
||
633 | public function setDeliveryEmailAddress($deliveryEmailAddress) |
||
634 | { |
||
635 | $this->deliveryEmailAddress = $deliveryEmailAddress; |
||
636 | |||
637 | return $this; |
||
638 | } |
||
639 | |||
640 | /** |
||
641 | * @return pickupRequestStatusType |
||
642 | */ |
||
643 | public function getStatus() |
||
644 | { |
||
645 | return $this->status; |
||
646 | } |
||
647 | |||
648 | /** |
||
649 | * @param pickupRequestStatusType $status |
||
650 | * |
||
651 | * @return $this |
||
652 | */ |
||
653 | public function setStatus($status) |
||
654 | { |
||
655 | $this->status = $status; |
||
656 | |||
657 | return $this; |
||
658 | } |
||
659 | |||
660 | /** |
||
661 | * @return \DateTime |
||
662 | */ |
||
663 | public function getStatusDate() |
||
664 | { |
||
665 | return $this->statusDate; |
||
666 | } |
||
667 | |||
668 | /** |
||
669 | * @param \DateTime $statusDate |
||
670 | * |
||
671 | * @return $this |
||
672 | */ |
||
673 | public function setStatusDate($statusDate) |
||
674 | { |
||
675 | $this->statusDate = $statusDate; |
||
676 | |||
677 | return $this; |
||
678 | } |
||
679 | |||
680 | /** |
||
681 | * @return string |
||
682 | */ |
||
683 | public function getAdditionalInstruction() |
||
684 | { |
||
685 | return $this->additionalInstruction; |
||
686 | } |
||
687 | |||
688 | /** |
||
689 | * @param string $additionalInstruction |
||
690 | * |
||
691 | * @return $this |
||
692 | */ |
||
693 | public function setAdditionalInstruction($additionalInstruction) |
||
698 | } |
||
699 | } |
||
700 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.