Complex classes like Loyalty 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 Loyalty, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class Loyalty |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @var int $ID_Member |
||
| 10 | */ |
||
| 11 | protected $ID_Member = null; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var string $GHClub_Name |
||
| 15 | */ |
||
| 16 | protected $GHClub_Name = null; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string $GHClub_ShortName |
||
| 20 | */ |
||
| 21 | protected $GHClub_ShortName = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var boolean $GHClubLevel_IsActive |
||
| 25 | */ |
||
| 26 | protected $GHClubLevel_IsActive = null; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var string $GHClubLevel_Name |
||
| 30 | */ |
||
| 31 | protected $GHClubLevel_Name = null; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string $GHClubLevel_Shortname |
||
| 35 | */ |
||
| 36 | protected $GHClubLevel_Shortname = null; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var boolean $GHClubLevel_IsVIP |
||
| 40 | */ |
||
| 41 | protected $GHClubLevel_IsVIP = null; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var int $ID_SpecialRequestGroup |
||
| 45 | */ |
||
| 46 | protected $ID_SpecialRequestGroup = null; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var int $ID_GHClub |
||
| 50 | */ |
||
| 51 | protected $ID_GHClub = null; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var int $GHClubLevel_ViewOrder |
||
| 55 | */ |
||
| 56 | protected $GHClubLevel_ViewOrder = null; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var int $MinPoint |
||
| 60 | */ |
||
| 61 | protected $MinPoint = null; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var int $ID_Reference |
||
| 65 | */ |
||
| 66 | protected $ID_Reference = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var int $GHClubLevel_ID_VIP |
||
| 70 | */ |
||
| 71 | protected $GHClubLevel_ID_VIP = null; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var int $ID_MemberClub |
||
| 75 | */ |
||
| 76 | protected $ID_MemberClub = null; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var boolean $MemberClub_IsActive |
||
| 80 | */ |
||
| 81 | protected $MemberClub_IsActive = null; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var int $ID_GHClubLevel |
||
| 85 | */ |
||
| 86 | protected $ID_GHClubLevel = null; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var string $MemberClub_CardNumber |
||
| 90 | */ |
||
| 91 | protected $MemberClub_CardNumber = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var boolean $MemberClub_IsDefault |
||
| 95 | */ |
||
| 96 | protected $MemberClub_IsDefault = null; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var int $PropertyGUID |
||
| 100 | */ |
||
| 101 | protected $PropertyGUID = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var \DateTime $CreationDate |
||
| 105 | */ |
||
| 106 | protected $CreationDate = null; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var int $ID_MemberClubPoints |
||
| 110 | */ |
||
| 111 | protected $ID_MemberClubPoints = null; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var int $AccumTotal |
||
| 115 | */ |
||
| 116 | protected $AccumTotal = null; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var int $AccumYear |
||
| 120 | */ |
||
| 121 | protected $AccumYear = null; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @var int $ExpenseTotal |
||
| 125 | */ |
||
| 126 | protected $ExpenseTotal = null; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @var \DateTime $SysModifDate |
||
| 130 | */ |
||
| 131 | protected $SysModifDate = null; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @param int $ID_Member |
||
| 135 | * @param boolean $GHClubLevel_IsActive |
||
| 136 | * @param boolean $GHClubLevel_IsVIP |
||
| 137 | * @param int $ID_SpecialRequestGroup |
||
| 138 | * @param int $ID_GHClub |
||
| 139 | * @param int $GHClubLevel_ViewOrder |
||
| 140 | * @param int $MinPoint |
||
| 141 | * @param int $ID_Reference |
||
| 142 | * @param int $GHClubLevel_ID_VIP |
||
| 143 | * @param int $ID_MemberClub |
||
| 144 | * @param boolean $MemberClub_IsActive |
||
| 145 | * @param int $ID_GHClubLevel |
||
| 146 | * @param boolean $MemberClub_IsDefault |
||
| 147 | * @param int $PropertyGUID |
||
| 148 | * @param \DateTime $CreationDate |
||
| 149 | * @param int $ID_MemberClubPoints |
||
| 150 | * @param int $AccumTotal |
||
| 151 | * @param int $AccumYear |
||
| 152 | * @param int $ExpenseTotal |
||
| 153 | * @param \DateTime $SysModifDate |
||
| 154 | */ |
||
| 155 | public function __construct($ID_Member, $GHClubLevel_IsActive, $GHClubLevel_IsVIP, $ID_SpecialRequestGroup, $ID_GHClub, $GHClubLevel_ViewOrder, $MinPoint, $ID_Reference, $GHClubLevel_ID_VIP, $ID_MemberClub, $MemberClub_IsActive, $ID_GHClubLevel, $MemberClub_IsDefault, $PropertyGUID, \DateTime $CreationDate, $ID_MemberClubPoints, $AccumTotal, $AccumYear, $ExpenseTotal, \DateTime $SysModifDate) |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @return int |
||
| 181 | */ |
||
| 182 | public function getID_Member() |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @param int $ID_Member |
||
| 189 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 190 | */ |
||
| 191 | public function setID_Member($ID_Member) |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @return string |
||
| 199 | */ |
||
| 200 | public function getGHClub_Name() |
||
| 204 | |||
| 205 | /** |
||
| 206 | * @param string $GHClub_Name |
||
| 207 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 208 | */ |
||
| 209 | public function setGHClub_Name($GHClub_Name) |
||
| 214 | |||
| 215 | /** |
||
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | public function getGHClub_ShortName() |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @param string $GHClub_ShortName |
||
| 225 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 226 | */ |
||
| 227 | public function setGHClub_ShortName($GHClub_ShortName) |
||
| 232 | |||
| 233 | /** |
||
| 234 | * @return boolean |
||
| 235 | */ |
||
| 236 | public function getGHClubLevel_IsActive() |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @param boolean $GHClubLevel_IsActive |
||
| 243 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 244 | */ |
||
| 245 | public function setGHClubLevel_IsActive($GHClubLevel_IsActive) |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @return string |
||
| 253 | */ |
||
| 254 | public function getGHClubLevel_Name() |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @param string $GHClubLevel_Name |
||
| 261 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 262 | */ |
||
| 263 | public function setGHClubLevel_Name($GHClubLevel_Name) |
||
| 268 | |||
| 269 | /** |
||
| 270 | * @return string |
||
| 271 | */ |
||
| 272 | public function getGHClubLevel_Shortname() |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @param string $GHClubLevel_Shortname |
||
| 279 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 280 | */ |
||
| 281 | public function setGHClubLevel_Shortname($GHClubLevel_Shortname) |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @return boolean |
||
| 289 | */ |
||
| 290 | public function getGHClubLevel_IsVIP() |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @param boolean $GHClubLevel_IsVIP |
||
| 297 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 298 | */ |
||
| 299 | public function setGHClubLevel_IsVIP($GHClubLevel_IsVIP) |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @return int |
||
| 307 | */ |
||
| 308 | public function getID_SpecialRequestGroup() |
||
| 312 | |||
| 313 | /** |
||
| 314 | * @param int $ID_SpecialRequestGroup |
||
| 315 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 316 | */ |
||
| 317 | public function setID_SpecialRequestGroup($ID_SpecialRequestGroup) |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @return int |
||
| 325 | */ |
||
| 326 | public function getID_GHClub() |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @param int $ID_GHClub |
||
| 333 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 334 | */ |
||
| 335 | public function setID_GHClub($ID_GHClub) |
||
| 340 | |||
| 341 | /** |
||
| 342 | * @return int |
||
| 343 | */ |
||
| 344 | public function getGHClubLevel_ViewOrder() |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @param int $GHClubLevel_ViewOrder |
||
| 351 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 352 | */ |
||
| 353 | public function setGHClubLevel_ViewOrder($GHClubLevel_ViewOrder) |
||
| 358 | |||
| 359 | /** |
||
| 360 | * @return int |
||
| 361 | */ |
||
| 362 | public function getMinPoint() |
||
| 366 | |||
| 367 | /** |
||
| 368 | * @param int $MinPoint |
||
| 369 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 370 | */ |
||
| 371 | public function setMinPoint($MinPoint) |
||
| 376 | |||
| 377 | /** |
||
| 378 | * @return int |
||
| 379 | */ |
||
| 380 | public function getID_Reference() |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @param int $ID_Reference |
||
| 387 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 388 | */ |
||
| 389 | public function setID_Reference($ID_Reference) |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @return int |
||
| 397 | */ |
||
| 398 | public function getGHClubLevel_ID_VIP() |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @param int $GHClubLevel_ID_VIP |
||
| 405 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 406 | */ |
||
| 407 | public function setGHClubLevel_ID_VIP($GHClubLevel_ID_VIP) |
||
| 412 | |||
| 413 | /** |
||
| 414 | * @return int |
||
| 415 | */ |
||
| 416 | public function getID_MemberClub() |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @param int $ID_MemberClub |
||
| 423 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 424 | */ |
||
| 425 | public function setID_MemberClub($ID_MemberClub) |
||
| 430 | |||
| 431 | /** |
||
| 432 | * @return boolean |
||
| 433 | */ |
||
| 434 | public function getMemberClub_IsActive() |
||
| 438 | |||
| 439 | /** |
||
| 440 | * @param boolean $MemberClub_IsActive |
||
| 441 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 442 | */ |
||
| 443 | public function setMemberClub_IsActive($MemberClub_IsActive) |
||
| 448 | |||
| 449 | /** |
||
| 450 | * @return int |
||
| 451 | */ |
||
| 452 | public function getID_GHClubLevel() |
||
| 456 | |||
| 457 | /** |
||
| 458 | * @param int $ID_GHClubLevel |
||
| 459 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 460 | */ |
||
| 461 | public function setID_GHClubLevel($ID_GHClubLevel) |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @return string |
||
| 469 | */ |
||
| 470 | public function getMemberClub_CardNumber() |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @param string $MemberClub_CardNumber |
||
| 477 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 478 | */ |
||
| 479 | public function setMemberClub_CardNumber($MemberClub_CardNumber) |
||
| 484 | |||
| 485 | /** |
||
| 486 | * @return boolean |
||
| 487 | */ |
||
| 488 | public function getMemberClub_IsDefault() |
||
| 492 | |||
| 493 | /** |
||
| 494 | * @param boolean $MemberClub_IsDefault |
||
| 495 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 496 | */ |
||
| 497 | public function setMemberClub_IsDefault($MemberClub_IsDefault) |
||
| 502 | |||
| 503 | /** |
||
| 504 | * @return int |
||
| 505 | */ |
||
| 506 | public function getPropertyGUID() |
||
| 510 | |||
| 511 | /** |
||
| 512 | * @param int $PropertyGUID |
||
| 513 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 514 | */ |
||
| 515 | public function setPropertyGUID($PropertyGUID) |
||
| 520 | |||
| 521 | /** |
||
| 522 | * @return \DateTime |
||
| 523 | */ |
||
| 524 | public function getCreationDate() |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @param \DateTime $CreationDate |
||
| 539 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 540 | */ |
||
| 541 | public function setCreationDate(\DateTime $CreationDate) |
||
| 546 | |||
| 547 | /** |
||
| 548 | * @return int |
||
| 549 | */ |
||
| 550 | public function getID_MemberClubPoints() |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @param int $ID_MemberClubPoints |
||
| 557 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 558 | */ |
||
| 559 | public function setID_MemberClubPoints($ID_MemberClubPoints) |
||
| 564 | |||
| 565 | /** |
||
| 566 | * @return int |
||
| 567 | */ |
||
| 568 | public function getAccumTotal() |
||
| 572 | |||
| 573 | /** |
||
| 574 | * @param int $AccumTotal |
||
| 575 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 576 | */ |
||
| 577 | public function setAccumTotal($AccumTotal) |
||
| 582 | |||
| 583 | /** |
||
| 584 | * @return int |
||
| 585 | */ |
||
| 586 | public function getAccumYear() |
||
| 590 | |||
| 591 | /** |
||
| 592 | * @param int $AccumYear |
||
| 593 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 594 | */ |
||
| 595 | public function setAccumYear($AccumYear) |
||
| 600 | |||
| 601 | /** |
||
| 602 | * @return int |
||
| 603 | */ |
||
| 604 | public function getExpenseTotal() |
||
| 608 | |||
| 609 | /** |
||
| 610 | * @param int $ExpenseTotal |
||
| 611 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 612 | */ |
||
| 613 | public function setExpenseTotal($ExpenseTotal) |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @return \DateTime |
||
| 621 | */ |
||
| 622 | public function getSysModifDate() |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @param \DateTime $SysModifDate |
||
| 637 | * @return \Gueststream\PMS\IQWare\API\Loyalty |
||
| 638 | */ |
||
| 639 | public function setSysModifDate(\DateTime $SysModifDate) |
||
| 644 | } |
||
| 645 |
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..