Complex classes like TravelAgent 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 TravelAgent, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class TravelAgent |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $AccountNo |
||
10 | */ |
||
11 | protected $AccountNo = null; |
||
12 | |||
13 | /** |
||
14 | * @var int $AccountID |
||
15 | */ |
||
16 | protected $AccountID = null; |
||
17 | |||
18 | /** |
||
19 | * @var string $IATANo |
||
20 | */ |
||
21 | protected $IATANo = null; |
||
22 | |||
23 | /** |
||
24 | * @var boolean $IsPayable |
||
25 | */ |
||
26 | protected $IsPayable = null; |
||
27 | |||
28 | /** |
||
29 | * @var int $CurrencyID |
||
30 | */ |
||
31 | protected $CurrencyID = null; |
||
32 | |||
33 | /** |
||
34 | * @var int $AgentType |
||
35 | */ |
||
36 | protected $AgentType = null; |
||
37 | |||
38 | /** |
||
39 | * @var int $SAStatus |
||
40 | */ |
||
41 | protected $SAStatus = null; |
||
42 | |||
43 | /** |
||
44 | * @var int $AddressID |
||
45 | */ |
||
46 | protected $AddressID = null; |
||
47 | |||
48 | /** |
||
49 | * @var string $AccountName |
||
50 | */ |
||
51 | protected $AccountName = null; |
||
52 | |||
53 | /** |
||
54 | * @var float $TotalCommNotApproved |
||
55 | */ |
||
56 | protected $TotalCommNotApproved = null; |
||
57 | |||
58 | /** |
||
59 | * @var float $TotalCommNotPaid |
||
60 | */ |
||
61 | protected $TotalCommNotPaid = null; |
||
62 | |||
63 | /** |
||
64 | * @var float $CheckNotReconcile |
||
65 | */ |
||
66 | protected $CheckNotReconcile = null; |
||
67 | |||
68 | /** |
||
69 | * @var int $AccountAcceptedCurrencyType |
||
70 | */ |
||
71 | protected $AccountAcceptedCurrencyType = null; |
||
72 | |||
73 | /** |
||
74 | * @var int $PaymentMode1 |
||
75 | */ |
||
76 | protected $PaymentMode1 = null; |
||
77 | |||
78 | /** |
||
79 | * @var float $Mode1PctCommRate |
||
80 | */ |
||
81 | protected $Mode1PctCommRate = null; |
||
82 | |||
83 | /** |
||
84 | * @var float $Mode1FixCommRate |
||
85 | */ |
||
86 | protected $Mode1FixCommRate = null; |
||
87 | |||
88 | /** |
||
89 | * @var float $Mode1AddPersonRate |
||
90 | */ |
||
91 | protected $Mode1AddPersonRate = null; |
||
92 | |||
93 | /** |
||
94 | * @var int $PaymentMode2 |
||
95 | */ |
||
96 | protected $PaymentMode2 = null; |
||
97 | |||
98 | /** |
||
99 | * @var float $Mode2PctCommRate |
||
100 | */ |
||
101 | protected $Mode2PctCommRate = null; |
||
102 | |||
103 | /** |
||
104 | * @var float $Mode2FixCommRate |
||
105 | */ |
||
106 | protected $Mode2FixCommRate = null; |
||
107 | |||
108 | /** |
||
109 | * @var float $Mode2AddPersonRate |
||
110 | */ |
||
111 | protected $Mode2AddPersonRate = null; |
||
112 | |||
113 | /** |
||
114 | * @var Reservations $Reservations |
||
115 | */ |
||
116 | protected $Reservations = null; |
||
117 | |||
118 | /** |
||
119 | * @var Comissions $Comissions |
||
120 | */ |
||
121 | protected $Comissions = null; |
||
122 | |||
123 | /** |
||
124 | * @var Address $Address |
||
125 | */ |
||
126 | protected $Address = null; |
||
127 | |||
128 | /** |
||
129 | * @var Balances $Balances |
||
130 | */ |
||
131 | protected $Balances = null; |
||
132 | |||
133 | /** |
||
134 | * @var Telephones $Telephones |
||
135 | */ |
||
136 | protected $Telephones = null; |
||
137 | |||
138 | /** |
||
139 | * @param int $AccountNo |
||
140 | * @param int $AccountID |
||
141 | * @param string $IATANo |
||
142 | * @param boolean $IsPayable |
||
143 | * @param int $CurrencyID |
||
144 | * @param int $AgentType |
||
145 | * @param int $SAStatus |
||
146 | * @param int $AddressID |
||
147 | * @param string $AccountName |
||
148 | * @param float $TotalCommNotApproved |
||
149 | * @param float $TotalCommNotPaid |
||
150 | * @param float $CheckNotReconcile |
||
151 | * @param int $AccountAcceptedCurrencyType |
||
152 | * @param int $PaymentMode1 |
||
153 | * @param float $Mode1PctCommRate |
||
154 | * @param float $Mode1FixCommRate |
||
155 | * @param float $Mode1AddPersonRate |
||
156 | * @param int $PaymentMode2 |
||
157 | * @param float $Mode2PctCommRate |
||
158 | * @param float $Mode2FixCommRate |
||
159 | * @param float $Mode2AddPersonRate |
||
160 | * @param Reservations $Reservations |
||
161 | * @param Comissions $Comissions |
||
162 | * @param Address $Address |
||
163 | * @param Balances $Balances |
||
164 | * @param Telephones $Telephones |
||
165 | */ |
||
166 | public function __construct($AccountNo, $AccountID, $IATANo, $IsPayable, $CurrencyID, $AgentType, $SAStatus, $AddressID, $AccountName, $TotalCommNotApproved, $TotalCommNotPaid, $CheckNotReconcile, $AccountAcceptedCurrencyType, $PaymentMode1, $Mode1PctCommRate, $Mode1FixCommRate, $Mode1AddPersonRate, $PaymentMode2, $Mode2PctCommRate, $Mode2FixCommRate, $Mode2AddPersonRate, $Reservations, $Comissions, $Address, $Balances, $Telephones) |
||
195 | |||
196 | /** |
||
197 | * @return int |
||
198 | */ |
||
199 | public function getAccountNo() |
||
203 | |||
204 | /** |
||
205 | * @param int $AccountNo |
||
206 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
207 | */ |
||
208 | public function setAccountNo($AccountNo) |
||
213 | |||
214 | /** |
||
215 | * @return int |
||
216 | */ |
||
217 | public function getAccountID() |
||
221 | |||
222 | /** |
||
223 | * @param int $AccountID |
||
224 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
225 | */ |
||
226 | public function setAccountID($AccountID) |
||
231 | |||
232 | /** |
||
233 | * @return string |
||
234 | */ |
||
235 | public function getIATANo() |
||
239 | |||
240 | /** |
||
241 | * @param string $IATANo |
||
242 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
243 | */ |
||
244 | public function setIATANo($IATANo) |
||
249 | |||
250 | /** |
||
251 | * @return boolean |
||
252 | */ |
||
253 | public function getIsPayable() |
||
257 | |||
258 | /** |
||
259 | * @param boolean $IsPayable |
||
260 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
261 | */ |
||
262 | public function setIsPayable($IsPayable) |
||
267 | |||
268 | /** |
||
269 | * @return int |
||
270 | */ |
||
271 | public function getCurrencyID() |
||
275 | |||
276 | /** |
||
277 | * @param int $CurrencyID |
||
278 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
279 | */ |
||
280 | public function setCurrencyID($CurrencyID) |
||
285 | |||
286 | /** |
||
287 | * @return int |
||
288 | */ |
||
289 | public function getAgentType() |
||
293 | |||
294 | /** |
||
295 | * @param int $AgentType |
||
296 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
297 | */ |
||
298 | public function setAgentType($AgentType) |
||
303 | |||
304 | /** |
||
305 | * @return int |
||
306 | */ |
||
307 | public function getSAStatus() |
||
311 | |||
312 | /** |
||
313 | * @param int $SAStatus |
||
314 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
315 | */ |
||
316 | public function setSAStatus($SAStatus) |
||
321 | |||
322 | /** |
||
323 | * @return int |
||
324 | */ |
||
325 | public function getAddressID() |
||
329 | |||
330 | /** |
||
331 | * @param int $AddressID |
||
332 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
333 | */ |
||
334 | public function setAddressID($AddressID) |
||
339 | |||
340 | /** |
||
341 | * @return string |
||
342 | */ |
||
343 | public function getAccountName() |
||
347 | |||
348 | /** |
||
349 | * @param string $AccountName |
||
350 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
351 | */ |
||
352 | public function setAccountName($AccountName) |
||
357 | |||
358 | /** |
||
359 | * @return float |
||
360 | */ |
||
361 | public function getTotalCommNotApproved() |
||
365 | |||
366 | /** |
||
367 | * @param float $TotalCommNotApproved |
||
368 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
369 | */ |
||
370 | public function setTotalCommNotApproved($TotalCommNotApproved) |
||
375 | |||
376 | /** |
||
377 | * @return float |
||
378 | */ |
||
379 | public function getTotalCommNotPaid() |
||
383 | |||
384 | /** |
||
385 | * @param float $TotalCommNotPaid |
||
386 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
387 | */ |
||
388 | public function setTotalCommNotPaid($TotalCommNotPaid) |
||
393 | |||
394 | /** |
||
395 | * @return float |
||
396 | */ |
||
397 | public function getCheckNotReconcile() |
||
401 | |||
402 | /** |
||
403 | * @param float $CheckNotReconcile |
||
404 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
405 | */ |
||
406 | public function setCheckNotReconcile($CheckNotReconcile) |
||
411 | |||
412 | /** |
||
413 | * @return int |
||
414 | */ |
||
415 | public function getAccountAcceptedCurrencyType() |
||
419 | |||
420 | /** |
||
421 | * @param int $AccountAcceptedCurrencyType |
||
422 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
423 | */ |
||
424 | public function setAccountAcceptedCurrencyType($AccountAcceptedCurrencyType) |
||
429 | |||
430 | /** |
||
431 | * @return int |
||
432 | */ |
||
433 | public function getPaymentMode1() |
||
437 | |||
438 | /** |
||
439 | * @param int $PaymentMode1 |
||
440 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
441 | */ |
||
442 | public function setPaymentMode1($PaymentMode1) |
||
447 | |||
448 | /** |
||
449 | * @return float |
||
450 | */ |
||
451 | public function getMode1PctCommRate() |
||
455 | |||
456 | /** |
||
457 | * @param float $Mode1PctCommRate |
||
458 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
459 | */ |
||
460 | public function setMode1PctCommRate($Mode1PctCommRate) |
||
465 | |||
466 | /** |
||
467 | * @return float |
||
468 | */ |
||
469 | public function getMode1FixCommRate() |
||
473 | |||
474 | /** |
||
475 | * @param float $Mode1FixCommRate |
||
476 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
477 | */ |
||
478 | public function setMode1FixCommRate($Mode1FixCommRate) |
||
483 | |||
484 | /** |
||
485 | * @return float |
||
486 | */ |
||
487 | public function getMode1AddPersonRate() |
||
491 | |||
492 | /** |
||
493 | * @param float $Mode1AddPersonRate |
||
494 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
495 | */ |
||
496 | public function setMode1AddPersonRate($Mode1AddPersonRate) |
||
501 | |||
502 | /** |
||
503 | * @return int |
||
504 | */ |
||
505 | public function getPaymentMode2() |
||
509 | |||
510 | /** |
||
511 | * @param int $PaymentMode2 |
||
512 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
513 | */ |
||
514 | public function setPaymentMode2($PaymentMode2) |
||
519 | |||
520 | /** |
||
521 | * @return float |
||
522 | */ |
||
523 | public function getMode2PctCommRate() |
||
527 | |||
528 | /** |
||
529 | * @param float $Mode2PctCommRate |
||
530 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
531 | */ |
||
532 | public function setMode2PctCommRate($Mode2PctCommRate) |
||
537 | |||
538 | /** |
||
539 | * @return float |
||
540 | */ |
||
541 | public function getMode2FixCommRate() |
||
545 | |||
546 | /** |
||
547 | * @param float $Mode2FixCommRate |
||
548 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
549 | */ |
||
550 | public function setMode2FixCommRate($Mode2FixCommRate) |
||
555 | |||
556 | /** |
||
557 | * @return float |
||
558 | */ |
||
559 | public function getMode2AddPersonRate() |
||
563 | |||
564 | /** |
||
565 | * @param float $Mode2AddPersonRate |
||
566 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
567 | */ |
||
568 | public function setMode2AddPersonRate($Mode2AddPersonRate) |
||
573 | |||
574 | /** |
||
575 | * @return Reservations |
||
576 | */ |
||
577 | public function getReservations() |
||
581 | |||
582 | /** |
||
583 | * @param Reservations $Reservations |
||
584 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
585 | */ |
||
586 | public function setReservations($Reservations) |
||
591 | |||
592 | /** |
||
593 | * @return Comissions |
||
594 | */ |
||
595 | public function getComissions() |
||
599 | |||
600 | /** |
||
601 | * @param Comissions $Comissions |
||
602 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
603 | */ |
||
604 | public function setComissions($Comissions) |
||
609 | |||
610 | /** |
||
611 | * @return Address |
||
612 | */ |
||
613 | public function getAddress() |
||
617 | |||
618 | /** |
||
619 | * @param Address $Address |
||
620 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
621 | */ |
||
622 | public function setAddress($Address) |
||
627 | |||
628 | /** |
||
629 | * @return Balances |
||
630 | */ |
||
631 | public function getBalances() |
||
635 | |||
636 | /** |
||
637 | * @param Balances $Balances |
||
638 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
639 | */ |
||
640 | public function setBalances($Balances) |
||
645 | |||
646 | /** |
||
647 | * @return Telephones |
||
648 | */ |
||
649 | public function getTelephones() |
||
653 | |||
654 | /** |
||
655 | * @param Telephones $Telephones |
||
656 | * @return \Gueststream\PMS\IQWare\API\TravelAgent |
||
657 | */ |
||
658 | public function setTelephones($Telephones) |
||
663 | } |
||
664 |