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 |
||
| 23 | class SkiDataCard { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * SkiData card. |
||
| 27 | */ |
||
| 28 | use SkiDataCardTrait; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Article number. |
||
| 32 | * |
||
| 33 | * @var integer |
||
| 34 | */ |
||
| 35 | private $articleNumber; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Currency residual value. |
||
| 39 | * |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | private $currencyResidualValue; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Display text. |
||
| 46 | * |
||
| 47 | * @var boolean |
||
| 48 | */ |
||
| 49 | private $displayText; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Display text 1. |
||
| 53 | * |
||
| 54 | * @var string |
||
| 55 | */ |
||
| 56 | private $displayText1; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Display text 2. |
||
| 60 | * |
||
| 61 | * @var string |
||
| 62 | */ |
||
| 63 | private $displayText2; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Entry barrier closed. |
||
| 67 | * |
||
| 68 | * @var boolean |
||
| 69 | */ |
||
| 70 | private $entryBarrierClosed; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Exit barrier closed. |
||
| 74 | * |
||
| 75 | * @var boolean |
||
| 76 | */ |
||
| 77 | private $exitBarrierClosed; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Expires. |
||
| 81 | * |
||
| 82 | * @var DateTime |
||
| 83 | */ |
||
| 84 | private $expires; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Is neutral. |
||
| 88 | * |
||
| 89 | * @var boolean |
||
| 90 | */ |
||
| 91 | private $isNeutral; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Personnal no. |
||
| 95 | * |
||
| 96 | * @var integer |
||
| 97 | */ |
||
| 98 | private $personnalNo; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Production counter. |
||
| 102 | * |
||
| 103 | * @var integer |
||
| 104 | */ |
||
| 105 | private $productionCounter; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Production facility number. |
||
| 109 | * |
||
| 110 | * @var integer |
||
| 111 | */ |
||
| 112 | private $productionFacilityNumber; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Production state. |
||
| 116 | * |
||
| 117 | * @var integer |
||
| 118 | */ |
||
| 119 | private $productionState; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Reason for production. |
||
| 123 | * |
||
| 124 | * @var integer |
||
| 125 | */ |
||
| 126 | private $reasonProduction; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Residual value. |
||
| 130 | * |
||
| 131 | * @var integer |
||
| 132 | */ |
||
| 133 | private $residualValue; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Retain ticket at entry. |
||
| 137 | * |
||
| 138 | * @var boolean |
||
| 139 | */ |
||
| 140 | private $retainTicketEntry; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Retain ticket at exit. |
||
| 144 | * |
||
| 145 | * @var boolean |
||
| 146 | */ |
||
| 147 | private $retainTicketExit; |
||
| 148 | |||
| 149 | /** |
||
| 150 | * Serial no. |
||
| 151 | * |
||
| 152 | * @var string |
||
| 153 | */ |
||
| 154 | private $serialNo; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Serial number KeyCard/Swatch. |
||
| 158 | * |
||
| 159 | * @var string |
||
| 160 | */ |
||
| 161 | private $serialNumberKeyCardSwatch; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Suspend period from. |
||
| 165 | * |
||
| 166 | * @var DateTime |
||
| 167 | */ |
||
| 168 | private $suspendPeriodFrom; |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Suspend period until. |
||
| 172 | * |
||
| 173 | * @var DateTime |
||
| 174 | */ |
||
| 175 | private $suspendPeriodUntil; |
||
| 176 | |||
| 177 | /** |
||
| 178 | * SkiData ticket number. |
||
| 179 | * |
||
| 180 | * @var string |
||
| 181 | */ |
||
| 182 | private $ticketNumber; |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Ticket sub type. |
||
| 186 | * |
||
| 187 | * @var string |
||
| 188 | */ |
||
| 189 | private $ticketSubType; |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Ticket type. |
||
| 193 | * |
||
| 194 | * @var integer |
||
| 195 | */ |
||
| 196 | private $ticketType; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Use valid car parks. |
||
| 200 | * |
||
| 201 | * @var boolean |
||
| 202 | */ |
||
| 203 | private $useValidCarParks; |
||
| 204 | |||
| 205 | /** |
||
| 206 | * User number. |
||
| 207 | * |
||
| 208 | * @var integer |
||
| 209 | */ |
||
| 210 | private $userNumber; |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Valid from. |
||
| 214 | * |
||
| 215 | * @var DateTime |
||
| 216 | */ |
||
| 217 | private $validFrom; |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Constructor. |
||
| 221 | */ |
||
| 222 | public function __construct() { |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Get the article number. |
||
| 228 | * |
||
| 229 | * @return int Returns the article number. |
||
| 230 | */ |
||
| 231 | public function getArticleNumber() { |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Get the currency residual value. |
||
| 237 | * |
||
| 238 | * @return string Returns the currency residual value. |
||
| 239 | */ |
||
| 240 | public function getCurrencyResidualValue() { |
||
| 243 | |||
| 244 | /** |
||
| 245 | * Get the display text. |
||
| 246 | * |
||
| 247 | * @return bool Returns the display text. |
||
| 248 | */ |
||
| 249 | public function getDisplayText() { |
||
| 252 | |||
| 253 | /** |
||
| 254 | * Get the display text 1. |
||
| 255 | * |
||
| 256 | * @return string Returns the display text 1. |
||
| 257 | */ |
||
| 258 | public function getDisplayText1() { |
||
| 261 | |||
| 262 | /** |
||
| 263 | * Get the display text 2. |
||
| 264 | * |
||
| 265 | * @return string Returns the display text 2. |
||
| 266 | */ |
||
| 267 | public function getDisplayText2() { |
||
| 270 | |||
| 271 | /** |
||
| 272 | * Get the entry barrier closed. |
||
| 273 | * |
||
| 274 | * @return bool Returns the entry barrier closed. |
||
| 275 | */ |
||
| 276 | public function getEntryBarrierClosed() { |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Get the exit barrier closed. |
||
| 282 | * |
||
| 283 | * @return bool Returns the exit barrier closed. |
||
| 284 | */ |
||
| 285 | public function getExitBarrierClosed() { |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Get the expires. |
||
| 291 | * |
||
| 292 | * @return DateTime Returns the expires. |
||
| 293 | */ |
||
| 294 | public function getExpires() { |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Get the is neutral. |
||
| 300 | * |
||
| 301 | * @return bool Returns the is neutral. |
||
| 302 | */ |
||
| 303 | public function getNeutral() { |
||
| 306 | |||
| 307 | /** |
||
| 308 | * Get the personnal no. |
||
| 309 | * |
||
| 310 | * @return int Returns the personnal no. |
||
| 311 | */ |
||
| 312 | public function getPersonnalNo() { |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Get the production counter. |
||
| 318 | * |
||
| 319 | * @return int Returns the production counter. |
||
| 320 | */ |
||
| 321 | public function getProductionCounter() { |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Get the production facility number. |
||
| 327 | * |
||
| 328 | * @return int Returns the production facility number. |
||
| 329 | */ |
||
| 330 | public function getProductionFacilityNumber() { |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Get the production state. |
||
| 336 | * |
||
| 337 | * @return int Returns the production state. |
||
| 338 | */ |
||
| 339 | public function getProductionState() { |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Get the reason for production. |
||
| 345 | * |
||
| 346 | * @return int Returns the reason for production. |
||
| 347 | */ |
||
| 348 | public function getReasonProduction() { |
||
| 351 | |||
| 352 | /** |
||
| 353 | * Get the residual value. |
||
| 354 | * |
||
| 355 | * @return int Returns the residual value. |
||
| 356 | */ |
||
| 357 | public function getResidualValue() { |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Get the retain ticket at entry. |
||
| 363 | * |
||
| 364 | * @return bool Returns the retain ticket at entry. |
||
| 365 | */ |
||
| 366 | public function getRetainTicketEntry() { |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Get the retain ticket exit. |
||
| 372 | * |
||
| 373 | * @return bool Returns the retain ticket ax exit. |
||
| 374 | */ |
||
| 375 | public function getRetainTicketExit() { |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Get the serial no. |
||
| 381 | * |
||
| 382 | * @return string Returns the serial no. |
||
| 383 | */ |
||
| 384 | public function getSerialNo() { |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Get the serial number KeyCard/Swatch. |
||
| 390 | * |
||
| 391 | * @return string Returns the serial number KeyCard/Swatch. |
||
| 392 | */ |
||
| 393 | public function getSerialNumberKeyCardSwatch() { |
||
| 396 | |||
| 397 | /** |
||
| 398 | * Get the suspend period from. |
||
| 399 | * |
||
| 400 | * @return DateTime Returns the suspend period from. |
||
| 401 | */ |
||
| 402 | public function getSuspendPeriodFrom() { |
||
| 405 | |||
| 406 | /** |
||
| 407 | * Get the suspend period until. |
||
| 408 | * |
||
| 409 | * @return DateTime Returns the suspend period until. |
||
| 410 | */ |
||
| 411 | public function getSuspendPeriodUntil() { |
||
| 414 | |||
| 415 | /** |
||
| 416 | * Get the ticket number. |
||
| 417 | * |
||
| 418 | * @return string Returns the ticket number. |
||
| 419 | */ |
||
| 420 | public function getTicketNumber() { |
||
| 423 | |||
| 424 | /** |
||
| 425 | * Get the ticket sub type. |
||
| 426 | * |
||
| 427 | * @return string Returns the ticket sub type. |
||
| 428 | */ |
||
| 429 | public function getTicketSubType() { |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Get the ticket type. |
||
| 435 | * |
||
| 436 | * @return int Returns the ticket type. |
||
| 437 | */ |
||
| 438 | public function getTicketType() { |
||
| 441 | |||
| 442 | /** |
||
| 443 | * Get the use valid car parks. |
||
| 444 | * |
||
| 445 | * @return bool Returns the use valid car parks. |
||
| 446 | */ |
||
| 447 | public function getUseValidCarParks() { |
||
| 450 | |||
| 451 | /** |
||
| 452 | * Get the user number. |
||
| 453 | * |
||
| 454 | * @return int Returns the user number. |
||
| 455 | */ |
||
| 456 | public function getUserNumber() { |
||
| 459 | |||
| 460 | /** |
||
| 461 | * Get the valid from. |
||
| 462 | * |
||
| 463 | * @return DateTime Returns the valid from. |
||
| 464 | */ |
||
| 465 | public function getValidFrom() { |
||
| 468 | |||
| 469 | /** |
||
| 470 | * Set the article number. |
||
| 471 | * |
||
| 472 | * @param int $articleNumber The article number. |
||
| 473 | * @return SkiDataCard Returns this card entity. |
||
| 474 | */ |
||
| 475 | public function setArticleNumber($articleNumber) { |
||
| 479 | |||
| 480 | /** |
||
| 481 | * Set the currency residual value. |
||
| 482 | * |
||
| 483 | * @param string $currencyResidualValue The currency residual value. |
||
| 484 | * @return SkiDataCard Returns this card entity. |
||
| 485 | */ |
||
| 486 | public function setCurrencyResidualValue($currencyResidualValue) { |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Set the display text. |
||
| 493 | * |
||
| 494 | * @param bool $displayText The display text. |
||
| 495 | * @return SkiDataCard Returns this card entity. |
||
| 496 | */ |
||
| 497 | public function setDisplayText($displayText) { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Set the display text 1. |
||
| 504 | * |
||
| 505 | * @param string $displayText1 The display text 1. |
||
| 506 | * @return SkiDataCard Returns this card entity. |
||
| 507 | */ |
||
| 508 | public function setDisplayText1($displayText1) { |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Set the display text 2. |
||
| 515 | * |
||
| 516 | * @param string $displayText2 The display text 2. |
||
| 517 | * @return SkiDataCard Returns this card entity. |
||
| 518 | */ |
||
| 519 | public function setDisplayText2($displayText2) { |
||
| 523 | |||
| 524 | /** |
||
| 525 | * Set the entry barrier closed. |
||
| 526 | * |
||
| 527 | * @param bool $entryBarrierClosed The entry barrier closed. |
||
| 528 | * @return SkiDataCard Returns this card entity. |
||
| 529 | */ |
||
| 530 | public function setEntryBarrierClosed($entryBarrierClosed) { |
||
| 534 | |||
| 535 | /** |
||
| 536 | * Set the exit barrier closed. |
||
| 537 | * |
||
| 538 | * @param bool $exitBarrierClosed The exit barrier closed. |
||
| 539 | * @return SkiDataCard Returns this card entity. |
||
| 540 | */ |
||
| 541 | public function setExitBarrierClosed($exitBarrierClosed) { |
||
| 545 | |||
| 546 | /** |
||
| 547 | * Set the expires. |
||
| 548 | * |
||
| 549 | * @param DateTime $expires The expires. |
||
| 550 | * @return SkiDataCard Returns this card entity. |
||
| 551 | */ |
||
| 552 | public function setExpires(DateTime $expires = null) { |
||
| 556 | |||
| 557 | /** |
||
| 558 | * Set the is neutral. |
||
| 559 | * |
||
| 560 | * @param bool $isNeutral The is neutral. |
||
| 561 | * @return SkiDataCard Returns this card entity. |
||
| 562 | */ |
||
| 563 | public function setNeutral($isNeutral) { |
||
| 567 | |||
| 568 | /** |
||
| 569 | * Set the personnal no. |
||
| 570 | * |
||
| 571 | * @param int $personnalNo The personnal no. |
||
| 572 | * @return SkiDataCard Returns this card entity. |
||
| 573 | */ |
||
| 574 | public function setPersonnalNo($personnalNo) { |
||
| 578 | |||
| 579 | /** |
||
| 580 | * Set the production counter. |
||
| 581 | * |
||
| 582 | * @param int $productionCounter The production counter. |
||
| 583 | * @return SkiDataCard Returns this card entity. |
||
| 584 | */ |
||
| 585 | public function setProductionCounter($productionCounter) { |
||
| 589 | |||
| 590 | /** |
||
| 591 | * Set the production facility number. |
||
| 592 | * |
||
| 593 | * @param int $productionFacilityNumber The production facility number. |
||
| 594 | * @return SkiDataCard Returns this card entity. |
||
| 595 | */ |
||
| 596 | public function setProductionFacilityNumber($productionFacilityNumber) { |
||
| 600 | |||
| 601 | /** |
||
| 602 | * Set the production state. |
||
| 603 | * |
||
| 604 | * @param int $productionState The production state. |
||
| 605 | * @return SkiDataCard Returns this card entity. |
||
| 606 | */ |
||
| 607 | public function setProductionState($productionState) { |
||
| 611 | |||
| 612 | /** |
||
| 613 | * Set the reason for production. |
||
| 614 | * |
||
| 615 | * @param int $reasonProduction The reason for production. |
||
| 616 | * @return SkiDataCard Returns this card entity. |
||
| 617 | */ |
||
| 618 | public function setReasonProduction($reasonProduction) { |
||
| 622 | |||
| 623 | /** |
||
| 624 | * Set the residual value. |
||
| 625 | * |
||
| 626 | * @param int $residualValue The residual value. |
||
| 627 | * @return SkiDataCard Returns this card entity. |
||
| 628 | */ |
||
| 629 | public function setResidualValue($residualValue) { |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Set the retain ticket at entry. |
||
| 636 | * |
||
| 637 | * @param bool $retainTicketEntry The retain ticket at entry. |
||
| 638 | * @return SkiDataCard Returns this card entity. |
||
| 639 | */ |
||
| 640 | public function setRetainTicketEntry($retainTicketEntry) { |
||
| 644 | |||
| 645 | /** |
||
| 646 | * Set the retain ticket at exit. |
||
| 647 | * |
||
| 648 | * @param bool $retainTicketExit The retain ticket at exit. |
||
| 649 | * @return SkiDataCard Returns this card entity. |
||
| 650 | */ |
||
| 651 | public function setRetainTicketExit($retainTicketExit) { |
||
| 655 | |||
| 656 | /** |
||
| 657 | * Set the serial no. |
||
| 658 | * |
||
| 659 | * @param string $serialNo The serial no. |
||
| 660 | * @return SkiDataCard Returns this card entity. |
||
| 661 | */ |
||
| 662 | public function setSerialNo($serialNo) { |
||
| 666 | |||
| 667 | /** |
||
| 668 | * Set the serial number KeyCard/Swatch. |
||
| 669 | * |
||
| 670 | * @param string $serialNumberKeyCardSwatch The serial number KeyCard/Swatch. |
||
| 671 | * @return SkiDataCard Returns this card entity. |
||
| 672 | */ |
||
| 673 | public function setSerialNumberKeyCardSwatch($serialNumberKeyCardSwatch) { |
||
| 677 | |||
| 678 | /** |
||
| 679 | * Set the suspend period from. |
||
| 680 | * |
||
| 681 | * @param DateTime $suspendPeriodFrom The suspend period from. |
||
| 682 | * @return SkiDataCard Returns this card entity. |
||
| 683 | */ |
||
| 684 | public function setSuspendPeriodFrom(DateTime $suspendPeriodFrom = null) { |
||
| 688 | |||
| 689 | /** |
||
| 690 | * Set the suspend period until. |
||
| 691 | * |
||
| 692 | * @param DateTime $suspendPeriodUntil The suspend period until. |
||
| 693 | * @return SkiDataCard Returns this card entity. |
||
| 694 | */ |
||
| 695 | public function setSuspendPeriodUntil(DateTime $suspendPeriodUntil = null) { |
||
| 699 | |||
| 700 | /** |
||
| 701 | * Set the ticket number. |
||
| 702 | * |
||
| 703 | * @param string $ticketNumber The ticket number. |
||
| 704 | * @return SkiDataCard Returns this card entity. |
||
| 705 | */ |
||
| 706 | public function setTicketNumber($ticketNumber) { |
||
| 710 | |||
| 711 | /** |
||
| 712 | * Set the ticket sub type. |
||
| 713 | * |
||
| 714 | * @param string $ticketSubType The ticket sub type. |
||
| 715 | * @return SkiDataCard Returns this card entity. |
||
| 716 | */ |
||
| 717 | public function setTicketSubType($ticketSubType) { |
||
| 721 | |||
| 722 | /** |
||
| 723 | * Set the ticket type. |
||
| 724 | * |
||
| 725 | * @param int $ticketType The ticket type. |
||
| 726 | * @return SkiDataCard Returns this card entity. |
||
| 727 | */ |
||
| 728 | public function setTicketType($ticketType) { |
||
| 732 | |||
| 733 | /** |
||
| 734 | * Set the use valid car parks. |
||
| 735 | * |
||
| 736 | * @param bool $useValidCarParks The use valid car parks. |
||
| 737 | * @return SkiDataCard Returns this card entity. |
||
| 738 | */ |
||
| 739 | public function setUseValidCarParks($useValidCarParks) { |
||
| 743 | |||
| 744 | /** |
||
| 745 | * Set the user number. |
||
| 746 | * |
||
| 747 | * @param int $userNumber The user number. |
||
| 748 | * @return SkiDataCard Returns this card entity. |
||
| 749 | */ |
||
| 750 | public function setUserNumber($userNumber) { |
||
| 754 | |||
| 755 | /** |
||
| 756 | * Set the valid from. |
||
| 757 | * |
||
| 758 | * @param DateTime $validFrom The valid from. |
||
| 759 | * @return SkiDataCard Returns this card entity. |
||
| 760 | */ |
||
| 761 | public function setValidFrom(DateTime $validFrom = null) { |
||
| 765 | |||
| 766 | } |
||
| 767 |