Complex classes like NewTravelAgent 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 NewTravelAgent, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class NewTravelAgent |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var string $UserName |
||
10 | */ |
||
11 | protected $UserName = null; |
||
12 | |||
13 | /** |
||
14 | * @var string $Password |
||
15 | */ |
||
16 | protected $Password = null; |
||
17 | |||
18 | /** |
||
19 | * @var string $IATANo |
||
20 | */ |
||
21 | protected $IATANo = null; |
||
22 | |||
23 | /** |
||
24 | * @var int $Dear |
||
25 | */ |
||
26 | protected $Dear = null; |
||
27 | |||
28 | /** |
||
29 | * @var string $Address1 |
||
30 | */ |
||
31 | protected $Address1 = null; |
||
32 | |||
33 | /** |
||
34 | * @var string $LastName |
||
35 | */ |
||
36 | protected $LastName = null; |
||
37 | |||
38 | /** |
||
39 | * @var string $FirstName |
||
40 | */ |
||
41 | protected $FirstName = null; |
||
42 | |||
43 | /** |
||
44 | * @var string $City |
||
45 | */ |
||
46 | protected $City = null; |
||
47 | |||
48 | /** |
||
49 | * @var string $State |
||
50 | */ |
||
51 | protected $State = null; |
||
52 | |||
53 | /** |
||
54 | * @var string $Title |
||
55 | */ |
||
56 | protected $Title = null; |
||
57 | |||
58 | /** |
||
59 | * @var string $Country |
||
60 | */ |
||
61 | protected $Country = null; |
||
62 | |||
63 | /** |
||
64 | * @var string $ZipCode |
||
65 | */ |
||
66 | protected $ZipCode = null; |
||
67 | |||
68 | /** |
||
69 | * @var string $Address2 |
||
70 | */ |
||
71 | protected $Address2 = null; |
||
72 | |||
73 | /** |
||
74 | * @var string $WebSiteURL |
||
75 | */ |
||
76 | protected $WebSiteURL = null; |
||
77 | |||
78 | /** |
||
79 | * @var string $Email |
||
80 | */ |
||
81 | protected $Email = null; |
||
82 | |||
83 | /** |
||
84 | * @var boolean $IsMailing |
||
85 | */ |
||
86 | protected $IsMailing = null; |
||
87 | |||
88 | /** |
||
89 | * @var string $OtherCieName |
||
90 | */ |
||
91 | protected $OtherCieName = null; |
||
92 | |||
93 | /** |
||
94 | * @var int $ConfirmBy |
||
95 | */ |
||
96 | protected $ConfirmBy = null; |
||
97 | |||
98 | /** |
||
99 | * @var string $HomePhone |
||
100 | */ |
||
101 | protected $HomePhone = null; |
||
102 | |||
103 | /** |
||
104 | * @var string $WorkPhone |
||
105 | */ |
||
106 | protected $WorkPhone = null; |
||
107 | |||
108 | /** |
||
109 | * @var string $Fax |
||
110 | */ |
||
111 | protected $Fax = null; |
||
112 | |||
113 | /** |
||
114 | * @param string $UserName |
||
115 | * @param string $Password |
||
116 | * @param string $IATANo |
||
117 | * @param int $Dear |
||
118 | * @param string $Address1 |
||
119 | * @param string $LastName |
||
120 | * @param string $FirstName |
||
121 | * @param string $City |
||
122 | * @param string $State |
||
123 | * @param string $Title |
||
124 | * @param string $Country |
||
125 | * @param string $ZipCode |
||
126 | * @param string $Address2 |
||
127 | * @param string $WebSiteURL |
||
128 | * @param string $Email |
||
129 | * @param boolean $IsMailing |
||
130 | * @param string $OtherCieName |
||
131 | * @param int $ConfirmBy |
||
132 | * @param string $HomePhone |
||
133 | * @param string $WorkPhone |
||
134 | * @param string $Fax |
||
135 | */ |
||
136 | public function __construct($UserName, $Password, $IATANo, $Dear, $Address1, $LastName, $FirstName, $City, $State, $Title, $Country, $ZipCode, $Address2, $WebSiteURL, $Email, $IsMailing, $OtherCieName, $ConfirmBy, $HomePhone, $WorkPhone, $Fax) |
||
160 | |||
161 | /** |
||
162 | * @return string |
||
163 | */ |
||
164 | public function getUserName() |
||
168 | |||
169 | /** |
||
170 | * @param string $UserName |
||
171 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
172 | */ |
||
173 | public function setUserName($UserName) |
||
178 | |||
179 | /** |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getPassword() |
||
186 | |||
187 | /** |
||
188 | * @param string $Password |
||
189 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
190 | */ |
||
191 | public function setPassword($Password) |
||
196 | |||
197 | /** |
||
198 | * @return string |
||
199 | */ |
||
200 | public function getIATANo() |
||
204 | |||
205 | /** |
||
206 | * @param string $IATANo |
||
207 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
208 | */ |
||
209 | public function setIATANo($IATANo) |
||
214 | |||
215 | /** |
||
216 | * @return int |
||
217 | */ |
||
218 | public function getDear() |
||
222 | |||
223 | /** |
||
224 | * @param int $Dear |
||
225 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
226 | */ |
||
227 | public function setDear($Dear) |
||
232 | |||
233 | /** |
||
234 | * @return string |
||
235 | */ |
||
236 | public function getAddress1() |
||
240 | |||
241 | /** |
||
242 | * @param string $Address1 |
||
243 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
244 | */ |
||
245 | public function setAddress1($Address1) |
||
250 | |||
251 | /** |
||
252 | * @return string |
||
253 | */ |
||
254 | public function getLastName() |
||
258 | |||
259 | /** |
||
260 | * @param string $LastName |
||
261 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
262 | */ |
||
263 | public function setLastName($LastName) |
||
268 | |||
269 | /** |
||
270 | * @return string |
||
271 | */ |
||
272 | public function getFirstName() |
||
276 | |||
277 | /** |
||
278 | * @param string $FirstName |
||
279 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
280 | */ |
||
281 | public function setFirstName($FirstName) |
||
286 | |||
287 | /** |
||
288 | * @return string |
||
289 | */ |
||
290 | public function getCity() |
||
294 | |||
295 | /** |
||
296 | * @param string $City |
||
297 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
298 | */ |
||
299 | public function setCity($City) |
||
304 | |||
305 | /** |
||
306 | * @return string |
||
307 | */ |
||
308 | public function getState() |
||
312 | |||
313 | /** |
||
314 | * @param string $State |
||
315 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
316 | */ |
||
317 | public function setState($State) |
||
322 | |||
323 | /** |
||
324 | * @return string |
||
325 | */ |
||
326 | public function getTitle() |
||
330 | |||
331 | /** |
||
332 | * @param string $Title |
||
333 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
334 | */ |
||
335 | public function setTitle($Title) |
||
340 | |||
341 | /** |
||
342 | * @return string |
||
343 | */ |
||
344 | public function getCountry() |
||
348 | |||
349 | /** |
||
350 | * @param string $Country |
||
351 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
352 | */ |
||
353 | public function setCountry($Country) |
||
358 | |||
359 | /** |
||
360 | * @return string |
||
361 | */ |
||
362 | public function getZipCode() |
||
366 | |||
367 | /** |
||
368 | * @param string $ZipCode |
||
369 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
370 | */ |
||
371 | public function setZipCode($ZipCode) |
||
376 | |||
377 | /** |
||
378 | * @return string |
||
379 | */ |
||
380 | public function getAddress2() |
||
384 | |||
385 | /** |
||
386 | * @param string $Address2 |
||
387 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
388 | */ |
||
389 | public function setAddress2($Address2) |
||
394 | |||
395 | /** |
||
396 | * @return string |
||
397 | */ |
||
398 | public function getWebSiteURL() |
||
402 | |||
403 | /** |
||
404 | * @param string $WebSiteURL |
||
405 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
406 | */ |
||
407 | public function setWebSiteURL($WebSiteURL) |
||
412 | |||
413 | /** |
||
414 | * @return string |
||
415 | */ |
||
416 | public function getEmail() |
||
420 | |||
421 | /** |
||
422 | * @param string $Email |
||
423 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
424 | */ |
||
425 | public function setEmail($Email) |
||
430 | |||
431 | /** |
||
432 | * @return boolean |
||
433 | */ |
||
434 | public function getIsMailing() |
||
438 | |||
439 | /** |
||
440 | * @param boolean $IsMailing |
||
441 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
442 | */ |
||
443 | public function setIsMailing($IsMailing) |
||
448 | |||
449 | /** |
||
450 | * @return string |
||
451 | */ |
||
452 | public function getOtherCieName() |
||
456 | |||
457 | /** |
||
458 | * @param string $OtherCieName |
||
459 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
460 | */ |
||
461 | public function setOtherCieName($OtherCieName) |
||
466 | |||
467 | /** |
||
468 | * @return int |
||
469 | */ |
||
470 | public function getConfirmBy() |
||
474 | |||
475 | /** |
||
476 | * @param int $ConfirmBy |
||
477 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
478 | */ |
||
479 | public function setConfirmBy($ConfirmBy) |
||
484 | |||
485 | /** |
||
486 | * @return string |
||
487 | */ |
||
488 | public function getHomePhone() |
||
492 | |||
493 | /** |
||
494 | * @param string $HomePhone |
||
495 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
496 | */ |
||
497 | public function setHomePhone($HomePhone) |
||
502 | |||
503 | /** |
||
504 | * @return string |
||
505 | */ |
||
506 | public function getWorkPhone() |
||
510 | |||
511 | /** |
||
512 | * @param string $WorkPhone |
||
513 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
514 | */ |
||
515 | public function setWorkPhone($WorkPhone) |
||
520 | |||
521 | /** |
||
522 | * @return string |
||
523 | */ |
||
524 | public function getFax() |
||
528 | |||
529 | /** |
||
530 | * @param string $Fax |
||
531 | * @return \Gueststream\PMS\IQWare\API\NewTravelAgent |
||
532 | */ |
||
533 | public function setFax($Fax) |
||
538 | } |
||
539 |