Complex classes like PhoneMetadata 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 PhoneMetadata, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
10 | class PhoneMetadata |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $id = null; |
||
16 | /** |
||
17 | * @var int |
||
18 | */ |
||
19 | protected $countryCode = null; |
||
20 | protected $leadingDigits = null; |
||
21 | protected $internationalPrefix = null; |
||
22 | protected $preferredInternationalPrefix = null; |
||
23 | protected $nationalPrefixForParsing = null; |
||
24 | protected $nationalPrefixTransformRule = null; |
||
25 | protected $nationalPrefix = null; |
||
26 | protected $preferredExtnPrefix = null; |
||
27 | protected $mainCountryForCode = false; |
||
28 | protected $leadingZeroPossible = false; |
||
29 | protected $mobileNumberPortableRegion = false; |
||
30 | protected $generalDesc = null; |
||
31 | /** |
||
32 | * @var PhoneNumberDesc |
||
33 | */ |
||
34 | protected $mobile = null; |
||
35 | protected $premiumRate = null; |
||
36 | protected $fixedLine = null; |
||
37 | protected $sameMobileAndFixedLinePattern = false; |
||
38 | protected $numberFormat = array(); |
||
39 | protected $tollFree = null; |
||
40 | protected $sharedCost = null; |
||
41 | protected $personalNumber; |
||
42 | protected $voip; |
||
43 | protected $pager; |
||
44 | protected $uan; |
||
45 | protected $emergency; |
||
46 | protected $voicemail; |
||
47 | /** |
||
48 | * @var PhoneNumberDesc |
||
49 | */ |
||
50 | protected $short_code; |
||
51 | /** |
||
52 | * @var PhoneNumberDesc |
||
53 | */ |
||
54 | protected $standard_rate; |
||
55 | /** |
||
56 | * @var PhoneNumberDesc |
||
57 | */ |
||
58 | protected $carrierSpecific; |
||
59 | /** |
||
60 | * @var PhoneNumberDesc |
||
61 | */ |
||
62 | protected $smsServices; |
||
63 | /** |
||
64 | * @var PhoneNumberDesc |
||
65 | */ |
||
66 | protected $noInternationalDialling = null; |
||
67 | /** |
||
68 | * |
||
69 | * @var NumberFormat[] |
||
70 | */ |
||
71 | protected $intlNumberFormat = array(); |
||
72 | |||
73 | /** |
||
74 | * @return boolean |
||
75 | */ |
||
76 | public function hasId() |
||
80 | |||
81 | /** |
||
82 | * @return boolean |
||
83 | */ |
||
84 | 483 | public function hasCountryCode() |
|
88 | |||
89 | 483 | public function hasInternationalPrefix() |
|
93 | |||
94 | public function hasMainCountryForCode() |
||
98 | |||
99 | 2 | public function isMainCountryForCode() |
|
103 | |||
104 | 483 | public function getMainCountryForCode() |
|
108 | |||
109 | 1571 | public function setMainCountryForCode($value) |
|
114 | |||
115 | 2 | public function clearMainCountryForCode() |
|
120 | |||
121 | 483 | public function hasLeadingZeroPossible() |
|
125 | |||
126 | 483 | public function hasMobileNumberPortableRegion() |
|
130 | |||
131 | 483 | public function hasSameMobileAndFixedLinePattern() |
|
135 | |||
136 | 2 | public function numberFormatSize() |
|
140 | |||
141 | /** |
||
142 | * @param int $index |
||
143 | * @return NumberFormat |
||
144 | */ |
||
145 | 11 | public function getNumberFormat($index) |
|
149 | |||
150 | 27 | public function intlNumberFormatSize() |
|
154 | |||
155 | 6 | public function getIntlNumberFormat($index) |
|
159 | |||
160 | 7 | public function clearIntlNumberFormat() |
|
165 | |||
166 | 483 | public function toArray() |
|
301 | |||
302 | 486 | public function hasGeneralDesc() |
|
306 | |||
307 | /** |
||
308 | * @return PhoneNumberDesc |
||
309 | */ |
||
310 | 3601 | public function getGeneralDesc() |
|
314 | |||
315 | 1582 | public function setGeneralDesc(PhoneNumberDesc $value) |
|
320 | |||
321 | 489 | public function hasFixedLine() |
|
325 | |||
326 | /** |
||
327 | * @return PhoneNumberDesc |
||
328 | */ |
||
329 | 1863 | public function getFixedLine() |
|
333 | |||
334 | 1086 | public function setFixedLine(PhoneNumberDesc $value) |
|
339 | |||
340 | 489 | public function hasMobile() |
|
344 | |||
345 | /** |
||
346 | * @return PhoneNumberDesc |
||
347 | */ |
||
348 | 1475 | public function getMobile() |
|
352 | |||
353 | 1086 | public function setMobile(PhoneNumberDesc $value) |
|
358 | |||
359 | 489 | public function hasTollFree() |
|
363 | |||
364 | /** |
||
365 | * @return PhoneNumberDesc |
||
366 | */ |
||
367 | 2733 | public function getTollFree() |
|
371 | |||
372 | 1579 | public function setTollFree(PhoneNumberDesc $value) |
|
377 | |||
378 | 489 | public function hasPremiumRate() |
|
382 | |||
383 | /** |
||
384 | * @return PhoneNumberDesc |
||
385 | */ |
||
386 | 2981 | public function getPremiumRate() |
|
390 | |||
391 | 1576 | public function setPremiumRate(PhoneNumberDesc $value) |
|
396 | |||
397 | 489 | public function hasSharedCost() |
|
401 | |||
402 | /** |
||
403 | * @return PhoneNumberDesc |
||
404 | */ |
||
405 | 1937 | public function getSharedCost() |
|
409 | |||
410 | 1083 | public function setSharedCost(PhoneNumberDesc $value) |
|
415 | |||
416 | 489 | public function hasPersonalNumber() |
|
420 | |||
421 | /** |
||
422 | * @return PhoneNumberDesc |
||
423 | */ |
||
424 | 1790 | public function getPersonalNumber() |
|
428 | |||
429 | 1083 | public function setPersonalNumber(PhoneNumberDesc $value) |
|
434 | |||
435 | 489 | public function hasVoip() |
|
439 | |||
440 | /** |
||
441 | * @return PhoneNumberDesc |
||
442 | */ |
||
443 | 1855 | public function getVoip() |
|
447 | |||
448 | 1083 | public function setVoip(PhoneNumberDesc $value) |
|
453 | |||
454 | 489 | public function hasPager() |
|
458 | |||
459 | /** |
||
460 | * @return PhoneNumberDesc |
||
461 | */ |
||
462 | 1764 | public function getPager() |
|
466 | |||
467 | 1083 | public function setPager(PhoneNumberDesc $value) |
|
472 | |||
473 | 489 | public function hasUan() |
|
477 | |||
478 | /** |
||
479 | * @return PhoneNumberDesc |
||
480 | */ |
||
481 | 1718 | public function getUan() |
|
485 | |||
486 | 1083 | public function setUan(PhoneNumberDesc $value) |
|
491 | |||
492 | 750 | public function hasEmergency() |
|
496 | |||
497 | /** |
||
498 | * @return PhoneNumberDesc |
||
499 | */ |
||
500 | 501 | public function getEmergency() |
|
504 | |||
505 | 501 | public function setEmergency(PhoneNumberDesc $value) |
|
510 | |||
511 | 489 | public function hasVoicemail() |
|
515 | |||
516 | /** |
||
517 | * @return PhoneNumberDesc |
||
518 | */ |
||
519 | 1703 | public function getVoicemail() |
|
523 | |||
524 | 1083 | public function setVoicemail(PhoneNumberDesc $value) |
|
529 | |||
530 | 489 | public function hasShortCode() |
|
534 | |||
535 | 486 | public function getShortCode() |
|
539 | |||
540 | 501 | public function setShortCode(PhoneNumberDesc $value) |
|
545 | |||
546 | 489 | public function hasStandardRate() |
|
550 | |||
551 | 775 | public function getStandardRate() |
|
555 | |||
556 | 501 | public function setStandardRate(PhoneNumberDesc $value) |
|
561 | |||
562 | 489 | public function hasCarrierSpecific() |
|
566 | |||
567 | 480 | public function getCarrierSpecific() |
|
571 | |||
572 | 501 | public function setCarrierSpecific(PhoneNumberDesc $value) |
|
577 | |||
578 | 489 | public function hasSmsServices() |
|
582 | |||
583 | 480 | public function getSmsServices() |
|
587 | |||
588 | 501 | public function setSmsServices(PhoneNumberDesc $value) |
|
593 | |||
594 | 489 | public function hasNoInternationalDialling() |
|
598 | |||
599 | 493 | public function getNoInternationalDialling() |
|
603 | |||
604 | 1083 | public function setNoInternationalDialling(PhoneNumberDesc $value) |
|
609 | |||
610 | /** |
||
611 | * @return string |
||
612 | */ |
||
613 | 501 | public function getId() |
|
617 | |||
618 | /** |
||
619 | * @param string $value |
||
620 | * @return PhoneMetadata |
||
621 | */ |
||
622 | 1583 | public function setId($value) |
|
627 | |||
628 | /** |
||
629 | * @return int |
||
630 | */ |
||
631 | 3569 | public function getCountryCode() |
|
635 | |||
636 | /** |
||
637 | * @param int $value |
||
638 | * @return PhoneMetadata |
||
639 | */ |
||
640 | 1583 | public function setCountryCode($value) |
|
645 | |||
646 | 3567 | public function getInternationalPrefix() |
|
650 | |||
651 | 1583 | public function setInternationalPrefix($value) |
|
656 | |||
657 | 487 | public function hasPreferredInternationalPrefix() |
|
661 | |||
662 | 30 | public function getPreferredInternationalPrefix() |
|
666 | |||
667 | 97 | public function setPreferredInternationalPrefix($value) |
|
672 | |||
673 | 2 | public function clearPreferredInternationalPrefix() |
|
678 | |||
679 | 516 | public function hasNationalPrefix() |
|
683 | |||
684 | 179 | public function getNationalPrefix() |
|
688 | |||
689 | 754 | public function setNationalPrefix($value) |
|
694 | |||
695 | public function clearNationalPrefix() |
||
700 | |||
701 | 486 | public function hasPreferredExtnPrefix() |
|
705 | |||
706 | 8 | public function getPreferredExtnPrefix() |
|
710 | |||
711 | 193 | public function setPreferredExtnPrefix($value) |
|
716 | |||
717 | 2 | public function clearPreferredExtnPrefix() |
|
722 | |||
723 | 512 | public function hasNationalPrefixForParsing() |
|
727 | |||
728 | 3235 | public function getNationalPrefixForParsing() |
|
732 | |||
733 | 771 | public function setNationalPrefixForParsing($value) |
|
738 | |||
739 | 483 | public function hasNationalPrefixTransformRule() |
|
743 | |||
744 | 153 | public function getNationalPrefixTransformRule() |
|
748 | |||
749 | 52 | public function setNationalPrefixTransformRule($value) |
|
754 | |||
755 | 2 | public function clearNationalPrefixTransformRule() |
|
760 | |||
761 | 1686 | public function getSameMobileAndFixedLinePattern() |
|
765 | |||
766 | 5 | public function setSameMobileAndFixedLinePattern($value) |
|
771 | |||
772 | 2 | public function clearSameMobileAndFixedLinePattern() |
|
777 | |||
778 | /** |
||
779 | * @return NumberFormat[] |
||
780 | */ |
||
781 | 633 | public function numberFormats() |
|
785 | |||
786 | 590 | public function intlNumberFormats() |
|
790 | |||
791 | /** |
||
792 | * @return bool |
||
793 | */ |
||
794 | 1079 | public function hasLeadingDigits() |
|
798 | |||
799 | 201 | public function getLeadingDigits() |
|
803 | |||
804 | 80 | public function setLeadingDigits($value) |
|
809 | |||
810 | 483 | public function isLeadingZeroPossible() |
|
814 | |||
815 | 1570 | public function setLeadingZeroPossible($value) |
|
820 | |||
821 | 2 | public function clearLeadingZeroPossible() |
|
826 | |||
827 | 488 | public function isMobileNumberPortableRegion() |
|
831 | |||
832 | 1571 | public function setMobileNumberPortableRegion($value) |
|
837 | |||
838 | 2 | public function clearMobileNumberPortableRegion() |
|
843 | |||
844 | /** |
||
845 | * @param array $input |
||
846 | * @return PhoneMetadata |
||
847 | */ |
||
848 | 1570 | public function fromArray(array $input) |
|
989 | |||
990 | 982 | public function addNumberFormat(NumberFormat $value) |
|
995 | |||
996 | 274 | public function addIntlNumberFormat(NumberFormat $value) |
|
1001 | } |
||
1002 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.