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 | public function hasCountryCode() |
||
| 88 | |||
| 89 | public function hasInternationalPrefix() |
||
| 93 | |||
| 94 | public function hasMainCountryForCode() |
||
| 98 | |||
| 99 | public function isMainCountryForCode() |
||
| 103 | |||
| 104 | public function getMainCountryForCode() |
||
| 108 | |||
| 109 | public function setMainCountryForCode($value) |
||
| 114 | |||
| 115 | public function clearMainCountryForCode() |
||
| 120 | |||
| 121 | public function hasLeadingZeroPossible() |
||
| 125 | |||
| 126 | public function hasMobileNumberPortableRegion() |
||
| 130 | |||
| 131 | public function hasSameMobileAndFixedLinePattern() |
||
| 135 | |||
| 136 | public function numberFormatSize() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @param int $index |
||
| 143 | * @return NumberFormat |
||
| 144 | */ |
||
| 145 | public function getNumberFormat($index) |
||
| 149 | |||
| 150 | public function intlNumberFormatSize() |
||
| 154 | |||
| 155 | public function getIntlNumberFormat($index) |
||
| 159 | |||
| 160 | public function clearIntlNumberFormat() |
||
| 165 | |||
| 166 | public function toArray() |
||
| 301 | |||
| 302 | public function hasGeneralDesc() |
||
| 306 | |||
| 307 | /** |
||
| 308 | * @return PhoneNumberDesc |
||
| 309 | */ |
||
| 310 | public function getGeneralDesc() |
||
| 314 | |||
| 315 | public function setGeneralDesc(PhoneNumberDesc $value) |
||
| 320 | |||
| 321 | public function hasFixedLine() |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @return PhoneNumberDesc |
||
| 328 | */ |
||
| 329 | public function getFixedLine() |
||
| 333 | |||
| 334 | public function setFixedLine(PhoneNumberDesc $value) |
||
| 339 | |||
| 340 | public function hasMobile() |
||
| 344 | |||
| 345 | /** |
||
| 346 | * @return PhoneNumberDesc |
||
| 347 | */ |
||
| 348 | public function getMobile() |
||
| 352 | |||
| 353 | public function setMobile(PhoneNumberDesc $value) |
||
| 358 | |||
| 359 | public function hasTollFree() |
||
| 363 | |||
| 364 | /** |
||
| 365 | * @return PhoneNumberDesc |
||
| 366 | */ |
||
| 367 | public function getTollFree() |
||
| 371 | |||
| 372 | public function setTollFree(PhoneNumberDesc $value) |
||
| 377 | |||
| 378 | public function hasPremiumRate() |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @return PhoneNumberDesc |
||
| 385 | */ |
||
| 386 | public function getPremiumRate() |
||
| 390 | |||
| 391 | public function setPremiumRate(PhoneNumberDesc $value) |
||
| 396 | |||
| 397 | public function hasSharedCost() |
||
| 401 | |||
| 402 | /** |
||
| 403 | * @return PhoneNumberDesc |
||
| 404 | */ |
||
| 405 | public function getSharedCost() |
||
| 409 | |||
| 410 | public function setSharedCost(PhoneNumberDesc $value) |
||
| 415 | |||
| 416 | public function hasPersonalNumber() |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @return PhoneNumberDesc |
||
| 423 | */ |
||
| 424 | public function getPersonalNumber() |
||
| 428 | |||
| 429 | public function setPersonalNumber(PhoneNumberDesc $value) |
||
| 434 | |||
| 435 | public function hasVoip() |
||
| 439 | |||
| 440 | /** |
||
| 441 | * @return PhoneNumberDesc |
||
| 442 | */ |
||
| 443 | public function getVoip() |
||
| 447 | |||
| 448 | public function setVoip(PhoneNumberDesc $value) |
||
| 453 | |||
| 454 | public function hasPager() |
||
| 458 | |||
| 459 | /** |
||
| 460 | * @return PhoneNumberDesc |
||
| 461 | */ |
||
| 462 | public function getPager() |
||
| 466 | |||
| 467 | public function setPager(PhoneNumberDesc $value) |
||
| 472 | |||
| 473 | public function hasUan() |
||
| 477 | |||
| 478 | /** |
||
| 479 | * @return PhoneNumberDesc |
||
| 480 | */ |
||
| 481 | public function getUan() |
||
| 485 | |||
| 486 | public function setUan(PhoneNumberDesc $value) |
||
| 491 | |||
| 492 | public function hasEmergency() |
||
| 496 | |||
| 497 | /** |
||
| 498 | * @return PhoneNumberDesc |
||
| 499 | */ |
||
| 500 | public function getEmergency() |
||
| 504 | |||
| 505 | public function setEmergency(PhoneNumberDesc $value) |
||
| 510 | |||
| 511 | public function hasVoicemail() |
||
| 515 | |||
| 516 | /** |
||
| 517 | * @return PhoneNumberDesc |
||
| 518 | */ |
||
| 519 | public function getVoicemail() |
||
| 523 | |||
| 524 | public function setVoicemail(PhoneNumberDesc $value) |
||
| 529 | |||
| 530 | public function hasShortCode() |
||
| 534 | |||
| 535 | public function getShortCode() |
||
| 539 | |||
| 540 | public function setShortCode(PhoneNumberDesc $value) |
||
| 545 | |||
| 546 | public function hasStandardRate() |
||
| 550 | |||
| 551 | public function getStandardRate() |
||
| 555 | |||
| 556 | public function setStandardRate(PhoneNumberDesc $value) |
||
| 561 | |||
| 562 | public function hasCarrierSpecific() |
||
| 566 | |||
| 567 | public function getCarrierSpecific() |
||
| 571 | |||
| 572 | public function setCarrierSpecific(PhoneNumberDesc $value) |
||
| 577 | |||
| 578 | public function hasSmsServices() |
||
| 582 | |||
| 583 | public function getSmsServices() |
||
| 587 | |||
| 588 | public function setSmsServices(PhoneNumberDesc $value) |
||
| 593 | |||
| 594 | public function hasNoInternationalDialling() |
||
| 598 | |||
| 599 | public function getNoInternationalDialling() |
||
| 603 | |||
| 604 | public function setNoInternationalDialling(PhoneNumberDesc $value) |
||
| 609 | |||
| 610 | /** |
||
| 611 | * @return string |
||
| 612 | */ |
||
| 613 | public function getId() |
||
| 617 | |||
| 618 | /** |
||
| 619 | * @param string $value |
||
| 620 | * @return PhoneMetadata |
||
| 621 | */ |
||
| 622 | public function setId($value) |
||
| 627 | |||
| 628 | /** |
||
| 629 | * @return int |
||
| 630 | */ |
||
| 631 | public function getCountryCode() |
||
| 635 | |||
| 636 | /** |
||
| 637 | * @param int $value |
||
| 638 | * @return PhoneMetadata |
||
| 639 | */ |
||
| 640 | public function setCountryCode($value) |
||
| 645 | |||
| 646 | public function getInternationalPrefix() |
||
| 650 | |||
| 651 | public function setInternationalPrefix($value) |
||
| 656 | |||
| 657 | public function hasPreferredInternationalPrefix() |
||
| 661 | |||
| 662 | public function getPreferredInternationalPrefix() |
||
| 666 | |||
| 667 | public function setPreferredInternationalPrefix($value) |
||
| 672 | |||
| 673 | public function clearPreferredInternationalPrefix() |
||
| 678 | |||
| 679 | public function hasNationalPrefix() |
||
| 683 | |||
| 684 | public function getNationalPrefix() |
||
| 688 | |||
| 689 | public function setNationalPrefix($value) |
||
| 694 | |||
| 695 | public function clearNationalPrefix() |
||
| 700 | |||
| 701 | public function hasPreferredExtnPrefix() |
||
| 705 | |||
| 706 | public function getPreferredExtnPrefix() |
||
| 710 | |||
| 711 | public function setPreferredExtnPrefix($value) |
||
| 716 | |||
| 717 | public function clearPreferredExtnPrefix() |
||
| 722 | |||
| 723 | public function hasNationalPrefixForParsing() |
||
| 727 | |||
| 728 | public function getNationalPrefixForParsing() |
||
| 732 | |||
| 733 | public function setNationalPrefixForParsing($value) |
||
| 738 | |||
| 739 | public function hasNationalPrefixTransformRule() |
||
| 743 | |||
| 744 | public function getNationalPrefixTransformRule() |
||
| 748 | |||
| 749 | public function setNationalPrefixTransformRule($value) |
||
| 754 | |||
| 755 | public function clearNationalPrefixTransformRule() |
||
| 760 | |||
| 761 | public function getSameMobileAndFixedLinePattern() |
||
| 765 | |||
| 766 | public function setSameMobileAndFixedLinePattern($value) |
||
| 771 | |||
| 772 | public function clearSameMobileAndFixedLinePattern() |
||
| 777 | |||
| 778 | /** |
||
| 779 | * @return NumberFormat[] |
||
| 780 | */ |
||
| 781 | public function numberFormats() |
||
| 785 | |||
| 786 | public function intlNumberFormats() |
||
| 790 | |||
| 791 | /** |
||
| 792 | * @return bool |
||
| 793 | */ |
||
| 794 | public function hasLeadingDigits() |
||
| 798 | |||
| 799 | public function getLeadingDigits() |
||
| 803 | |||
| 804 | public function setLeadingDigits($value) |
||
| 809 | |||
| 810 | public function isLeadingZeroPossible() |
||
| 814 | |||
| 815 | public function setLeadingZeroPossible($value) |
||
| 820 | |||
| 821 | public function clearLeadingZeroPossible() |
||
| 826 | |||
| 827 | public function isMobileNumberPortableRegion() |
||
| 831 | |||
| 832 | public function setMobileNumberPortableRegion($value) |
||
| 837 | |||
| 838 | public function clearMobileNumberPortableRegion() |
||
| 843 | |||
| 844 | /** |
||
| 845 | * @param array $input |
||
| 846 | * @return PhoneMetadata |
||
| 847 | */ |
||
| 848 | public function fromArray(array $input) |
||
| 989 | |||
| 990 | public function addNumberFormat(NumberFormat $value) |
||
| 995 | |||
| 996 | 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.