Complex classes like SpecialOffers 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 SpecialOffers, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class SpecialOffers |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $ID_RateSpecial |
||
10 | */ |
||
11 | protected $ID_RateSpecial = null; |
||
12 | |||
13 | /** |
||
14 | * @var string $RateSpecialName |
||
15 | */ |
||
16 | protected $RateSpecialName = null; |
||
17 | |||
18 | /** |
||
19 | * @var \DateTime $StartBooking |
||
20 | */ |
||
21 | protected $StartBooking = null; |
||
22 | |||
23 | /** |
||
24 | * @var \DateTime $EndBooking |
||
25 | */ |
||
26 | protected $EndBooking = null; |
||
27 | |||
28 | /** |
||
29 | * @var \DateTime $StartArrival |
||
30 | */ |
||
31 | protected $StartArrival = null; |
||
32 | |||
33 | /** |
||
34 | * @var \DateTime $EndArrival |
||
35 | */ |
||
36 | protected $EndArrival = null; |
||
37 | |||
38 | /** |
||
39 | * @var int $SpecialType |
||
40 | */ |
||
41 | protected $SpecialType = null; |
||
42 | |||
43 | /** |
||
44 | * @var int $NbrDaysAhead |
||
45 | */ |
||
46 | protected $NbrDaysAhead = null; |
||
47 | |||
48 | /** |
||
49 | * @var int $MinOfNights |
||
50 | */ |
||
51 | protected $MinOfNights = null; |
||
52 | |||
53 | /** |
||
54 | * @var int $RecurrenceType |
||
55 | */ |
||
56 | protected $RecurrenceType = null; |
||
57 | |||
58 | /** |
||
59 | * @var int $ValidNbrDayIntoStay |
||
60 | */ |
||
61 | protected $ValidNbrDayIntoStay = null; |
||
62 | |||
63 | /** |
||
64 | * @var int $ValidNbrFromLast |
||
65 | */ |
||
66 | protected $ValidNbrFromLast = null; |
||
67 | |||
68 | /** |
||
69 | * @var int $MinGuests |
||
70 | */ |
||
71 | protected $MinGuests = null; |
||
72 | |||
73 | /** |
||
74 | * @var boolean $IsCummulatif |
||
75 | */ |
||
76 | protected $IsCummulatif = null; |
||
77 | |||
78 | /** |
||
79 | * @var boolean $IsIndividual |
||
80 | */ |
||
81 | protected $IsIndividual = null; |
||
82 | |||
83 | /** |
||
84 | * @var int $ID_TrnCode |
||
85 | */ |
||
86 | protected $ID_TrnCode = null; |
||
87 | |||
88 | /** |
||
89 | * @var int $SpecificChargeType |
||
90 | */ |
||
91 | protected $SpecificChargeType = null; |
||
92 | |||
93 | /** |
||
94 | * @var int $ReductionType |
||
95 | */ |
||
96 | protected $ReductionType = null; |
||
97 | |||
98 | /** |
||
99 | * @var int $ReductionValue |
||
100 | */ |
||
101 | protected $ReductionValue = null; |
||
102 | |||
103 | /** |
||
104 | * @var boolean $IsSpecialGuaranteed |
||
105 | */ |
||
106 | protected $IsSpecialGuaranteed = null; |
||
107 | |||
108 | /** |
||
109 | * @var boolean $IsAppliedLocally |
||
110 | */ |
||
111 | protected $IsAppliedLocally = null; |
||
112 | |||
113 | /** |
||
114 | * @var boolean $IsAppliedCentrally |
||
115 | */ |
||
116 | protected $IsAppliedCentrally = null; |
||
117 | |||
118 | /** |
||
119 | * @var boolean $IsApplicable |
||
120 | */ |
||
121 | protected $IsApplicable = null; |
||
122 | |||
123 | /** |
||
124 | * @var \DateTime $StartStay |
||
125 | */ |
||
126 | protected $StartStay = null; |
||
127 | |||
128 | /** |
||
129 | * @var \DateTime $EndStay |
||
130 | */ |
||
131 | protected $EndStay = null; |
||
132 | |||
133 | /** |
||
134 | * @var boolean $IsForPromoOnly |
||
135 | */ |
||
136 | protected $IsForPromoOnly = null; |
||
137 | |||
138 | /** |
||
139 | * @var boolean $IsToCreditFixTax |
||
140 | */ |
||
141 | protected $IsToCreditFixTax = null; |
||
142 | |||
143 | /** |
||
144 | * @var boolean $IsRoomChargeReversal |
||
145 | */ |
||
146 | protected $IsRoomChargeReversal = null; |
||
147 | |||
148 | /** |
||
149 | * @var boolean $IsElementSTDReversal |
||
150 | */ |
||
151 | protected $IsElementSTDReversal = null; |
||
152 | |||
153 | /** |
||
154 | * @var boolean $IsLocationReversal |
||
155 | */ |
||
156 | protected $IsLocationReversal = null; |
||
157 | |||
158 | /** |
||
159 | * @var boolean $IsAttributReversal |
||
160 | */ |
||
161 | protected $IsAttributReversal = null; |
||
162 | |||
163 | /** |
||
164 | * @var boolean $IsSvcRateReversal |
||
165 | */ |
||
166 | protected $IsSvcRateReversal = null; |
||
167 | |||
168 | /** |
||
169 | * @var boolean $IsSvcHskReversal |
||
170 | */ |
||
171 | protected $IsSvcHskReversal = null; |
||
172 | |||
173 | /** |
||
174 | * @var boolean $IsSvcRoomReversal |
||
175 | */ |
||
176 | protected $IsSvcRoomReversal = null; |
||
177 | |||
178 | /** |
||
179 | * @var int $ID_RateCodeChanged |
||
180 | */ |
||
181 | protected $ID_RateCodeChanged = null; |
||
182 | |||
183 | /** |
||
184 | * @var ArrayOfRateCode $LinkedRateCodes |
||
185 | */ |
||
186 | protected $LinkedRateCodes = null; |
||
187 | |||
188 | /** |
||
189 | * @var ArrayOfRateSpecialValidPeriod $RateSpecialValidPeriods |
||
190 | */ |
||
191 | protected $RateSpecialValidPeriods = null; |
||
192 | |||
193 | /** |
||
194 | * @param int $ID_RateSpecial |
||
195 | * @param \DateTime $StartBooking |
||
196 | * @param \DateTime $EndBooking |
||
197 | * @param \DateTime $StartArrival |
||
198 | * @param \DateTime $EndArrival |
||
199 | * @param int $SpecialType |
||
200 | * @param int $NbrDaysAhead |
||
201 | * @param int $MinOfNights |
||
202 | * @param int $RecurrenceType |
||
203 | * @param int $ValidNbrDayIntoStay |
||
204 | * @param int $ValidNbrFromLast |
||
205 | * @param int $MinGuests |
||
206 | * @param boolean $IsCummulatif |
||
207 | * @param boolean $IsIndividual |
||
208 | * @param int $ID_TrnCode |
||
209 | * @param int $SpecificChargeType |
||
210 | * @param int $ReductionType |
||
211 | * @param int $ReductionValue |
||
212 | * @param boolean $IsSpecialGuaranteed |
||
213 | * @param boolean $IsAppliedLocally |
||
214 | * @param boolean $IsAppliedCentrally |
||
215 | * @param boolean $IsApplicable |
||
216 | * @param \DateTime $StartStay |
||
217 | * @param \DateTime $EndStay |
||
218 | * @param boolean $IsForPromoOnly |
||
219 | * @param boolean $IsToCreditFixTax |
||
220 | * @param boolean $IsRoomChargeReversal |
||
221 | * @param boolean $IsElementSTDReversal |
||
222 | * @param boolean $IsLocationReversal |
||
223 | * @param boolean $IsAttributReversal |
||
224 | * @param boolean $IsSvcRateReversal |
||
225 | * @param boolean $IsSvcHskReversal |
||
226 | * @param boolean $IsSvcRoomReversal |
||
227 | * @param int $ID_RateCodeChanged |
||
228 | */ |
||
229 | public function __construct($ID_RateSpecial, \DateTime $StartBooking, \DateTime $EndBooking, \DateTime $StartArrival, \DateTime $EndArrival, $SpecialType, $NbrDaysAhead, $MinOfNights, $RecurrenceType, $ValidNbrDayIntoStay, $ValidNbrFromLast, $MinGuests, $IsCummulatif, $IsIndividual, $ID_TrnCode, $SpecificChargeType, $ReductionType, $ReductionValue, $IsSpecialGuaranteed, $IsAppliedLocally, $IsAppliedCentrally, $IsApplicable, \DateTime $StartStay, \DateTime $EndStay, $IsForPromoOnly, $IsToCreditFixTax, $IsRoomChargeReversal, $IsElementSTDReversal, $IsLocationReversal, $IsAttributReversal, $IsSvcRateReversal, $IsSvcHskReversal, $IsSvcRoomReversal, $ID_RateCodeChanged) |
||
266 | |||
267 | /** |
||
268 | * @return int |
||
269 | */ |
||
270 | public function getID_RateSpecial() |
||
274 | |||
275 | /** |
||
276 | * @param int $ID_RateSpecial |
||
277 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
278 | */ |
||
279 | public function setID_RateSpecial($ID_RateSpecial) |
||
284 | |||
285 | /** |
||
286 | * @return string |
||
287 | */ |
||
288 | public function getRateSpecialName() |
||
292 | |||
293 | /** |
||
294 | * @param string $RateSpecialName |
||
295 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
296 | */ |
||
297 | public function setRateSpecialName($RateSpecialName) |
||
302 | |||
303 | /** |
||
304 | * @return \DateTime |
||
305 | */ |
||
306 | public function getStartBooking() |
||
318 | |||
319 | /** |
||
320 | * @param \DateTime $StartBooking |
||
321 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
322 | */ |
||
323 | public function setStartBooking(\DateTime $StartBooking) |
||
328 | |||
329 | /** |
||
330 | * @return \DateTime |
||
331 | */ |
||
332 | public function getEndBooking() |
||
344 | |||
345 | /** |
||
346 | * @param \DateTime $EndBooking |
||
347 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
348 | */ |
||
349 | public function setEndBooking(\DateTime $EndBooking) |
||
354 | |||
355 | /** |
||
356 | * @return \DateTime |
||
357 | */ |
||
358 | public function getStartArrival() |
||
370 | |||
371 | /** |
||
372 | * @param \DateTime $StartArrival |
||
373 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
374 | */ |
||
375 | public function setStartArrival(\DateTime $StartArrival) |
||
380 | |||
381 | /** |
||
382 | * @return \DateTime |
||
383 | */ |
||
384 | public function getEndArrival() |
||
396 | |||
397 | /** |
||
398 | * @param \DateTime $EndArrival |
||
399 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
400 | */ |
||
401 | public function setEndArrival(\DateTime $EndArrival) |
||
406 | |||
407 | /** |
||
408 | * @return int |
||
409 | */ |
||
410 | public function getSpecialType() |
||
414 | |||
415 | /** |
||
416 | * @param int $SpecialType |
||
417 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
418 | */ |
||
419 | public function setSpecialType($SpecialType) |
||
424 | |||
425 | /** |
||
426 | * @return int |
||
427 | */ |
||
428 | public function getNbrDaysAhead() |
||
432 | |||
433 | /** |
||
434 | * @param int $NbrDaysAhead |
||
435 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
436 | */ |
||
437 | public function setNbrDaysAhead($NbrDaysAhead) |
||
442 | |||
443 | /** |
||
444 | * @return int |
||
445 | */ |
||
446 | public function getMinOfNights() |
||
450 | |||
451 | /** |
||
452 | * @param int $MinOfNights |
||
453 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
454 | */ |
||
455 | public function setMinOfNights($MinOfNights) |
||
460 | |||
461 | /** |
||
462 | * @return int |
||
463 | */ |
||
464 | public function getRecurrenceType() |
||
468 | |||
469 | /** |
||
470 | * @param int $RecurrenceType |
||
471 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
472 | */ |
||
473 | public function setRecurrenceType($RecurrenceType) |
||
478 | |||
479 | /** |
||
480 | * @return int |
||
481 | */ |
||
482 | public function getValidNbrDayIntoStay() |
||
486 | |||
487 | /** |
||
488 | * @param int $ValidNbrDayIntoStay |
||
489 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
490 | */ |
||
491 | public function setValidNbrDayIntoStay($ValidNbrDayIntoStay) |
||
496 | |||
497 | /** |
||
498 | * @return int |
||
499 | */ |
||
500 | public function getValidNbrFromLast() |
||
504 | |||
505 | /** |
||
506 | * @param int $ValidNbrFromLast |
||
507 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
508 | */ |
||
509 | public function setValidNbrFromLast($ValidNbrFromLast) |
||
514 | |||
515 | /** |
||
516 | * @return int |
||
517 | */ |
||
518 | public function getMinGuests() |
||
522 | |||
523 | /** |
||
524 | * @param int $MinGuests |
||
525 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
526 | */ |
||
527 | public function setMinGuests($MinGuests) |
||
532 | |||
533 | /** |
||
534 | * @return boolean |
||
535 | */ |
||
536 | public function getIsCummulatif() |
||
540 | |||
541 | /** |
||
542 | * @param boolean $IsCummulatif |
||
543 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
544 | */ |
||
545 | public function setIsCummulatif($IsCummulatif) |
||
550 | |||
551 | /** |
||
552 | * @return boolean |
||
553 | */ |
||
554 | public function getIsIndividual() |
||
558 | |||
559 | /** |
||
560 | * @param boolean $IsIndividual |
||
561 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
562 | */ |
||
563 | public function setIsIndividual($IsIndividual) |
||
568 | |||
569 | /** |
||
570 | * @return int |
||
571 | */ |
||
572 | public function getID_TrnCode() |
||
576 | |||
577 | /** |
||
578 | * @param int $ID_TrnCode |
||
579 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
580 | */ |
||
581 | public function setID_TrnCode($ID_TrnCode) |
||
586 | |||
587 | /** |
||
588 | * @return int |
||
589 | */ |
||
590 | public function getSpecificChargeType() |
||
594 | |||
595 | /** |
||
596 | * @param int $SpecificChargeType |
||
597 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
598 | */ |
||
599 | public function setSpecificChargeType($SpecificChargeType) |
||
604 | |||
605 | /** |
||
606 | * @return int |
||
607 | */ |
||
608 | public function getReductionType() |
||
612 | |||
613 | /** |
||
614 | * @param int $ReductionType |
||
615 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
616 | */ |
||
617 | public function setReductionType($ReductionType) |
||
622 | |||
623 | /** |
||
624 | * @return int |
||
625 | */ |
||
626 | public function getReductionValue() |
||
630 | |||
631 | /** |
||
632 | * @param int $ReductionValue |
||
633 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
634 | */ |
||
635 | public function setReductionValue($ReductionValue) |
||
640 | |||
641 | /** |
||
642 | * @return boolean |
||
643 | */ |
||
644 | public function getIsSpecialGuaranteed() |
||
648 | |||
649 | /** |
||
650 | * @param boolean $IsSpecialGuaranteed |
||
651 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
652 | */ |
||
653 | public function setIsSpecialGuaranteed($IsSpecialGuaranteed) |
||
658 | |||
659 | /** |
||
660 | * @return boolean |
||
661 | */ |
||
662 | public function getIsAppliedLocally() |
||
666 | |||
667 | /** |
||
668 | * @param boolean $IsAppliedLocally |
||
669 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
670 | */ |
||
671 | public function setIsAppliedLocally($IsAppliedLocally) |
||
676 | |||
677 | /** |
||
678 | * @return boolean |
||
679 | */ |
||
680 | public function getIsAppliedCentrally() |
||
684 | |||
685 | /** |
||
686 | * @param boolean $IsAppliedCentrally |
||
687 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
688 | */ |
||
689 | public function setIsAppliedCentrally($IsAppliedCentrally) |
||
694 | |||
695 | /** |
||
696 | * @return boolean |
||
697 | */ |
||
698 | public function getIsApplicable() |
||
702 | |||
703 | /** |
||
704 | * @param boolean $IsApplicable |
||
705 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
706 | */ |
||
707 | public function setIsApplicable($IsApplicable) |
||
712 | |||
713 | /** |
||
714 | * @return \DateTime |
||
715 | */ |
||
716 | public function getStartStay() |
||
728 | |||
729 | /** |
||
730 | * @param \DateTime $StartStay |
||
731 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
732 | */ |
||
733 | public function setStartStay(\DateTime $StartStay) |
||
738 | |||
739 | /** |
||
740 | * @return \DateTime |
||
741 | */ |
||
742 | public function getEndStay() |
||
754 | |||
755 | /** |
||
756 | * @param \DateTime $EndStay |
||
757 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
758 | */ |
||
759 | public function setEndStay(\DateTime $EndStay) |
||
764 | |||
765 | /** |
||
766 | * @return boolean |
||
767 | */ |
||
768 | public function getIsForPromoOnly() |
||
772 | |||
773 | /** |
||
774 | * @param boolean $IsForPromoOnly |
||
775 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
776 | */ |
||
777 | public function setIsForPromoOnly($IsForPromoOnly) |
||
782 | |||
783 | /** |
||
784 | * @return boolean |
||
785 | */ |
||
786 | public function getIsToCreditFixTax() |
||
790 | |||
791 | /** |
||
792 | * @param boolean $IsToCreditFixTax |
||
793 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
794 | */ |
||
795 | public function setIsToCreditFixTax($IsToCreditFixTax) |
||
800 | |||
801 | /** |
||
802 | * @return boolean |
||
803 | */ |
||
804 | public function getIsRoomChargeReversal() |
||
808 | |||
809 | /** |
||
810 | * @param boolean $IsRoomChargeReversal |
||
811 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
812 | */ |
||
813 | public function setIsRoomChargeReversal($IsRoomChargeReversal) |
||
818 | |||
819 | /** |
||
820 | * @return boolean |
||
821 | */ |
||
822 | public function getIsElementSTDReversal() |
||
826 | |||
827 | /** |
||
828 | * @param boolean $IsElementSTDReversal |
||
829 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
830 | */ |
||
831 | public function setIsElementSTDReversal($IsElementSTDReversal) |
||
836 | |||
837 | /** |
||
838 | * @return boolean |
||
839 | */ |
||
840 | public function getIsLocationReversal() |
||
844 | |||
845 | /** |
||
846 | * @param boolean $IsLocationReversal |
||
847 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
848 | */ |
||
849 | public function setIsLocationReversal($IsLocationReversal) |
||
854 | |||
855 | /** |
||
856 | * @return boolean |
||
857 | */ |
||
858 | public function getIsAttributReversal() |
||
862 | |||
863 | /** |
||
864 | * @param boolean $IsAttributReversal |
||
865 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
866 | */ |
||
867 | public function setIsAttributReversal($IsAttributReversal) |
||
872 | |||
873 | /** |
||
874 | * @return boolean |
||
875 | */ |
||
876 | public function getIsSvcRateReversal() |
||
880 | |||
881 | /** |
||
882 | * @param boolean $IsSvcRateReversal |
||
883 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
884 | */ |
||
885 | public function setIsSvcRateReversal($IsSvcRateReversal) |
||
890 | |||
891 | /** |
||
892 | * @return boolean |
||
893 | */ |
||
894 | public function getIsSvcHskReversal() |
||
898 | |||
899 | /** |
||
900 | * @param boolean $IsSvcHskReversal |
||
901 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
902 | */ |
||
903 | public function setIsSvcHskReversal($IsSvcHskReversal) |
||
908 | |||
909 | /** |
||
910 | * @return boolean |
||
911 | */ |
||
912 | public function getIsSvcRoomReversal() |
||
916 | |||
917 | /** |
||
918 | * @param boolean $IsSvcRoomReversal |
||
919 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
920 | */ |
||
921 | public function setIsSvcRoomReversal($IsSvcRoomReversal) |
||
926 | |||
927 | /** |
||
928 | * @return int |
||
929 | */ |
||
930 | public function getID_RateCodeChanged() |
||
934 | |||
935 | /** |
||
936 | * @param int $ID_RateCodeChanged |
||
937 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
938 | */ |
||
939 | public function setID_RateCodeChanged($ID_RateCodeChanged) |
||
944 | |||
945 | /** |
||
946 | * @return ArrayOfRateCode |
||
947 | */ |
||
948 | public function getLinkedRateCodes() |
||
952 | |||
953 | /** |
||
954 | * @param ArrayOfRateCode $LinkedRateCodes |
||
955 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
956 | */ |
||
957 | public function setLinkedRateCodes($LinkedRateCodes) |
||
962 | |||
963 | /** |
||
964 | * @return ArrayOfRateSpecialValidPeriod |
||
965 | */ |
||
966 | public function getRateSpecialValidPeriods() |
||
970 | |||
971 | /** |
||
972 | * @param ArrayOfRateSpecialValidPeriod $RateSpecialValidPeriods |
||
973 | * @return \Gueststream\PMS\IQWare\API\SpecialOffers |
||
974 | */ |
||
975 | public function setRateSpecialValidPeriods($RateSpecialValidPeriods) |
||
980 | } |
||
981 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..