Complex classes like AbstractType 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 AbstractType, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | abstract class AbstractType implements \JsonSerializable |
||
| 6 | { |
||
| 7 | /** @var \DateTimeImmutable */ |
||
| 8 | protected $ActiveEnterTimestamp; |
||
| 9 | |||
| 10 | /** @var integer */ |
||
| 11 | protected $ActiveEnterTimestampMonotonic; |
||
| 12 | |||
| 13 | /** @var integer */ |
||
| 14 | protected $ActiveExitTimestampMonotonic; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | protected $ActiveState; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var boolean |
||
| 23 | */ |
||
| 24 | protected $AllowIsolate; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var boolean |
||
| 28 | */ |
||
| 29 | protected $AssertResult; |
||
| 30 | |||
| 31 | /** @var \DateTimeImmutable */ |
||
| 32 | protected $AssertTimestamp; |
||
| 33 | |||
| 34 | /** @var integer */ |
||
| 35 | protected $AssertTimestampMonotonic; |
||
| 36 | |||
| 37 | /** @var array */ |
||
| 38 | protected $Before = []; |
||
| 39 | |||
| 40 | /** @var boolean */ |
||
| 41 | protected $CanIsolate; |
||
| 42 | |||
| 43 | /** @var boolean */ |
||
| 44 | protected $CanReload; |
||
| 45 | |||
| 46 | /** @var boolean */ |
||
| 47 | protected $CanStart; |
||
| 48 | |||
| 49 | /** @var boolean */ |
||
| 50 | protected $CanStop; |
||
| 51 | |||
| 52 | /** @var boolean */ |
||
| 53 | protected $ConditionResult; |
||
| 54 | |||
| 55 | /** @var \DateTimeImmutable */ |
||
| 56 | protected $ConditionTimestamp; |
||
| 57 | |||
| 58 | /** @var integer */ |
||
| 59 | protected $ConditionTimestampMonotonic; |
||
| 60 | |||
| 61 | /** @var boolean */ |
||
| 62 | protected $DefaultDependencies; |
||
| 63 | |||
| 64 | /** @var string */ |
||
| 65 | protected $Description; |
||
| 66 | |||
| 67 | /** @var string */ |
||
| 68 | protected $Id; |
||
| 69 | |||
| 70 | /** @var boolean */ |
||
| 71 | protected $IgnoreOnIsolate; |
||
| 72 | |||
| 73 | /** @var integer */ |
||
| 74 | protected $InactiveEnterTimestampMonotonic; |
||
| 75 | |||
| 76 | /** @var \DateTimeImmutable */ |
||
| 77 | protected $InactiveExitTimestamp; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var integer |
||
| 81 | */ |
||
| 82 | protected $InactiveExitTimestampMonotonic; |
||
| 83 | |||
| 84 | /** @var string */ |
||
| 85 | protected $InvocationID; |
||
| 86 | |||
| 87 | /** @var string */ |
||
| 88 | protected $JobTimeoutAction; |
||
| 89 | |||
| 90 | /** @var string */ |
||
| 91 | protected $JobTimeoutUSec; |
||
| 92 | |||
| 93 | /** @var string */ |
||
| 94 | protected $LoadError; |
||
| 95 | |||
| 96 | /** @var string */ |
||
| 97 | protected $LoadState; |
||
| 98 | |||
| 99 | /** @var array */ |
||
| 100 | protected $Names = []; |
||
| 101 | |||
| 102 | /** @var boolean */ |
||
| 103 | protected $NeedDaemonReload; |
||
| 104 | |||
| 105 | /** @var string */ |
||
| 106 | protected $OnFailureJobMode; |
||
| 107 | |||
| 108 | /** @var boolean */ |
||
| 109 | protected $Perpetual; |
||
| 110 | |||
| 111 | /** @var boolean */ |
||
| 112 | protected $RefuseManualStart; |
||
| 113 | |||
| 114 | /** @var boolean */ |
||
| 115 | protected $RefuseManualStop; |
||
| 116 | |||
| 117 | /** @var string */ |
||
| 118 | protected $StartLimitAction; |
||
| 119 | |||
| 120 | /** @var boolean */ |
||
| 121 | protected $StartLimitBurst; |
||
| 122 | |||
| 123 | /** @var integer */ |
||
| 124 | protected $StartLimitIntervalSec; |
||
| 125 | |||
| 126 | /** @var \DateTimeImmutable */ |
||
| 127 | protected $StateChangeTimestamp; |
||
| 128 | |||
| 129 | /** @var integer */ |
||
| 130 | protected $StateChangeTimestampMonotonic; |
||
| 131 | |||
| 132 | /** @var boolean */ |
||
| 133 | protected $StopWhenUnneeded; |
||
| 134 | |||
| 135 | /** @var string */ |
||
| 136 | protected $SubState; |
||
| 137 | |||
| 138 | /** @var boolean */ |
||
| 139 | protected $Transient; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @return \DateTimeImmutable |
||
| 143 | */ |
||
| 144 | public function getActiveEnterTimestamp(): \DateTimeImmutable |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param \DateTimeImmutable $ActiveEnterTimestamp |
||
| 151 | * @return AbstractType |
||
| 152 | */ |
||
| 153 | public function setActiveEnterTimestamp(\DateTimeImmutable $ActiveEnterTimestamp): AbstractType |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @return int |
||
| 161 | */ |
||
| 162 | public function getActiveEnterTimestampMonotonic(): int |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @param int $ActiveEnterTimestampMonotonic |
||
| 169 | * @return AbstractType |
||
| 170 | */ |
||
| 171 | public function setActiveEnterTimestampMonotonic(int $ActiveEnterTimestampMonotonic): AbstractType |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @return int |
||
| 179 | */ |
||
| 180 | public function getActiveExitTimestampMonotonic(): int |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @param int $ActiveExitTimestampMonotonic |
||
| 187 | * @return AbstractType |
||
| 188 | */ |
||
| 189 | public function setActiveExitTimestampMonotonic(int $ActiveExitTimestampMonotonic): AbstractType |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @return string |
||
| 197 | */ |
||
| 198 | public function getActiveState(): string |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @param string $ActiveState |
||
| 205 | * @return AbstractType |
||
| 206 | */ |
||
| 207 | public function setActiveState(string $ActiveState): AbstractType |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @return bool |
||
| 215 | */ |
||
| 216 | public function isAllowIsolate(): bool |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @param bool $AllowIsolate |
||
| 223 | * @return AbstractType |
||
| 224 | */ |
||
| 225 | public function setAllowIsolate(bool $AllowIsolate): AbstractType |
||
| 230 | |||
| 231 | /** |
||
| 232 | * @return bool |
||
| 233 | */ |
||
| 234 | public function isAssertResult(): bool |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @param bool $AssertResult |
||
| 241 | * @return AbstractType |
||
| 242 | */ |
||
| 243 | public function setAssertResult(bool $AssertResult): AbstractType |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @return \DateTimeImmutable |
||
| 251 | */ |
||
| 252 | public function getAssertTimestamp(): \DateTimeImmutable |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @param \DateTimeImmutable $AssertTimestamp |
||
| 259 | * @return AbstractType |
||
| 260 | */ |
||
| 261 | public function setAssertTimestamp(\DateTimeImmutable $AssertTimestamp): AbstractType |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @return int |
||
| 269 | */ |
||
| 270 | public function getAssertTimestampMonotonic(): int |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @param int $AssertTimestampMonotonic |
||
| 277 | * @return AbstractType |
||
| 278 | */ |
||
| 279 | public function setAssertTimestampMonotonic(int $AssertTimestampMonotonic): AbstractType |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @return array |
||
| 287 | */ |
||
| 288 | public function getBefore(): array |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @param array $Before |
||
| 295 | * @return AbstractType |
||
| 296 | */ |
||
| 297 | public function setBefore(array $Before): AbstractType |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @return bool |
||
| 305 | */ |
||
| 306 | public function isCanIsolate(): bool |
||
| 310 | |||
| 311 | /** |
||
| 312 | * @param bool $CanIsolate |
||
| 313 | * @return AbstractType |
||
| 314 | */ |
||
| 315 | public function setCanIsolate(bool $CanIsolate): AbstractType |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @return bool |
||
| 323 | */ |
||
| 324 | public function isCanReload(): bool |
||
| 328 | |||
| 329 | /** |
||
| 330 | * @param bool $CanReload |
||
| 331 | * @return AbstractType |
||
| 332 | */ |
||
| 333 | public function setCanReload(bool $CanReload): AbstractType |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return bool |
||
| 341 | */ |
||
| 342 | public function isCanStart(): bool |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @param bool $CanStart |
||
| 349 | * @return AbstractType |
||
| 350 | */ |
||
| 351 | public function setCanStart(bool $CanStart): AbstractType |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @return bool |
||
| 359 | */ |
||
| 360 | public function isCanStop(): bool |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @param bool $CanStop |
||
| 367 | * @return AbstractType |
||
| 368 | */ |
||
| 369 | public function setCanStop(bool $CanStop): AbstractType |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @return bool |
||
| 377 | */ |
||
| 378 | public function isConditionResult(): bool |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @param bool $ConditionResult |
||
| 385 | * @return AbstractType |
||
| 386 | */ |
||
| 387 | public function setConditionResult(bool $ConditionResult): AbstractType |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @return \DateTimeImmutable |
||
| 395 | */ |
||
| 396 | public function getConditionTimestamp(): \DateTimeImmutable |
||
| 400 | |||
| 401 | /** |
||
| 402 | * @param \DateTimeImmutable $ConditionTimestamp |
||
| 403 | * @return AbstractType |
||
| 404 | */ |
||
| 405 | public function setConditionTimestamp(\DateTimeImmutable $ConditionTimestamp): AbstractType |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @return int |
||
| 413 | */ |
||
| 414 | public function getConditionTimestampMonotonic(): int |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @param int $ConditionTimestampMonotonic |
||
| 421 | * @return AbstractType |
||
| 422 | */ |
||
| 423 | public function setConditionTimestampMonotonic(int $ConditionTimestampMonotonic): AbstractType |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @return bool |
||
| 431 | */ |
||
| 432 | public function isDefaultDependencies(): bool |
||
| 436 | |||
| 437 | /** |
||
| 438 | * @param bool $DefaultDependencies |
||
| 439 | * @return AbstractType |
||
| 440 | */ |
||
| 441 | public function setDefaultDependencies(bool $DefaultDependencies): AbstractType |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @return string |
||
| 449 | */ |
||
| 450 | public function getDescription(): string |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @param string $Description |
||
| 457 | * @return AbstractType |
||
| 458 | */ |
||
| 459 | public function setDescription(string $Description): AbstractType |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @return string |
||
| 467 | */ |
||
| 468 | public function getId(): string |
||
| 472 | |||
| 473 | /** |
||
| 474 | * @param string $Id |
||
| 475 | * @return AbstractType |
||
| 476 | */ |
||
| 477 | public function setId(string $Id): AbstractType |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @return bool |
||
| 485 | */ |
||
| 486 | public function isIgnoreOnIsolate(): bool |
||
| 490 | |||
| 491 | /** |
||
| 492 | * @param bool $IgnoreOnIsolate |
||
| 493 | * @return AbstractType |
||
| 494 | */ |
||
| 495 | public function setIgnoreOnIsolate(bool $IgnoreOnIsolate): AbstractType |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @return int |
||
| 503 | */ |
||
| 504 | public function getInactiveEnterTimestampMonotonic(): int |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @param int $InactiveEnterTimestampMonotonic |
||
| 511 | * @return AbstractType |
||
| 512 | */ |
||
| 513 | public function setInactiveEnterTimestampMonotonic(int $InactiveEnterTimestampMonotonic): AbstractType |
||
| 518 | |||
| 519 | /** |
||
| 520 | * @return \DateTimeImmutable |
||
| 521 | */ |
||
| 522 | public function getInactiveExitTimestamp(): \DateTimeImmutable |
||
| 526 | |||
| 527 | /** |
||
| 528 | * @param \DateTimeImmutable $InactiveExitTimestamp |
||
| 529 | * @return AbstractType |
||
| 530 | */ |
||
| 531 | public function setInactiveExitTimestamp(\DateTimeImmutable $InactiveExitTimestamp): AbstractType |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @return int |
||
| 539 | */ |
||
| 540 | public function getInactiveExitTimestampMonotonic(): int |
||
| 544 | |||
| 545 | /** |
||
| 546 | * @param int $InactiveExitTimestampMonotonic |
||
| 547 | * @return AbstractType |
||
| 548 | */ |
||
| 549 | public function setInactiveExitTimestampMonotonic(int $InactiveExitTimestampMonotonic): AbstractType |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @return string |
||
| 557 | */ |
||
| 558 | public function getInvocationID(): string |
||
| 562 | |||
| 563 | /** |
||
| 564 | * @param string $InvocationID |
||
| 565 | * @return AbstractType |
||
| 566 | */ |
||
| 567 | public function setInvocationID(string $InvocationID): AbstractType |
||
| 572 | |||
| 573 | /** |
||
| 574 | * @return string |
||
| 575 | */ |
||
| 576 | public function getJobTimeoutAction(): string |
||
| 580 | |||
| 581 | /** |
||
| 582 | * @param string $JobTimeoutAction |
||
| 583 | * @return AbstractType |
||
| 584 | */ |
||
| 585 | public function setJobTimeoutAction(string $JobTimeoutAction): AbstractType |
||
| 590 | |||
| 591 | /** |
||
| 592 | * @return string |
||
| 593 | */ |
||
| 594 | public function getJobTimeoutUSec(): string |
||
| 598 | |||
| 599 | /** |
||
| 600 | * @param string $JobTimeoutUSec |
||
| 601 | * @return AbstractType |
||
| 602 | */ |
||
| 603 | public function setJobTimeoutUSec(string $JobTimeoutUSec): AbstractType |
||
| 608 | |||
| 609 | /** |
||
| 610 | * @return string |
||
| 611 | */ |
||
| 612 | public function getLoadError(): string |
||
| 616 | |||
| 617 | /** |
||
| 618 | * @param string $LoadError |
||
| 619 | * @return AbstractType |
||
| 620 | */ |
||
| 621 | public function setLoadError(string $LoadError): AbstractType |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @return string |
||
| 629 | */ |
||
| 630 | public function getLoadState(): string |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @param string $LoadState |
||
| 637 | * @return AbstractType |
||
| 638 | */ |
||
| 639 | public function setLoadState(string $LoadState): AbstractType |
||
| 644 | |||
| 645 | /** |
||
| 646 | * @return array |
||
| 647 | */ |
||
| 648 | public function getNames(): array |
||
| 652 | |||
| 653 | /** |
||
| 654 | * @param array $Names |
||
| 655 | * @return AbstractType |
||
| 656 | */ |
||
| 657 | public function setNames(array $Names): AbstractType |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @return bool |
||
| 665 | */ |
||
| 666 | public function isNeedDaemonReload(): bool |
||
| 670 | |||
| 671 | /** |
||
| 672 | * @param bool $NeedDaemonReload |
||
| 673 | * @return AbstractType |
||
| 674 | */ |
||
| 675 | public function setNeedDaemonReload(bool $NeedDaemonReload): AbstractType |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @return string |
||
| 683 | */ |
||
| 684 | public function getOnFailureJobMode(): string |
||
| 688 | |||
| 689 | /** |
||
| 690 | * @param string $OnFailureJobMode |
||
| 691 | * @return AbstractType |
||
| 692 | */ |
||
| 693 | public function setOnFailureJobMode(string $OnFailureJobMode): AbstractType |
||
| 698 | |||
| 699 | /** |
||
| 700 | * @return bool |
||
| 701 | */ |
||
| 702 | public function isPerpetual(): bool |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @param bool $Perpetual |
||
| 709 | * @return AbstractType |
||
| 710 | */ |
||
| 711 | public function setPerpetual(bool $Perpetual): AbstractType |
||
| 716 | |||
| 717 | /** |
||
| 718 | * @return bool |
||
| 719 | */ |
||
| 720 | public function isRefuseManualStart(): bool |
||
| 724 | |||
| 725 | /** |
||
| 726 | * @param bool $RefuseManualStart |
||
| 727 | * @return AbstractType |
||
| 728 | */ |
||
| 729 | public function setRefuseManualStart(bool $RefuseManualStart): AbstractType |
||
| 734 | |||
| 735 | /** |
||
| 736 | * @return bool |
||
| 737 | */ |
||
| 738 | public function isRefuseManualStop(): bool |
||
| 742 | |||
| 743 | /** |
||
| 744 | * @param bool $RefuseManualStop |
||
| 745 | * @return AbstractType |
||
| 746 | */ |
||
| 747 | public function setRefuseManualStop(bool $RefuseManualStop): AbstractType |
||
| 752 | |||
| 753 | /** |
||
| 754 | * @return string |
||
| 755 | */ |
||
| 756 | public function getStartLimitAction(): string |
||
| 760 | |||
| 761 | /** |
||
| 762 | * @param string $StartLimitAction |
||
| 763 | * @return AbstractType |
||
| 764 | */ |
||
| 765 | public function setStartLimitAction(string $StartLimitAction): AbstractType |
||
| 770 | |||
| 771 | /** |
||
| 772 | * @return bool |
||
| 773 | */ |
||
| 774 | public function isStartLimitBurst(): bool |
||
| 778 | |||
| 779 | /** |
||
| 780 | * @param bool $StartLimitBurst |
||
| 781 | * @return AbstractType |
||
| 782 | */ |
||
| 783 | public function setStartLimitBurst(bool $StartLimitBurst): AbstractType |
||
| 788 | |||
| 789 | /** |
||
| 790 | * @return int |
||
| 791 | */ |
||
| 792 | public function getStartLimitIntervalSec(): int |
||
| 796 | |||
| 797 | /** |
||
| 798 | * @param int $StartLimitIntervalSec |
||
| 799 | * @return AbstractType |
||
| 800 | */ |
||
| 801 | public function setStartLimitIntervalSec(int $StartLimitIntervalSec): AbstractType |
||
| 806 | |||
| 807 | /** |
||
| 808 | * @return \DateTimeImmutable |
||
| 809 | */ |
||
| 810 | public function getStateChangeTimestamp(): \DateTimeImmutable |
||
| 814 | |||
| 815 | /** |
||
| 816 | * @param \DateTimeImmutable $StateChangeTimestamp |
||
| 817 | * @return AbstractType |
||
| 818 | */ |
||
| 819 | public function setStateChangeTimestamp(\DateTimeImmutable $StateChangeTimestamp): AbstractType |
||
| 824 | |||
| 825 | /** |
||
| 826 | * @return int |
||
| 827 | */ |
||
| 828 | public function getStateChangeTimestampMonotonic(): int |
||
| 832 | |||
| 833 | /** |
||
| 834 | * @param int $StateChangeTimestampMonotonic |
||
| 835 | * @return AbstractType |
||
| 836 | */ |
||
| 837 | public function setStateChangeTimestampMonotonic(int $StateChangeTimestampMonotonic): AbstractType |
||
| 842 | |||
| 843 | /** |
||
| 844 | * @return bool |
||
| 845 | */ |
||
| 846 | public function isStopWhenUnneeded(): bool |
||
| 850 | |||
| 851 | /** |
||
| 852 | * @param bool $StopWhenUnneeded |
||
| 853 | * @return AbstractType |
||
| 854 | */ |
||
| 855 | public function setStopWhenUnneeded(bool $StopWhenUnneeded): AbstractType |
||
| 860 | |||
| 861 | /** |
||
| 862 | * @return string |
||
| 863 | */ |
||
| 864 | public function getSubState(): string |
||
| 868 | |||
| 869 | /** |
||
| 870 | * @param string $SubState |
||
| 871 | * @return AbstractType |
||
| 872 | */ |
||
| 873 | public function setSubState(string $SubState): AbstractType |
||
| 878 | |||
| 879 | /** |
||
| 880 | * @return bool |
||
| 881 | */ |
||
| 882 | public function isTransient(): bool |
||
| 886 | |||
| 887 | /** |
||
| 888 | * @param bool $Transient |
||
| 889 | * @return AbstractType |
||
| 890 | */ |
||
| 891 | public function setTransient(bool $Transient): AbstractType |
||
| 896 | |||
| 897 | public function jsonSerialize() |
||
| 901 | } |
||
| 902 |