Complex classes like BlockAvailabilityQuery 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 BlockAvailabilityQuery, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
8 | class BlockAvailabilityQuery extends Query |
||
9 | { |
||
10 | /** |
||
11 | * @var string Show the room size and bedding info in the result |
||
12 | */ |
||
13 | public const EXTRAS_ADDITIONAL_ROOM_INFO = 'additional_room_info'; |
||
14 | |||
15 | /** |
||
16 | * @var string Show the addon type in the addons records, if returned |
||
17 | */ |
||
18 | public const EXTRAS_ADDON_TYPE = 'addon_type'; |
||
19 | |||
20 | /** |
||
21 | * @var string Show addon information for blocks |
||
22 | */ |
||
23 | public const EXTRAS_ADDONS = 'addons'; |
||
24 | |||
25 | /** |
||
26 | * @var string Show an indication per hotel if the user needs to enter his address in order to book an hotel |
||
27 | */ |
||
28 | public const EXTRAS_ADDRESS_REQUIRED = 'address_required'; |
||
29 | |||
30 | /** |
||
31 | * Show all extra charges, even if not computable. |
||
32 | * If not computable, do not show the total amount, but include all the other details |
||
33 | * @var string |
||
34 | */ |
||
35 | public const EXTRAS_ALL_EXTRA_CHARGES = 'all_extra_charges'; |
||
36 | |||
37 | /** |
||
38 | * @var string Show total incremental price with split pricing, when split pricing is activated |
||
39 | */ |
||
40 | public const EXTRAS_ALL_PRICES = 'all_prices'; |
||
41 | |||
42 | /** |
||
43 | * @var string Show the average commission % for every hotel for the specified period |
||
44 | */ |
||
45 | public const EXTRAS_BOOKING_COMMISION = 'booking_commission'; |
||
46 | |||
47 | /** |
||
48 | * @var string Show detailed cancellation timeline for each block, including fees and datetimes |
||
49 | */ |
||
50 | public const EXTRAS_CANCELLATION_INFO = 'cancellation_info'; |
||
51 | |||
52 | /** |
||
53 | * @var string Show cc_required field for hotels |
||
54 | */ |
||
55 | public const EXTRAS_CC_REQUIRED = 'cc_required'; |
||
56 | |||
57 | /** |
||
58 | * @var string Show flash deals to partners |
||
59 | */ |
||
60 | public const EXTRAS_DEAL_FLASH = 'deal_flash'; |
||
61 | |||
62 | /** |
||
63 | * @var string Show lastm deals to partners |
||
64 | */ |
||
65 | public const EXTRAS_DEAL_LASTM = 'deal_lastm'; |
||
66 | |||
67 | /** |
||
68 | * @var string Show smart deals to partners |
||
69 | */ |
||
70 | public const EXTRAS_DEAL_SMART = 'deal_smart'; |
||
71 | |||
72 | /** |
||
73 | * @var string Show extra beds in group recommendations |
||
74 | */ |
||
75 | public const EXTRAS_EXTRA_BEDS = 'extra_beds'; |
||
76 | |||
77 | /** |
||
78 | * @var string Show breakdown of extra charges for each block |
||
79 | */ |
||
80 | public const EXTRAS_EXTRA_CHARGES = 'extra_charges'; |
||
81 | |||
82 | /** |
||
83 | * @var string Show facilities |
||
84 | */ |
||
85 | public const EXTRAS_FACILITIES = 'facilities'; |
||
86 | |||
87 | /** |
||
88 | * @var string Show recommendations for group bookers |
||
89 | */ |
||
90 | public const EXTRAS_GROUP_RECOMMENDATIONS = 'group_recommendations'; |
||
91 | |||
92 | /** |
||
93 | * @var string Show indication if the hotel qualifies for domestic no credit card |
||
94 | */ |
||
95 | public const EXTRAS_IF_DOMESTIC_NO_CC = 'if_domestic_no_cc'; |
||
96 | |||
97 | /** |
||
98 | * @var string Show indication if the hotel qualifies for no credit card reservation |
||
99 | */ |
||
100 | public const EXTRAS_IF_NO_CC_ALLOWED = 'if_no_cc_allowed'; |
||
101 | |||
102 | /** |
||
103 | * @var string Show important information |
||
104 | */ |
||
105 | public const EXTRAS_IMPORTANT_INFORMATION = 'important_information'; |
||
106 | |||
107 | /** |
||
108 | * @var string Show internet/wifi availability |
||
109 | */ |
||
110 | public const EXTRAS_INTERNET = 'internet'; |
||
111 | |||
112 | /** |
||
113 | * @var string Show the just_booked flag if the room has been booked in the last 20 minutes |
||
114 | */ |
||
115 | public const EXTRAS_JUST_BOOKED = 'just_booked'; |
||
116 | |||
117 | /** |
||
118 | * @var string Shows the maximum number of children allowed for free |
||
119 | */ |
||
120 | public const EXTRAS_MAX_CHILDREN_FREE = 'max_children_free'; |
||
121 | |||
122 | /** |
||
123 | * @var string Shows the age limit used for deciding whether children stay for free in a room |
||
124 | */ |
||
125 | public const EXTRAS_MAX_CHILDREN_FREE_AGE = 'max_children_free_age'; |
||
126 | |||
127 | /** |
||
128 | * @var string Show max number of rooms in one reservation |
||
129 | */ |
||
130 | public const EXTRAS_MAX_ROOMS_IN_RESERVATION = 'max_rooms_in_reservation'; |
||
131 | |||
132 | /** |
||
133 | * @var string Show half-board, full-board and all inclusive mealplan information in the output |
||
134 | */ |
||
135 | public const EXTRAS_MEALPLANS = 'mealplans'; |
||
136 | |||
137 | /** |
||
138 | * @var string Show net_price in extra charges |
||
139 | */ |
||
140 | public const EXTRAS_NET_PRICE = 'net_price'; |
||
141 | |||
142 | /** |
||
143 | * @var string Show the number of rooms left |
||
144 | */ |
||
145 | public const EXTRAS_NUMBERS_OF_ROOMS_LEFT = 'number_of_rooms_left'; |
||
146 | |||
147 | /** |
||
148 | * @var string Show the payment terms name and the description for cancellation and prepay terms. |
||
149 | */ |
||
150 | public const EXTRAS_PAYMENT_TERMS = 'payment_terms'; |
||
151 | |||
152 | /** |
||
153 | * @var string Show 1 room photo even if detail_level=0 |
||
154 | */ |
||
155 | public const EXTRAS_PHOTOS = 'photos'; |
||
156 | |||
157 | /** |
||
158 | * @var string Show policies |
||
159 | */ |
||
160 | public const EXTRAS_POLICIES = 'policies'; |
||
161 | |||
162 | /** |
||
163 | * Show url for postcard photo only if high resolution photo for this format is available, |
||
164 | * otherwise skip it (requires detail_level=1 or extras=photos) |
||
165 | * @var string |
||
166 | */ |
||
167 | public const EXTRAS_POSTCARD_PHOTO = 'postcard_photo'; |
||
168 | |||
169 | /** |
||
170 | * @var string Show rack rates in the output. Using this parameter may significantly affect performance |
||
171 | */ |
||
172 | public const EXTRAS_RACK_RATES = 'rack_rates'; |
||
173 | |||
174 | /** |
||
175 | * @var string Show room type id |
||
176 | */ |
||
177 | public const EXTRAS_ROOM_TYPE_ID = 'room_type_id'; |
||
178 | |||
179 | /** |
||
180 | * Show the no-smoking bit in the results per block. Possible values are "unknown", "smoking" or "non-smoking" |
||
181 | * @var string |
||
182 | */ |
||
183 | public const EXTRAS_SMOKING_STATUS = 'smoking_status'; |
||
184 | |||
185 | /** |
||
186 | * @var string |
||
187 | */ |
||
188 | protected static $uri = '/blockAvailability'; |
||
189 | |||
190 | /** |
||
191 | * @var array |
||
192 | */ |
||
193 | protected $hotel_ids; |
||
194 | |||
195 | /** |
||
196 | * @var string The arrival date. Must be within 360 days in the future and in the format yyyy-mm-dd. |
||
197 | */ |
||
198 | protected $checkin; |
||
199 | |||
200 | /** |
||
201 | * The departure date. Must be later than {checkin}. Must be between 1 and 30 days after {checkin}. |
||
202 | * Must be within 360 days in the future and in the format yyyy-mm-dd. |
||
203 | * @var string |
||
204 | */ |
||
205 | protected $checkout; |
||
206 | |||
207 | /** |
||
208 | * @var string Returns the prices in this currency, in addition to the hotel currency |
||
209 | */ |
||
210 | protected $currency; |
||
211 | |||
212 | /** |
||
213 | * @var array The extras parameter definitions are defined in the descriptions. |
||
214 | */ |
||
215 | protected $extras; |
||
216 | |||
217 | /** |
||
218 | * Specify the language for: block_id, policies, room texts and hotel descriptions. |
||
219 | * Note: not all text is translated in all languages. |
||
220 | * @var string |
||
221 | */ |
||
222 | protected $language; |
||
223 | |||
224 | /** |
||
225 | * @var int Show blocks from only test hotels (useful for debugging). possible values 0, 1 |
||
226 | */ |
||
227 | protected $show_only_test; |
||
228 | |||
229 | /** |
||
230 | * @var int Show blocks from test hotels (useful for debugging). possible values 0, 1 |
||
231 | */ |
||
232 | protected $show_test; |
||
233 | |||
234 | /** |
||
235 | * Which guests to put in which rooms. Syntax: comma-separated list, |
||
236 | * A for each adult, a number in the range 0..17 for each child.If you use this parameter, |
||
237 | * then you should add guest_quantities to processBooking call, |
||
238 | * otherwise per-person included charges may cause pricing problems, causing the booking to fail. |
||
239 | * @var array |
||
240 | */ |
||
241 | protected $room1; |
||
242 | protected $room2; |
||
243 | protected $room3; |
||
244 | protected $room4; |
||
245 | protected $room5; |
||
246 | protected $room6; |
||
247 | protected $room7; |
||
248 | protected $room8; |
||
249 | protected $room9; |
||
250 | protected $room10; |
||
251 | protected $room11; |
||
252 | protected $room12; |
||
253 | protected $room13; |
||
254 | protected $room14; |
||
255 | protected $room15; |
||
256 | protected $room16; |
||
257 | protected $room17; |
||
258 | protected $room18; |
||
259 | protected $room19; |
||
260 | protected $room20; |
||
261 | protected $room21; |
||
262 | protected $room22; |
||
263 | protected $room23; |
||
264 | protected $room24; |
||
265 | protected $room25; |
||
266 | protected $room26; |
||
267 | protected $room27; |
||
268 | protected $room28; |
||
269 | protected $room29; |
||
270 | protected $room30; |
||
271 | |||
272 | /** |
||
273 | * @return bool |
||
274 | */ |
||
275 | public function isSecure(): bool |
||
279 | |||
280 | /** |
||
281 | * @return array |
||
282 | */ |
||
283 | public function getHotelIds(): ?array |
||
287 | |||
288 | /** |
||
289 | * @param array $hotel_ids |
||
290 | * @return self |
||
291 | */ |
||
292 | public function setHotelIds(array $hotel_ids): self |
||
298 | |||
299 | /** |
||
300 | * @return string |
||
301 | */ |
||
302 | public function getCheckin(): ?string |
||
306 | |||
307 | /** |
||
308 | * @param DateTime $checkin |
||
309 | * @return self |
||
310 | */ |
||
311 | public function setCheckin(DateTime $checkin): self |
||
317 | |||
318 | /** |
||
319 | * @return string |
||
320 | */ |
||
321 | public function getCheckout(): ?string |
||
325 | |||
326 | /** |
||
327 | * @param DateTime $checkout |
||
328 | * @return self |
||
329 | */ |
||
330 | public function setCheckout(DateTime $checkout): self |
||
336 | |||
337 | /** |
||
338 | * @return string |
||
339 | */ |
||
340 | public function getCurrency(): ?string |
||
344 | |||
345 | /** |
||
346 | * @param string $currency |
||
347 | * @return self |
||
348 | */ |
||
349 | public function setCurrency(string $currency): self |
||
355 | |||
356 | /** |
||
357 | * @return array|null |
||
358 | */ |
||
359 | public function getExtras(): ?array |
||
363 | |||
364 | /** |
||
365 | * @param array $extras |
||
366 | * @return self |
||
367 | */ |
||
368 | public function setExtras(array $extras): self |
||
374 | |||
375 | /** |
||
376 | * @return BlockAvailabilityQuery |
||
377 | */ |
||
378 | public function withExtras(): self |
||
418 | |||
419 | /** |
||
420 | * @return string |
||
421 | */ |
||
422 | public function getLanguage(): ?string |
||
426 | |||
427 | /** |
||
428 | * @param string $language |
||
429 | * @return self |
||
430 | */ |
||
431 | public function setLanguage(string $language): self |
||
437 | |||
438 | /** |
||
439 | * @return int |
||
440 | */ |
||
441 | public function getShowOnlyTest(): ?int |
||
445 | |||
446 | /** |
||
447 | * @param bool $show_only_test |
||
448 | * @return self |
||
449 | */ |
||
450 | public function setShowOnlyTest(bool $show_only_test): self |
||
456 | |||
457 | /** |
||
458 | * @return int |
||
459 | */ |
||
460 | public function getShowTest(): ?int |
||
464 | |||
465 | /** |
||
466 | * @param bool $show_test |
||
467 | * @return self |
||
468 | */ |
||
469 | public function setShowTest(bool $show_test): self |
||
475 | |||
476 | /** |
||
477 | * @return array |
||
478 | */ |
||
479 | public function getRoom1(): ?array |
||
483 | |||
484 | /** |
||
485 | * @param array $room1 |
||
486 | * @return self |
||
487 | */ |
||
488 | public function setRoom1(array $room1): self |
||
494 | |||
495 | /** |
||
496 | * @return array |
||
497 | */ |
||
498 | public function getRoom2(): ?array |
||
502 | |||
503 | /** |
||
504 | * @param array $room2 |
||
505 | * @return self |
||
506 | */ |
||
507 | public function setRoom2(array $room2): self |
||
513 | |||
514 | /** |
||
515 | * @return array |
||
516 | */ |
||
517 | public function getRoom3(): ?array |
||
521 | |||
522 | /** |
||
523 | * @param array $room3 |
||
524 | * @return self |
||
525 | */ |
||
526 | public function setRoom3(array $room3): self |
||
532 | |||
533 | /** |
||
534 | * @return array |
||
535 | */ |
||
536 | public function getRoom4(): ?array |
||
540 | |||
541 | /** |
||
542 | * @param array $room4 |
||
543 | * @return self |
||
544 | */ |
||
545 | public function setRoom4(array $room4): self |
||
551 | |||
552 | /** |
||
553 | * @return array |
||
554 | */ |
||
555 | public function getRoom5(): ?array |
||
559 | |||
560 | /** |
||
561 | * @param array $room5 |
||
562 | * @return self |
||
563 | */ |
||
564 | public function setRoom5(array $room5): self |
||
570 | |||
571 | /** |
||
572 | * @return array |
||
573 | */ |
||
574 | public function getRoom6(): ?array |
||
578 | |||
579 | /** |
||
580 | * @param array $room6 |
||
581 | * @return self |
||
582 | */ |
||
583 | public function setRoom6(array $room6): self |
||
589 | |||
590 | /** |
||
591 | * @return array |
||
592 | */ |
||
593 | public function getRoom7(): ?array |
||
597 | |||
598 | /** |
||
599 | * @param array $room7 |
||
600 | * @return self |
||
601 | */ |
||
602 | public function setRoom7(array $room7): self |
||
608 | |||
609 | /** |
||
610 | * @return array |
||
611 | */ |
||
612 | public function getRoom8(): ?array |
||
616 | |||
617 | /** |
||
618 | * @param array $room8 |
||
619 | * @return self |
||
620 | */ |
||
621 | public function setRoom8(array $room8): self |
||
627 | |||
628 | /** |
||
629 | * @return array |
||
630 | */ |
||
631 | public function getRoom9(): ?array |
||
635 | |||
636 | /** |
||
637 | * @param array $room9 |
||
638 | * @return self |
||
639 | */ |
||
640 | public function setRoom9(array $room9): self |
||
646 | |||
647 | /** |
||
648 | * @return array |
||
649 | */ |
||
650 | public function getRoom10(): ?array |
||
654 | |||
655 | /** |
||
656 | * @param array $room10 |
||
657 | * @return self |
||
658 | */ |
||
659 | public function setRoom10(array $room10): self |
||
665 | |||
666 | /** |
||
667 | * @return array |
||
668 | */ |
||
669 | public function getRoom11(): ?array |
||
673 | |||
674 | /** |
||
675 | * @param array $room11 |
||
676 | * @return self |
||
677 | */ |
||
678 | public function setRoom11(array $room11): self |
||
684 | |||
685 | /** |
||
686 | * @return array |
||
687 | */ |
||
688 | public function getRoom12(): ?array |
||
692 | |||
693 | /** |
||
694 | * @param array $room12 |
||
695 | * @return self |
||
696 | */ |
||
697 | public function setRoom12(array $room12): self |
||
703 | |||
704 | /** |
||
705 | * @return array |
||
706 | */ |
||
707 | public function getRoom13(): ?array |
||
711 | |||
712 | /** |
||
713 | * @param array $room13 |
||
714 | * @return self |
||
715 | */ |
||
716 | public function setRoom13(array $room13): self |
||
722 | |||
723 | /** |
||
724 | * @return array |
||
725 | */ |
||
726 | public function getRoom14(): ?array |
||
730 | |||
731 | /** |
||
732 | * @param array $room14 |
||
733 | * @return self |
||
734 | */ |
||
735 | public function setRoom14(array $room14): self |
||
741 | |||
742 | /** |
||
743 | * @return array |
||
744 | */ |
||
745 | public function getRoom15(): ?array |
||
749 | |||
750 | /** |
||
751 | * @param array $room15 |
||
752 | * @return self |
||
753 | */ |
||
754 | public function setRoom15(array $room15): self |
||
760 | |||
761 | /** |
||
762 | * @return array |
||
763 | */ |
||
764 | public function getRoom16(): ?array |
||
768 | |||
769 | /** |
||
770 | * @param array $room16 |
||
771 | * @return self |
||
772 | */ |
||
773 | public function setRoom16(array $room16): self |
||
779 | |||
780 | /** |
||
781 | * @return array |
||
782 | */ |
||
783 | public function getRoom17(): ?array |
||
787 | |||
788 | /** |
||
789 | * @param array $room17 |
||
790 | * @return self |
||
791 | */ |
||
792 | public function setRoom17(array $room17): self |
||
798 | |||
799 | /** |
||
800 | * @return array |
||
801 | */ |
||
802 | public function getRoom18(): ?array |
||
806 | |||
807 | /** |
||
808 | * @param array $room18 |
||
809 | * @return self |
||
810 | */ |
||
811 | public function setRoom18(array $room18): self |
||
817 | |||
818 | /** |
||
819 | * @return array |
||
820 | */ |
||
821 | public function getRoom19(): ?array |
||
825 | |||
826 | /** |
||
827 | * @param array $room19 |
||
828 | * @return self |
||
829 | */ |
||
830 | public function setRoom19(array $room19): self |
||
836 | |||
837 | /** |
||
838 | * @return array |
||
839 | */ |
||
840 | public function getRoom20(): ?array |
||
844 | |||
845 | /** |
||
846 | * @param array $room20 |
||
847 | * @return self |
||
848 | */ |
||
849 | public function setRoom20(array $room20): self |
||
855 | |||
856 | /** |
||
857 | * @return array |
||
858 | */ |
||
859 | public function getRoom21(): ?array |
||
863 | |||
864 | /** |
||
865 | * @param array $room21 |
||
866 | * @return self |
||
867 | */ |
||
868 | public function setRoom21(array $room21): self |
||
874 | |||
875 | /** |
||
876 | * @return array |
||
877 | */ |
||
878 | public function getRoom22(): ?array |
||
882 | |||
883 | /** |
||
884 | * @param array $room22 |
||
885 | * @return self |
||
886 | */ |
||
887 | public function setRoom22(array $room22): self |
||
893 | |||
894 | /** |
||
895 | * @return array |
||
896 | */ |
||
897 | public function getRoom23(): ?array |
||
901 | |||
902 | /** |
||
903 | * @param array $room23 |
||
904 | * @return self |
||
905 | */ |
||
906 | public function setRoom23(array $room23): self |
||
912 | |||
913 | /** |
||
914 | * @return array |
||
915 | */ |
||
916 | public function getRoom24(): ?array |
||
920 | |||
921 | /** |
||
922 | * @param array $room24 |
||
923 | * @return self |
||
924 | */ |
||
925 | public function setRoom24(array $room24): self |
||
931 | |||
932 | /** |
||
933 | * @return array |
||
934 | */ |
||
935 | public function getRoom25(): ?array |
||
939 | |||
940 | /** |
||
941 | * @param array $room25 |
||
942 | * @return self |
||
943 | */ |
||
944 | public function setRoom25(array $room25): self |
||
950 | |||
951 | /** |
||
952 | * @return array |
||
953 | */ |
||
954 | public function getRoom26(): ?array |
||
958 | |||
959 | /** |
||
960 | * @param array $room26 |
||
961 | * @return self |
||
962 | */ |
||
963 | public function setRoom26(array $room26): self |
||
969 | |||
970 | /** |
||
971 | * @return array |
||
972 | */ |
||
973 | public function getRoom27(): ?array |
||
977 | |||
978 | /** |
||
979 | * @param array $room27 |
||
980 | * @return self |
||
981 | */ |
||
982 | public function setRoom27(array $room27): self |
||
988 | |||
989 | /** |
||
990 | * @return array |
||
991 | */ |
||
992 | public function getRoom28(): ?array |
||
996 | |||
997 | /** |
||
998 | * @param array $room28 |
||
999 | * @return self |
||
1000 | */ |
||
1001 | public function setRoom28(array $room28): self |
||
1007 | |||
1008 | /** |
||
1009 | * @return array |
||
1010 | */ |
||
1011 | public function getRoom29(): ?array |
||
1015 | |||
1016 | /** |
||
1017 | * @param array $room29 |
||
1018 | * @return self |
||
1019 | */ |
||
1020 | public function setRoom29(array $room29): self |
||
1026 | |||
1027 | /** |
||
1028 | * @return array |
||
1029 | */ |
||
1030 | public function getRoom30(): ?array |
||
1034 | |||
1035 | /** |
||
1036 | * @param array $room30 |
||
1037 | * @return self |
||
1038 | */ |
||
1039 | public function setRoom30(array $room30): self |
||
1045 | |||
1046 | /** |
||
1047 | * @return array |
||
1048 | */ |
||
1049 | protected function getAttributeMap(): array |
||
1092 | |||
1093 | /** |
||
1094 | * {@inheritDoc} |
||
1095 | */ |
||
1096 | protected function model(): string |
||
1100 | } |
||
1101 |