Complex classes like SaveGiftCertificate 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 SaveGiftCertificate, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class SaveGiftCertificate |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var int $intGUID |
||
10 | */ |
||
11 | protected $intGUID = null; |
||
12 | |||
13 | /** |
||
14 | * @var string $strISOLanguage |
||
15 | */ |
||
16 | protected $strISOLanguage = null; |
||
17 | |||
18 | /** |
||
19 | * @var string $strLastName |
||
20 | */ |
||
21 | protected $strLastName = null; |
||
22 | |||
23 | /** |
||
24 | * @var string $strFirstName |
||
25 | */ |
||
26 | protected $strFirstName = null; |
||
27 | |||
28 | /** |
||
29 | * @var string $strAddress1 |
||
30 | */ |
||
31 | protected $strAddress1 = null; |
||
32 | |||
33 | /** |
||
34 | * @var string $strZip |
||
35 | */ |
||
36 | protected $strZip = null; |
||
37 | |||
38 | /** |
||
39 | * @var string $strCity |
||
40 | */ |
||
41 | protected $strCity = null; |
||
42 | |||
43 | /** |
||
44 | * @var string $strState |
||
45 | */ |
||
46 | protected $strState = null; |
||
47 | |||
48 | /** |
||
49 | * @var string $strCountry |
||
50 | */ |
||
51 | protected $strCountry = null; |
||
52 | |||
53 | /** |
||
54 | * @var string $strPhone |
||
55 | */ |
||
56 | protected $strPhone = null; |
||
57 | |||
58 | /** |
||
59 | * @var string $strEmail |
||
60 | */ |
||
61 | protected $strEmail = null; |
||
62 | |||
63 | /** |
||
64 | * @var string $strFrom |
||
65 | */ |
||
66 | protected $strFrom = null; |
||
67 | |||
68 | /** |
||
69 | * @var string $strRecipientLastName |
||
70 | */ |
||
71 | protected $strRecipientLastName = null; |
||
72 | |||
73 | /** |
||
74 | * @var string $strRecipientFirstName |
||
75 | */ |
||
76 | protected $strRecipientFirstName = null; |
||
77 | |||
78 | /** |
||
79 | * @var string $strRecipientEmail |
||
80 | */ |
||
81 | protected $strRecipientEmail = null; |
||
82 | |||
83 | /** |
||
84 | * @var string $strRecipientAddress1 |
||
85 | */ |
||
86 | protected $strRecipientAddress1 = null; |
||
87 | |||
88 | /** |
||
89 | * @var string $strRecipientZip |
||
90 | */ |
||
91 | protected $strRecipientZip = null; |
||
92 | |||
93 | /** |
||
94 | * @var string $strRecipientCity |
||
95 | */ |
||
96 | protected $strRecipientCity = null; |
||
97 | |||
98 | /** |
||
99 | * @var string $strRecipientState |
||
100 | */ |
||
101 | protected $strRecipientState = null; |
||
102 | |||
103 | /** |
||
104 | * @var string $strRecipientCountry |
||
105 | */ |
||
106 | protected $strRecipientCountry = null; |
||
107 | |||
108 | /** |
||
109 | * @var string $strRecipientPhone |
||
110 | */ |
||
111 | protected $strRecipientPhone = null; |
||
112 | |||
113 | /** |
||
114 | * @var string $strMessage |
||
115 | */ |
||
116 | protected $strMessage = null; |
||
117 | |||
118 | /** |
||
119 | * @var int $intCCType |
||
120 | */ |
||
121 | protected $intCCType = null; |
||
122 | |||
123 | /** |
||
124 | * @var string $strCCNumber |
||
125 | */ |
||
126 | protected $strCCNumber = null; |
||
127 | |||
128 | /** |
||
129 | * @var \DateTime $dtCCExp |
||
130 | */ |
||
131 | protected $dtCCExp = null; |
||
132 | |||
133 | /** |
||
134 | * @var int $CVV2 |
||
135 | */ |
||
136 | protected $CVV2 = null; |
||
137 | |||
138 | /** |
||
139 | * @var string $strVaultTokenGuid |
||
140 | */ |
||
141 | protected $strVaultTokenGuid = null; |
||
142 | |||
143 | /** |
||
144 | * @var string $VaultLogin |
||
145 | */ |
||
146 | protected $VaultLogin = null; |
||
147 | |||
148 | /** |
||
149 | * @var string $VaultPassword |
||
150 | */ |
||
151 | protected $VaultPassword = null; |
||
152 | |||
153 | /** |
||
154 | * @var float $GiftCertificateAmount |
||
155 | */ |
||
156 | protected $GiftCertificateAmount = null; |
||
157 | |||
158 | /** |
||
159 | * @var dsGiftCertificateDetail $dsGiftCertificateDetail |
||
160 | */ |
||
161 | protected $dsGiftCertificateDetail = null; |
||
162 | |||
163 | /** |
||
164 | * @param int $intGUID |
||
165 | * @param string $strISOLanguage |
||
166 | * @param string $strLastName |
||
167 | * @param string $strFirstName |
||
168 | * @param string $strAddress1 |
||
169 | * @param string $strZip |
||
170 | * @param string $strCity |
||
171 | * @param string $strState |
||
172 | * @param string $strCountry |
||
173 | * @param string $strPhone |
||
174 | * @param string $strEmail |
||
175 | * @param string $strFrom |
||
176 | * @param string $strRecipientLastName |
||
177 | * @param string $strRecipientFirstName |
||
178 | * @param string $strRecipientEmail |
||
179 | * @param string $strRecipientAddress1 |
||
180 | * @param string $strRecipientZip |
||
181 | * @param string $strRecipientCity |
||
182 | * @param string $strRecipientState |
||
183 | * @param string $strRecipientCountry |
||
184 | * @param string $strRecipientPhone |
||
185 | * @param string $strMessage |
||
186 | * @param int $intCCType |
||
187 | * @param string $strCCNumber |
||
188 | * @param \DateTime $dtCCExp |
||
189 | * @param int $CVV2 |
||
190 | * @param string $strVaultTokenGuid |
||
191 | * @param string $VaultLogin |
||
192 | * @param string $VaultPassword |
||
193 | * @param float $GiftCertificateAmount |
||
194 | * @param dsGiftCertificateDetail $dsGiftCertificateDetail |
||
195 | */ |
||
196 | public function __construct($intGUID, $strISOLanguage, $strLastName, $strFirstName, $strAddress1, $strZip, $strCity, $strState, $strCountry, $strPhone, $strEmail, $strFrom, $strRecipientLastName, $strRecipientFirstName, $strRecipientEmail, $strRecipientAddress1, $strRecipientZip, $strRecipientCity, $strRecipientState, $strRecipientCountry, $strRecipientPhone, $strMessage, $intCCType, $strCCNumber, \DateTime $dtCCExp, $CVV2, $strVaultTokenGuid, $VaultLogin, $VaultPassword, $GiftCertificateAmount, $dsGiftCertificateDetail) |
||
230 | |||
231 | /** |
||
232 | * @return int |
||
233 | */ |
||
234 | public function getIntGUID() |
||
238 | |||
239 | /** |
||
240 | * @param int $intGUID |
||
241 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
242 | */ |
||
243 | public function setIntGUID($intGUID) |
||
248 | |||
249 | /** |
||
250 | * @return string |
||
251 | */ |
||
252 | public function getStrISOLanguage() |
||
256 | |||
257 | /** |
||
258 | * @param string $strISOLanguage |
||
259 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
260 | */ |
||
261 | public function setStrISOLanguage($strISOLanguage) |
||
266 | |||
267 | /** |
||
268 | * @return string |
||
269 | */ |
||
270 | public function getStrLastName() |
||
274 | |||
275 | /** |
||
276 | * @param string $strLastName |
||
277 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
278 | */ |
||
279 | public function setStrLastName($strLastName) |
||
284 | |||
285 | /** |
||
286 | * @return string |
||
287 | */ |
||
288 | public function getStrFirstName() |
||
292 | |||
293 | /** |
||
294 | * @param string $strFirstName |
||
295 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
296 | */ |
||
297 | public function setStrFirstName($strFirstName) |
||
302 | |||
303 | /** |
||
304 | * @return string |
||
305 | */ |
||
306 | public function getStrAddress1() |
||
310 | |||
311 | /** |
||
312 | * @param string $strAddress1 |
||
313 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
314 | */ |
||
315 | public function setStrAddress1($strAddress1) |
||
320 | |||
321 | /** |
||
322 | * @return string |
||
323 | */ |
||
324 | public function getStrZip() |
||
328 | |||
329 | /** |
||
330 | * @param string $strZip |
||
331 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
332 | */ |
||
333 | public function setStrZip($strZip) |
||
338 | |||
339 | /** |
||
340 | * @return string |
||
341 | */ |
||
342 | public function getStrCity() |
||
346 | |||
347 | /** |
||
348 | * @param string $strCity |
||
349 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
350 | */ |
||
351 | public function setStrCity($strCity) |
||
356 | |||
357 | /** |
||
358 | * @return string |
||
359 | */ |
||
360 | public function getStrState() |
||
364 | |||
365 | /** |
||
366 | * @param string $strState |
||
367 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
368 | */ |
||
369 | public function setStrState($strState) |
||
374 | |||
375 | /** |
||
376 | * @return string |
||
377 | */ |
||
378 | public function getStrCountry() |
||
382 | |||
383 | /** |
||
384 | * @param string $strCountry |
||
385 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
386 | */ |
||
387 | public function setStrCountry($strCountry) |
||
392 | |||
393 | /** |
||
394 | * @return string |
||
395 | */ |
||
396 | public function getStrPhone() |
||
400 | |||
401 | /** |
||
402 | * @param string $strPhone |
||
403 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
404 | */ |
||
405 | public function setStrPhone($strPhone) |
||
410 | |||
411 | /** |
||
412 | * @return string |
||
413 | */ |
||
414 | public function getStrEmail() |
||
418 | |||
419 | /** |
||
420 | * @param string $strEmail |
||
421 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
422 | */ |
||
423 | public function setStrEmail($strEmail) |
||
428 | |||
429 | /** |
||
430 | * @return string |
||
431 | */ |
||
432 | public function getStrFrom() |
||
436 | |||
437 | /** |
||
438 | * @param string $strFrom |
||
439 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
440 | */ |
||
441 | public function setStrFrom($strFrom) |
||
446 | |||
447 | /** |
||
448 | * @return string |
||
449 | */ |
||
450 | public function getStrRecipientLastName() |
||
454 | |||
455 | /** |
||
456 | * @param string $strRecipientLastName |
||
457 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
458 | */ |
||
459 | public function setStrRecipientLastName($strRecipientLastName) |
||
464 | |||
465 | /** |
||
466 | * @return string |
||
467 | */ |
||
468 | public function getStrRecipientFirstName() |
||
472 | |||
473 | /** |
||
474 | * @param string $strRecipientFirstName |
||
475 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
476 | */ |
||
477 | public function setStrRecipientFirstName($strRecipientFirstName) |
||
482 | |||
483 | /** |
||
484 | * @return string |
||
485 | */ |
||
486 | public function getStrRecipientEmail() |
||
490 | |||
491 | /** |
||
492 | * @param string $strRecipientEmail |
||
493 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
494 | */ |
||
495 | public function setStrRecipientEmail($strRecipientEmail) |
||
500 | |||
501 | /** |
||
502 | * @return string |
||
503 | */ |
||
504 | public function getStrRecipientAddress1() |
||
508 | |||
509 | /** |
||
510 | * @param string $strRecipientAddress1 |
||
511 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
512 | */ |
||
513 | public function setStrRecipientAddress1($strRecipientAddress1) |
||
518 | |||
519 | /** |
||
520 | * @return string |
||
521 | */ |
||
522 | public function getStrRecipientZip() |
||
526 | |||
527 | /** |
||
528 | * @param string $strRecipientZip |
||
529 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
530 | */ |
||
531 | public function setStrRecipientZip($strRecipientZip) |
||
536 | |||
537 | /** |
||
538 | * @return string |
||
539 | */ |
||
540 | public function getStrRecipientCity() |
||
544 | |||
545 | /** |
||
546 | * @param string $strRecipientCity |
||
547 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
548 | */ |
||
549 | public function setStrRecipientCity($strRecipientCity) |
||
554 | |||
555 | /** |
||
556 | * @return string |
||
557 | */ |
||
558 | public function getStrRecipientState() |
||
562 | |||
563 | /** |
||
564 | * @param string $strRecipientState |
||
565 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
566 | */ |
||
567 | public function setStrRecipientState($strRecipientState) |
||
572 | |||
573 | /** |
||
574 | * @return string |
||
575 | */ |
||
576 | public function getStrRecipientCountry() |
||
580 | |||
581 | /** |
||
582 | * @param string $strRecipientCountry |
||
583 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
584 | */ |
||
585 | public function setStrRecipientCountry($strRecipientCountry) |
||
590 | |||
591 | /** |
||
592 | * @return string |
||
593 | */ |
||
594 | public function getStrRecipientPhone() |
||
598 | |||
599 | /** |
||
600 | * @param string $strRecipientPhone |
||
601 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
602 | */ |
||
603 | public function setStrRecipientPhone($strRecipientPhone) |
||
608 | |||
609 | /** |
||
610 | * @return string |
||
611 | */ |
||
612 | public function getStrMessage() |
||
616 | |||
617 | /** |
||
618 | * @param string $strMessage |
||
619 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
620 | */ |
||
621 | public function setStrMessage($strMessage) |
||
626 | |||
627 | /** |
||
628 | * @return int |
||
629 | */ |
||
630 | public function getIntCCType() |
||
634 | |||
635 | /** |
||
636 | * @param int $intCCType |
||
637 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
638 | */ |
||
639 | public function setIntCCType($intCCType) |
||
644 | |||
645 | /** |
||
646 | * @return string |
||
647 | */ |
||
648 | public function getStrCCNumber() |
||
652 | |||
653 | /** |
||
654 | * @param string $strCCNumber |
||
655 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
656 | */ |
||
657 | public function setStrCCNumber($strCCNumber) |
||
662 | |||
663 | /** |
||
664 | * @return \DateTime |
||
665 | */ |
||
666 | public function getDtCCExp() |
||
678 | |||
679 | /** |
||
680 | * @param \DateTime $dtCCExp |
||
681 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
682 | */ |
||
683 | public function setDtCCExp(\DateTime $dtCCExp) |
||
688 | |||
689 | /** |
||
690 | * @return int |
||
691 | */ |
||
692 | public function getCVV2() |
||
696 | |||
697 | /** |
||
698 | * @param int $CVV2 |
||
699 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
700 | */ |
||
701 | public function setCVV2($CVV2) |
||
706 | |||
707 | /** |
||
708 | * @return string |
||
709 | */ |
||
710 | public function getStrVaultTokenGuid() |
||
714 | |||
715 | /** |
||
716 | * @param string $strVaultTokenGuid |
||
717 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
718 | */ |
||
719 | public function setStrVaultTokenGuid($strVaultTokenGuid) |
||
724 | |||
725 | /** |
||
726 | * @return string |
||
727 | */ |
||
728 | public function getVaultLogin() |
||
732 | |||
733 | /** |
||
734 | * @param string $VaultLogin |
||
735 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
736 | */ |
||
737 | public function setVaultLogin($VaultLogin) |
||
742 | |||
743 | /** |
||
744 | * @return string |
||
745 | */ |
||
746 | public function getVaultPassword() |
||
750 | |||
751 | /** |
||
752 | * @param string $VaultPassword |
||
753 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
754 | */ |
||
755 | public function setVaultPassword($VaultPassword) |
||
760 | |||
761 | /** |
||
762 | * @return float |
||
763 | */ |
||
764 | public function getGiftCertificateAmount() |
||
768 | |||
769 | /** |
||
770 | * @param float $GiftCertificateAmount |
||
771 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
772 | */ |
||
773 | public function setGiftCertificateAmount($GiftCertificateAmount) |
||
778 | |||
779 | /** |
||
780 | * @return dsGiftCertificateDetail |
||
781 | */ |
||
782 | public function getDsGiftCertificateDetail() |
||
786 | |||
787 | /** |
||
788 | * @param dsGiftCertificateDetail $dsGiftCertificateDetail |
||
789 | * @return \Gueststream\PMS\IQWare\API\SaveGiftCertificate |
||
790 | */ |
||
791 | public function setDsGiftCertificateDetail($dsGiftCertificateDetail) |
||
796 | } |
||
797 |
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..