Complex classes like SkiDataCard 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 SkiDataCard, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 22 | class SkiDataCard { | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Article number. | ||
| 26 | * | ||
| 27 | * @var integer | ||
| 28 | */ | ||
| 29 | private $articleNumber; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Blocked. | ||
| 33 | * | ||
| 34 | * @var boolean | ||
| 35 | */ | ||
| 36 | private $blocked; | ||
| 37 | |||
| 38 | /** | ||
| 39 | * Blocked as of date. | ||
| 40 | * | ||
| 41 | * @var DateTime | ||
| 42 | */ | ||
| 43 | private $blockedDate; | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Currency residual value. | ||
| 47 | * | ||
| 48 | * @var string | ||
| 49 | */ | ||
| 50 | private $currencyResidualValue; | ||
| 51 | |||
| 52 | /** | ||
| 53 | * Display text. | ||
| 54 | * | ||
| 55 | * @var boolean | ||
| 56 | */ | ||
| 57 | private $displayText; | ||
| 58 | |||
| 59 | /** | ||
| 60 | * Display text 1. | ||
| 61 | * | ||
| 62 | * @var string | ||
| 63 | */ | ||
| 64 | private $displayText1; | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Display text 2. | ||
| 68 | * | ||
| 69 | * @var string | ||
| 70 | */ | ||
| 71 | private $displayText2; | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Entry barrier closed. | ||
| 75 | * | ||
| 76 | * @var boolean | ||
| 77 | */ | ||
| 78 | private $entryBarrierClosed; | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Exit barrier closed. | ||
| 82 | * | ||
| 83 | * @var boolean | ||
| 84 | */ | ||
| 85 | private $exitBarrierClosed; | ||
| 86 | |||
| 87 | /** | ||
| 88 | * Expires. | ||
| 89 | * | ||
| 90 | * @var DateTime | ||
| 91 | */ | ||
| 92 | private $expires; | ||
| 93 | |||
| 94 | /** | ||
| 95 | * Is neutral. | ||
| 96 | * | ||
| 97 | * @var boolean | ||
| 98 | */ | ||
| 99 | private $isNeutral; | ||
| 100 | |||
| 101 | /** | ||
| 102 | * Personnal no. | ||
| 103 | * | ||
| 104 | * @var integer | ||
| 105 | */ | ||
| 106 | private $personnalNo; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * Production counter. | ||
| 110 | * | ||
| 111 | * @var integer | ||
| 112 | */ | ||
| 113 | private $productionCounter; | ||
| 114 | |||
| 115 | /** | ||
| 116 | * Production facility number. | ||
| 117 | * | ||
| 118 | * @var integer | ||
| 119 | */ | ||
| 120 | private $productionFacilityNumber; | ||
| 121 | |||
| 122 | /** | ||
| 123 | * Production state. | ||
| 124 | * | ||
| 125 | * @var integer | ||
| 126 | */ | ||
| 127 | private $productionState; | ||
| 128 | |||
| 129 | /** | ||
| 130 | * Reason for production. | ||
| 131 | * | ||
| 132 | * @var integer | ||
| 133 | */ | ||
| 134 | private $reasonProduction; | ||
| 135 | |||
| 136 | /** | ||
| 137 | * Residual value. | ||
| 138 | * | ||
| 139 | * @var integer | ||
| 140 | */ | ||
| 141 | private $residualValue; | ||
| 142 | |||
| 143 | /** | ||
| 144 | * Retain ticket at entry. | ||
| 145 | * | ||
| 146 | * @var boolean | ||
| 147 | */ | ||
| 148 | private $retainTicketEntry; | ||
| 149 | |||
| 150 | /** | ||
| 151 | * Retain ticket at exit. | ||
| 152 | * | ||
| 153 | * @var boolean | ||
| 154 | */ | ||
| 155 | private $retainTicketExit; | ||
| 156 | |||
| 157 | /** | ||
| 158 | * Serial no. | ||
| 159 | * | ||
| 160 | * @var string | ||
| 161 | */ | ||
| 162 | private $serialNo; | ||
| 163 | |||
| 164 | /** | ||
| 165 | * Serial number KeyCard/Swatch. | ||
| 166 | * | ||
| 167 | * @var string | ||
| 168 | */ | ||
| 169 | private $serialNumberKeyCardSwatch; | ||
| 170 | |||
| 171 | /** | ||
| 172 | * Suspend period from. | ||
| 173 | * | ||
| 174 | * @var DateTime | ||
| 175 | */ | ||
| 176 | private $suspendPeriodFrom; | ||
| 177 | |||
| 178 | /** | ||
| 179 | * Suspend period until. | ||
| 180 | * | ||
| 181 | * @var DateTime | ||
| 182 | */ | ||
| 183 | private $suspendPeriodUntil; | ||
| 184 | |||
| 185 | /** | ||
| 186 | * SkiData ticket number. | ||
| 187 | * | ||
| 188 | * @var string | ||
| 189 | */ | ||
| 190 | private $ticketNumber; | ||
| 191 | |||
| 192 | /** | ||
| 193 | * Ticket sub type. | ||
| 194 | * | ||
| 195 | * @var string | ||
| 196 | */ | ||
| 197 | private $ticketSubType; | ||
| 198 | |||
| 199 | /** | ||
| 200 | * Ticket type. | ||
| 201 | * | ||
| 202 | * @var integer | ||
| 203 | */ | ||
| 204 | private $ticketType; | ||
| 205 | |||
| 206 | /** | ||
| 207 | * Use valid car parks. | ||
| 208 | * | ||
| 209 | * @var boolean | ||
| 210 | */ | ||
| 211 | private $useValidCarParks; | ||
| 212 | |||
| 213 | /** | ||
| 214 | * User number. | ||
| 215 | * | ||
| 216 | * @var integer | ||
| 217 | */ | ||
| 218 | private $userNumber; | ||
| 219 | |||
| 220 | /** | ||
| 221 | * Valid from. | ||
| 222 | * | ||
| 223 | * @var DateTime | ||
| 224 | */ | ||
| 225 | private $validFrom; | ||
| 226 | |||
| 227 | /** | ||
| 228 | * Constructor. | ||
| 229 | */ | ||
| 230 |     public function __construct() { | ||
| 233 | |||
| 234 | /** | ||
| 235 | * Get the article number. | ||
| 236 | * | ||
| 237 | * @return int Returns the article number. | ||
| 238 | */ | ||
| 239 |     public function getArticleNumber() { | ||
| 242 | |||
| 243 | /** | ||
| 244 | * Get the blocked. | ||
| 245 | * | ||
| 246 | * @return bool Returns the blocked. | ||
| 247 | */ | ||
| 248 |     public function getBlocked() { | ||
| 251 | |||
| 252 | /** | ||
| 253 | * Get the blocked as of date. | ||
| 254 | * | ||
| 255 | * @return DateTime Returns the blocked as of date. | ||
| 256 | */ | ||
| 257 |     public function getBlockedDate() { | ||
| 260 | |||
| 261 | /** | ||
| 262 | * Get the currency residual value. | ||
| 263 | * | ||
| 264 | * @return string Returns the currency residual value. | ||
| 265 | */ | ||
| 266 |     public function getCurrencyResidualValue() { | ||
| 269 | |||
| 270 | /** | ||
| 271 | * Get the display text. | ||
| 272 | * | ||
| 273 | * @return bool Returns the display text. | ||
| 274 | */ | ||
| 275 |     public function getDisplayText() { | ||
| 278 | |||
| 279 | /** | ||
| 280 | * Get the display text 1. | ||
| 281 | * | ||
| 282 | * @return string Returns the display text 1. | ||
| 283 | */ | ||
| 284 |     public function getDisplayText1() { | ||
| 287 | |||
| 288 | /** | ||
| 289 | * Get the display text 2. | ||
| 290 | * | ||
| 291 | * @return string Returns the display text 2. | ||
| 292 | */ | ||
| 293 |     public function getDisplayText2() { | ||
| 296 | |||
| 297 | /** | ||
| 298 | * Get the entry barrier closed. | ||
| 299 | * | ||
| 300 | * @return bool Returns the entry barrier closed. | ||
| 301 | */ | ||
| 302 |     public function getEntryBarrierClosed() { | ||
| 305 | |||
| 306 | /** | ||
| 307 | * Get the exit barrier closed. | ||
| 308 | * | ||
| 309 | * @return bool Returns the exit barrier closed. | ||
| 310 | */ | ||
| 311 |     public function getExitBarrierClosed() { | ||
| 314 | |||
| 315 | /** | ||
| 316 | * Get the expires. | ||
| 317 | * | ||
| 318 | * @return DateTime Returns the expires. | ||
| 319 | */ | ||
| 320 |     public function getExpires() { | ||
| 323 | |||
| 324 | /** | ||
| 325 | * Get the is neutral. | ||
| 326 | * | ||
| 327 | * @return bool Returns the is neutral. | ||
| 328 | */ | ||
| 329 |     public function getNeutral() { | ||
| 332 | |||
| 333 | /** | ||
| 334 | * Get the personnal no. | ||
| 335 | * | ||
| 336 | * @return int Returns the personnal no. | ||
| 337 | */ | ||
| 338 |     public function getPersonnalNo() { | ||
| 341 | |||
| 342 | /** | ||
| 343 | * Get the production counter. | ||
| 344 | * | ||
| 345 | * @return int Returns the production counter. | ||
| 346 | */ | ||
| 347 |     public function getProductionCounter() { | ||
| 350 | |||
| 351 | /** | ||
| 352 | * Get the production facility number. | ||
| 353 | * | ||
| 354 | * @return int Returns the production facility number. | ||
| 355 | */ | ||
| 356 |     public function getProductionFacilityNumber() { | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Get the production state. | ||
| 362 | * | ||
| 363 | * @return int Returns the production state. | ||
| 364 | */ | ||
| 365 |     public function getProductionState() { | ||
| 368 | |||
| 369 | /** | ||
| 370 | * Get the reason for production. | ||
| 371 | * | ||
| 372 | * @return int Returns the reason for production. | ||
| 373 | */ | ||
| 374 |     public function getReasonProduction() { | ||
| 377 | |||
| 378 | /** | ||
| 379 | * Get the residual value. | ||
| 380 | * | ||
| 381 | * @return int Returns the residual value. | ||
| 382 | */ | ||
| 383 |     public function getResidualValue() { | ||
| 386 | |||
| 387 | /** | ||
| 388 | * Get the retain ticket at entry. | ||
| 389 | * | ||
| 390 | * @return bool Returns the retain ticket at entry. | ||
| 391 | */ | ||
| 392 |     public function getRetainTicketEntry() { | ||
| 395 | |||
| 396 | /** | ||
| 397 | * Get the retain ticket exit. | ||
| 398 | * | ||
| 399 | * @return bool Returns the retain ticket ax exit. | ||
| 400 | */ | ||
| 401 |     public function getRetainTicketExit() { | ||
| 404 | |||
| 405 | /** | ||
| 406 | * Get the serial no. | ||
| 407 | * | ||
| 408 | * @return string Returns the serial no. | ||
| 409 | */ | ||
| 410 |     public function getSerialNo() { | ||
| 413 | |||
| 414 | /** | ||
| 415 | * Get the serial number KeyCard/Swatch. | ||
| 416 | * | ||
| 417 | * @return string Returns the serial number KeyCard/Swatch. | ||
| 418 | */ | ||
| 419 |     public function getSerialNumberKeyCardSwatch() { | ||
| 422 | |||
| 423 | /** | ||
| 424 | * Get the suspend period from. | ||
| 425 | * | ||
| 426 | * @return DateTime Returns the suspend period from. | ||
| 427 | */ | ||
| 428 |     public function getSuspendPeriodFrom() { | ||
| 431 | |||
| 432 | /** | ||
| 433 | * Get the suspend period until. | ||
| 434 | * | ||
| 435 | * @return DateTime Returns the suspend period until. | ||
| 436 | */ | ||
| 437 |     public function getSuspendPeriodUntil() { | ||
| 440 | |||
| 441 | /** | ||
| 442 | * Get the ticket number. | ||
| 443 | * | ||
| 444 | * @return string Returns the ticket number. | ||
| 445 | */ | ||
| 446 |     public function getTicketNumber() { | ||
| 449 | |||
| 450 | /** | ||
| 451 | * Get the ticket sub type. | ||
| 452 | * | ||
| 453 | * @return string Returns the ticket sub type. | ||
| 454 | */ | ||
| 455 |     public function getTicketSubType() { | ||
| 458 | |||
| 459 | /** | ||
| 460 | * Get the ticket type. | ||
| 461 | * | ||
| 462 | * @return int Returns the ticket type. | ||
| 463 | */ | ||
| 464 |     public function getTicketType() { | ||
| 467 | |||
| 468 | /** | ||
| 469 | * Get the use valid car parks. | ||
| 470 | * | ||
| 471 | * @return bool Returns the use valid car parks. | ||
| 472 | */ | ||
| 473 |     public function getUseValidCarParks() { | ||
| 476 | |||
| 477 | /** | ||
| 478 | * Get the user number. | ||
| 479 | * | ||
| 480 | * @return int Returns the user number. | ||
| 481 | */ | ||
| 482 |     public function getUserNumber() { | ||
| 485 | |||
| 486 | /** | ||
| 487 | * Get the valid from. | ||
| 488 | * | ||
| 489 | * @return DateTime Returns the valid from. | ||
| 490 | */ | ||
| 491 |     public function getValidFrom() { | ||
| 494 | |||
| 495 | /** | ||
| 496 | * Set the article number. | ||
| 497 | * | ||
| 498 | * @param int $articleNumber The article number. | ||
| 499 | * @return SkiDataCard Returns this card entity. | ||
| 500 | */ | ||
| 501 |     public function setArticleNumber($articleNumber) { | ||
| 505 | |||
| 506 | /** | ||
| 507 | * Set the blocked. | ||
| 508 | * | ||
| 509 | * @param bool $blocked The blocked. | ||
| 510 | * @return SkiDataCard Returns this card entity. | ||
| 511 | */ | ||
| 512 |     public function setBlocked($blocked) { | ||
| 516 | |||
| 517 | /** | ||
| 518 | * Set the blocked as of date. | ||
| 519 | * | ||
| 520 | * @param DateTime $blockedDate The blocked as of date. | ||
| 521 | * @return SkiDataCard Returns this card entity. | ||
| 522 | */ | ||
| 523 |     public function setBlockedDate(DateTime $blockedDate = null) { | ||
| 527 | |||
| 528 | /** | ||
| 529 | * Set the currency residual value. | ||
| 530 | * | ||
| 531 | * @param string $currencyResidualValue The currency residual value. | ||
| 532 | * @return SkiDataCard Returns this card entity. | ||
| 533 | */ | ||
| 534 |     public function setCurrencyResidualValue($currencyResidualValue) { | ||
| 538 | |||
| 539 | /** | ||
| 540 | * Set the display text. | ||
| 541 | * | ||
| 542 | * @param bool $displayText The display text. | ||
| 543 | * @return SkiDataCard Returns this card entity. | ||
| 544 | */ | ||
| 545 |     public function setDisplayText($displayText) { | ||
| 549 | |||
| 550 | /** | ||
| 551 | * Set the display text 1. | ||
| 552 | * | ||
| 553 | * @param string $displayText1 The display text 1. | ||
| 554 | * @return SkiDataCard Returns this card entity. | ||
| 555 | */ | ||
| 556 |     public function setDisplayText1($displayText1) { | ||
| 560 | |||
| 561 | /** | ||
| 562 | * Set the display text 2. | ||
| 563 | * | ||
| 564 | * @param string $displayText2 The display text 2. | ||
| 565 | * @return SkiDataCard Returns this card entity. | ||
| 566 | */ | ||
| 567 |     public function setDisplayText2($displayText2) { | ||
| 571 | |||
| 572 | /** | ||
| 573 | * Set the entry barrier closed. | ||
| 574 | * | ||
| 575 | * @param bool $entryBarrierClosed The entry barrier closed. | ||
| 576 | * @return SkiDataCard Returns this card entity. | ||
| 577 | */ | ||
| 578 |     public function setEntryBarrierClosed($entryBarrierClosed) { | ||
| 582 | |||
| 583 | /** | ||
| 584 | * Set the exit barrier closed. | ||
| 585 | * | ||
| 586 | * @param bool $exitBarrierClosed The exit barrier closed. | ||
| 587 | * @return SkiDataCard Returns this card entity. | ||
| 588 | */ | ||
| 589 |     public function setExitBarrierClosed($exitBarrierClosed) { | ||
| 593 | |||
| 594 | /** | ||
| 595 | * Set the expires. | ||
| 596 | * | ||
| 597 | * @param DateTime $expires The expires. | ||
| 598 | * @return SkiDataCard Returns this card entity. | ||
| 599 | */ | ||
| 600 |     public function setExpires(DateTime $expires = null) { | ||
| 604 | |||
| 605 | /** | ||
| 606 | * Set the is neutral. | ||
| 607 | * | ||
| 608 | * @param bool $isNeutral The is neutral. | ||
| 609 | * @return SkiDataCard Returns this card entity. | ||
| 610 | */ | ||
| 611 |     public function setNeutral($isNeutral) { | ||
| 615 | |||
| 616 | /** | ||
| 617 | * Set the personnal no. | ||
| 618 | * | ||
| 619 | * @param int $personnalNo The personnal no. | ||
| 620 | * @return SkiDataCard Returns this card entity. | ||
| 621 | */ | ||
| 622 |     public function setPersonnalNo($personnalNo) { | ||
| 626 | |||
| 627 | /** | ||
| 628 | * Set the production counter. | ||
| 629 | * | ||
| 630 | * @param int $productionCounter The production counter. | ||
| 631 | * @return SkiDataCard Returns this card entity. | ||
| 632 | */ | ||
| 633 |     public function setProductionCounter($productionCounter) { | ||
| 637 | |||
| 638 | /** | ||
| 639 | * Set the production facility number. | ||
| 640 | * | ||
| 641 | * @param int $productionFacilityNumber The production facility number. | ||
| 642 | * @return SkiDataCard Returns this card entity. | ||
| 643 | */ | ||
| 644 |     public function setProductionFacilityNumber($productionFacilityNumber) { | ||
| 648 | |||
| 649 | /** | ||
| 650 | * Set the production state. | ||
| 651 | * | ||
| 652 | * @param int $productionState The production state. | ||
| 653 | * @return SkiDataCard Returns this card entity. | ||
| 654 | */ | ||
| 655 |     public function setProductionState($productionState) { | ||
| 659 | |||
| 660 | /** | ||
| 661 | * Set the reason for production. | ||
| 662 | * | ||
| 663 | * @param int $reasonProduction The reason for production. | ||
| 664 | * @return SkiDataCard Returns this card entity. | ||
| 665 | */ | ||
| 666 |     public function setReasonProduction($reasonProduction) { | ||
| 670 | |||
| 671 | /** | ||
| 672 | * Set the residual value. | ||
| 673 | * | ||
| 674 | * @param int $residualValue The residual value. | ||
| 675 | * @return SkiDataCard Returns this card entity. | ||
| 676 | */ | ||
| 677 |     public function setResidualValue($residualValue) { | ||
| 681 | |||
| 682 | /** | ||
| 683 | * Set the retain ticket at entry. | ||
| 684 | * | ||
| 685 | * @param bool $retainTicketEntry The retain ticket at entry. | ||
| 686 | * @return SkiDataCard Returns this card entity. | ||
| 687 | */ | ||
| 688 |     public function setRetainTicketEntry($retainTicketEntry) { | ||
| 692 | |||
| 693 | /** | ||
| 694 | * Set the retain ticket at exit. | ||
| 695 | * | ||
| 696 | * @param bool $retainTicketExit The retain ticket at exit. | ||
| 697 | * @return SkiDataCard Returns this card entity. | ||
| 698 | */ | ||
| 699 |     public function setRetainTicketExit($retainTicketExit) { | ||
| 703 | |||
| 704 | /** | ||
| 705 | * Set the serial no. | ||
| 706 | * | ||
| 707 | * @param string $serialNo The serial no. | ||
| 708 | * @return SkiDataCard Returns this card entity. | ||
| 709 | */ | ||
| 710 |     public function setSerialNo($serialNo) { | ||
| 714 | |||
| 715 | /** | ||
| 716 | * Set the serial number KeyCard/Swatch. | ||
| 717 | * | ||
| 718 | * @param string $serialNumberKeyCardSwatch The serial number KeyCard/Swatch. | ||
| 719 | * @return SkiDataCard Returns this card entity. | ||
| 720 | */ | ||
| 721 |     public function setSerialNumberKeyCardSwatch($serialNumberKeyCardSwatch) { | ||
| 725 | |||
| 726 | /** | ||
| 727 | * Set the suspend period from. | ||
| 728 | * | ||
| 729 | * @param DateTime $suspendPeriodFrom The suspend period from. | ||
| 730 | * @return SkiDataCard Returns this card entity. | ||
| 731 | */ | ||
| 732 |     public function setSuspendPeriodFrom(DateTime $suspendPeriodFrom = null) { | ||
| 736 | |||
| 737 | /** | ||
| 738 | * Set the suspend period until. | ||
| 739 | * | ||
| 740 | * @param DateTime $suspendPeriodUntil The suspend period until. | ||
| 741 | * @return SkiDataCard Returns this card entity. | ||
| 742 | */ | ||
| 743 |     public function setSuspendPeriodUntil(DateTime $suspendPeriodUntil = null) { | ||
| 747 | |||
| 748 | /** | ||
| 749 | * Set the ticket number. | ||
| 750 | * | ||
| 751 | * @param string $ticketNumber The ticket number. | ||
| 752 | * @return SkiDataCard Returns this card entity. | ||
| 753 | */ | ||
| 754 |     public function setTicketNumber($ticketNumber) { | ||
| 758 | |||
| 759 | /** | ||
| 760 | * Set the ticket sub type. | ||
| 761 | * | ||
| 762 | * @param string $ticketSubType The ticket sub type. | ||
| 763 | * @return SkiDataCard Returns this card entity. | ||
| 764 | */ | ||
| 765 |     public function setTicketSubType($ticketSubType) { | ||
| 769 | |||
| 770 | /** | ||
| 771 | * Set the ticket type. | ||
| 772 | * | ||
| 773 | * @param int $ticketType The ticket type. | ||
| 774 | * @return SkiDataCard Returns this card entity. | ||
| 775 | */ | ||
| 776 |     public function setTicketType($ticketType) { | ||
| 780 | |||
| 781 | /** | ||
| 782 | * Set the use valid car parks. | ||
| 783 | * | ||
| 784 | * @param bool $useValidCarParks The use valid car parks. | ||
| 785 | * @return SkiDataCard Returns this card entity. | ||
| 786 | */ | ||
| 787 |     public function setUseValidCarParks($useValidCarParks) { | ||
| 791 | |||
| 792 | /** | ||
| 793 | * Set the user number. | ||
| 794 | * | ||
| 795 | * @param int $userNumber The user number. | ||
| 796 | * @return SkiDataCard Returns this card entity. | ||
| 797 | */ | ||
| 798 |     public function setUserNumber($userNumber) { | ||
| 802 | |||
| 803 | /** | ||
| 804 | * Set the valid from. | ||
| 805 | * | ||
| 806 | * @param DateTime $validFrom The valid from. | ||
| 807 | * @return SkiDataCard Returns this card entity. | ||
| 808 | */ | ||
| 809 |     public function setValidFrom(DateTime $validFrom = null) { | ||
| 813 | |||
| 814 | } | ||
| 815 |