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 | /** @var integer */ |
||
80 | protected $InactiveExitTimestampMonotonic; |
||
81 | |||
82 | /** @var string */ |
||
83 | protected $InvocationID; |
||
84 | |||
85 | /** @var string */ |
||
86 | protected $JobTimeoutAction; |
||
87 | |||
88 | /** @var string */ |
||
89 | protected $JobTimeoutUSec; |
||
90 | |||
91 | /** @var string */ |
||
92 | protected $LoadError; |
||
93 | |||
94 | /** @var string */ |
||
95 | protected $LoadState; |
||
96 | |||
97 | /** @var array */ |
||
98 | protected $Names = []; |
||
99 | |||
100 | /** @var boolean */ |
||
101 | protected $NeedDaemonReload; |
||
102 | |||
103 | /** @var string */ |
||
104 | protected $OnFailureJobMode; |
||
105 | |||
106 | /** @var boolean */ |
||
107 | protected $Perpetual; |
||
108 | |||
109 | /** @var boolean */ |
||
110 | protected $RefuseManualStart; |
||
111 | |||
112 | /** @var boolean */ |
||
113 | protected $RefuseManualStop; |
||
114 | |||
115 | /** @var string */ |
||
116 | protected $StartLimitAction; |
||
117 | |||
118 | /** @var boolean */ |
||
119 | protected $StartLimitBurst; |
||
120 | |||
121 | /** @var integer */ |
||
122 | protected $StartLimitInterval; |
||
123 | |||
124 | /** @var integer */ |
||
125 | protected $StartLimitIntervalSec; |
||
126 | |||
127 | /** @var \DateTimeImmutable */ |
||
128 | protected $StateChangeTimestamp; |
||
129 | |||
130 | /** @var integer */ |
||
131 | protected $StateChangeTimestampMonotonic; |
||
132 | |||
133 | /** @var boolean */ |
||
134 | protected $StopWhenUnneeded; |
||
135 | |||
136 | /** @var string */ |
||
137 | protected $SubState; |
||
138 | |||
139 | /** @var boolean */ |
||
140 | protected $Transient; |
||
141 | |||
142 | /** |
||
143 | * @return \DateTimeImmutable |
||
144 | */ |
||
145 | public function getActiveEnterTimestamp(): \DateTimeImmutable |
||
149 | |||
150 | /** |
||
151 | * @param \DateTimeImmutable $ActiveEnterTimestamp |
||
152 | * @return AbstractType |
||
153 | */ |
||
154 | public function setActiveEnterTimestamp(\DateTimeImmutable $ActiveEnterTimestamp): AbstractType |
||
159 | |||
160 | /** |
||
161 | * @return int |
||
162 | */ |
||
163 | public function getActiveEnterTimestampMonotonic(): int |
||
167 | |||
168 | /** |
||
169 | * @param int $ActiveEnterTimestampMonotonic |
||
170 | * @return AbstractType |
||
171 | */ |
||
172 | public function setActiveEnterTimestampMonotonic(int $ActiveEnterTimestampMonotonic): AbstractType |
||
177 | |||
178 | /** |
||
179 | * @return int |
||
180 | */ |
||
181 | public function getActiveExitTimestampMonotonic(): int |
||
185 | |||
186 | /** |
||
187 | * @param int $ActiveExitTimestampMonotonic |
||
188 | * @return AbstractType |
||
189 | */ |
||
190 | public function setActiveExitTimestampMonotonic(int $ActiveExitTimestampMonotonic): AbstractType |
||
195 | |||
196 | /** |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getActiveState(): string |
||
203 | |||
204 | /** |
||
205 | * @param string $ActiveState |
||
206 | * @return AbstractType |
||
207 | */ |
||
208 | public function setActiveState(string $ActiveState): AbstractType |
||
213 | |||
214 | /** |
||
215 | * @return bool |
||
216 | */ |
||
217 | public function isAllowIsolate(): bool |
||
221 | |||
222 | /** |
||
223 | * @param bool $AllowIsolate |
||
224 | * @return AbstractType |
||
225 | */ |
||
226 | public function setAllowIsolate(bool $AllowIsolate): AbstractType |
||
231 | |||
232 | /** |
||
233 | * @return bool |
||
234 | */ |
||
235 | public function isAssertResult(): bool |
||
239 | |||
240 | /** |
||
241 | * @param bool $AssertResult |
||
242 | * @return AbstractType |
||
243 | */ |
||
244 | public function setAssertResult(bool $AssertResult): AbstractType |
||
249 | |||
250 | /** |
||
251 | * @return \DateTimeImmutable |
||
252 | */ |
||
253 | public function getAssertTimestamp(): \DateTimeImmutable |
||
257 | |||
258 | /** |
||
259 | * @param \DateTimeImmutable $AssertTimestamp |
||
260 | * @return AbstractType |
||
261 | */ |
||
262 | public function setAssertTimestamp(\DateTimeImmutable $AssertTimestamp): AbstractType |
||
267 | |||
268 | /** |
||
269 | * @return int |
||
270 | */ |
||
271 | public function getAssertTimestampMonotonic(): int |
||
275 | |||
276 | /** |
||
277 | * @param int $AssertTimestampMonotonic |
||
278 | * @return AbstractType |
||
279 | */ |
||
280 | public function setAssertTimestampMonotonic(int $AssertTimestampMonotonic): AbstractType |
||
285 | |||
286 | /** |
||
287 | * @return array |
||
288 | */ |
||
289 | public function getBefore(): array |
||
293 | |||
294 | /** |
||
295 | * @param array $Before |
||
296 | * @return AbstractType |
||
297 | */ |
||
298 | public function setBefore(array $Before): AbstractType |
||
303 | |||
304 | /** |
||
305 | * @return bool |
||
306 | */ |
||
307 | public function isCanIsolate(): bool |
||
311 | |||
312 | /** |
||
313 | * @param bool $CanIsolate |
||
314 | * @return AbstractType |
||
315 | */ |
||
316 | public function setCanIsolate(bool $CanIsolate): AbstractType |
||
321 | |||
322 | /** |
||
323 | * @return bool |
||
324 | */ |
||
325 | public function isCanReload(): bool |
||
329 | |||
330 | /** |
||
331 | * @param bool $CanReload |
||
332 | * @return AbstractType |
||
333 | */ |
||
334 | public function setCanReload(bool $CanReload): AbstractType |
||
339 | |||
340 | /** |
||
341 | * @return bool |
||
342 | */ |
||
343 | public function isCanStart(): bool |
||
347 | |||
348 | /** |
||
349 | * @param bool $CanStart |
||
350 | * @return AbstractType |
||
351 | */ |
||
352 | public function setCanStart(bool $CanStart): AbstractType |
||
357 | |||
358 | /** |
||
359 | * @return bool |
||
360 | */ |
||
361 | public function isCanStop(): bool |
||
365 | |||
366 | /** |
||
367 | * @param bool $CanStop |
||
368 | * @return AbstractType |
||
369 | */ |
||
370 | public function setCanStop(bool $CanStop): AbstractType |
||
375 | |||
376 | /** |
||
377 | * @return bool |
||
378 | */ |
||
379 | public function isConditionResult(): bool |
||
383 | |||
384 | /** |
||
385 | * @param bool $ConditionResult |
||
386 | * @return AbstractType |
||
387 | */ |
||
388 | public function setConditionResult(bool $ConditionResult): AbstractType |
||
393 | |||
394 | /** |
||
395 | * @return \DateTimeImmutable |
||
396 | */ |
||
397 | public function getConditionTimestamp(): \DateTimeImmutable |
||
401 | |||
402 | /** |
||
403 | * @param \DateTimeImmutable $ConditionTimestamp |
||
404 | * @return AbstractType |
||
405 | */ |
||
406 | public function setConditionTimestamp(\DateTimeImmutable $ConditionTimestamp): AbstractType |
||
411 | |||
412 | /** |
||
413 | * @return int |
||
414 | */ |
||
415 | public function getConditionTimestampMonotonic(): int |
||
419 | |||
420 | /** |
||
421 | * @param int $ConditionTimestampMonotonic |
||
422 | * @return AbstractType |
||
423 | */ |
||
424 | public function setConditionTimestampMonotonic(int $ConditionTimestampMonotonic): AbstractType |
||
429 | |||
430 | /** |
||
431 | * @return bool |
||
432 | */ |
||
433 | public function isDefaultDependencies(): bool |
||
437 | |||
438 | /** |
||
439 | * @param bool $DefaultDependencies |
||
440 | * @return AbstractType |
||
441 | */ |
||
442 | public function setDefaultDependencies(bool $DefaultDependencies): AbstractType |
||
447 | |||
448 | /** |
||
449 | * @return string |
||
450 | */ |
||
451 | public function getDescription(): string |
||
455 | |||
456 | /** |
||
457 | * @param string $Description |
||
458 | * @return AbstractType |
||
459 | */ |
||
460 | public function setDescription(string $Description): AbstractType |
||
465 | |||
466 | /** |
||
467 | * @return string |
||
468 | */ |
||
469 | public function getId(): string |
||
473 | |||
474 | /** |
||
475 | * @param string $Id |
||
476 | * @return AbstractType |
||
477 | */ |
||
478 | public function setId(string $Id): AbstractType |
||
483 | |||
484 | /** |
||
485 | * @return bool |
||
486 | */ |
||
487 | public function isIgnoreOnIsolate(): bool |
||
491 | |||
492 | /** |
||
493 | * @param bool $IgnoreOnIsolate |
||
494 | * @return AbstractType |
||
495 | */ |
||
496 | public function setIgnoreOnIsolate(bool $IgnoreOnIsolate): AbstractType |
||
501 | |||
502 | /** |
||
503 | * @return int |
||
504 | */ |
||
505 | public function getInactiveEnterTimestampMonotonic(): int |
||
509 | |||
510 | /** |
||
511 | * @param int $InactiveEnterTimestampMonotonic |
||
512 | * @return AbstractType |
||
513 | */ |
||
514 | public function setInactiveEnterTimestampMonotonic(int $InactiveEnterTimestampMonotonic): AbstractType |
||
519 | |||
520 | /** |
||
521 | * @return \DateTimeImmutable |
||
522 | */ |
||
523 | public function getInactiveExitTimestamp(): \DateTimeImmutable |
||
527 | |||
528 | /** |
||
529 | * @param \DateTimeImmutable $InactiveExitTimestamp |
||
530 | * @return AbstractType |
||
531 | */ |
||
532 | public function setInactiveExitTimestamp(\DateTimeImmutable $InactiveExitTimestamp): AbstractType |
||
537 | |||
538 | /** |
||
539 | * @return int |
||
540 | */ |
||
541 | public function getInactiveExitTimestampMonotonic(): int |
||
545 | |||
546 | /** |
||
547 | * @param int $InactiveExitTimestampMonotonic |
||
548 | * @return AbstractType |
||
549 | */ |
||
550 | public function setInactiveExitTimestampMonotonic(int $InactiveExitTimestampMonotonic): AbstractType |
||
555 | |||
556 | /** |
||
557 | * @return string |
||
558 | */ |
||
559 | public function getInvocationID(): string |
||
563 | |||
564 | /** |
||
565 | * @param string $InvocationID |
||
566 | * @return AbstractType |
||
567 | */ |
||
568 | public function setInvocationID(string $InvocationID): AbstractType |
||
573 | |||
574 | /** |
||
575 | * @return string |
||
576 | */ |
||
577 | public function getJobTimeoutAction(): string |
||
581 | |||
582 | /** |
||
583 | * @param string $JobTimeoutAction |
||
584 | * @return AbstractType |
||
585 | */ |
||
586 | public function setJobTimeoutAction(string $JobTimeoutAction): AbstractType |
||
591 | |||
592 | /** |
||
593 | * @return string |
||
594 | */ |
||
595 | public function getJobTimeoutUSec(): string |
||
599 | |||
600 | /** |
||
601 | * @param string $JobTimeoutUSec |
||
602 | * @return AbstractType |
||
603 | */ |
||
604 | public function setJobTimeoutUSec(string $JobTimeoutUSec): AbstractType |
||
609 | |||
610 | /** |
||
611 | * @return string |
||
612 | */ |
||
613 | public function getLoadError(): string |
||
617 | |||
618 | /** |
||
619 | * @param string $LoadError |
||
620 | * @return AbstractType |
||
621 | */ |
||
622 | public function setLoadError(string $LoadError): AbstractType |
||
627 | |||
628 | /** |
||
629 | * @return string |
||
630 | */ |
||
631 | public function getLoadState(): string |
||
635 | |||
636 | /** |
||
637 | * @param string $LoadState |
||
638 | * @return AbstractType |
||
639 | */ |
||
640 | public function setLoadState(string $LoadState): AbstractType |
||
645 | |||
646 | /** |
||
647 | * @return array |
||
648 | */ |
||
649 | public function getNames(): array |
||
653 | |||
654 | /** |
||
655 | * @param array $Names |
||
656 | * @return AbstractType |
||
657 | */ |
||
658 | public function setNames(array $Names): AbstractType |
||
663 | |||
664 | /** |
||
665 | * @return bool |
||
666 | */ |
||
667 | public function isNeedDaemonReload(): bool |
||
671 | |||
672 | /** |
||
673 | * @param bool $NeedDaemonReload |
||
674 | * @return AbstractType |
||
675 | */ |
||
676 | public function setNeedDaemonReload(bool $NeedDaemonReload): AbstractType |
||
681 | |||
682 | /** |
||
683 | * @return string |
||
684 | */ |
||
685 | public function getOnFailureJobMode(): string |
||
689 | |||
690 | /** |
||
691 | * @param string $OnFailureJobMode |
||
692 | * @return AbstractType |
||
693 | */ |
||
694 | public function setOnFailureJobMode(string $OnFailureJobMode): AbstractType |
||
699 | |||
700 | /** |
||
701 | * @return bool |
||
702 | */ |
||
703 | public function isPerpetual(): bool |
||
707 | |||
708 | /** |
||
709 | * @param bool $Perpetual |
||
710 | * @return AbstractType |
||
711 | */ |
||
712 | public function setPerpetual(bool $Perpetual): AbstractType |
||
717 | |||
718 | /** |
||
719 | * @return bool |
||
720 | */ |
||
721 | public function isRefuseManualStart(): bool |
||
725 | |||
726 | /** |
||
727 | * @param bool $RefuseManualStart |
||
728 | * @return AbstractType |
||
729 | */ |
||
730 | public function setRefuseManualStart(bool $RefuseManualStart): AbstractType |
||
735 | |||
736 | /** |
||
737 | * @return bool |
||
738 | */ |
||
739 | public function isRefuseManualStop(): bool |
||
743 | |||
744 | /** |
||
745 | * @param bool $RefuseManualStop |
||
746 | * @return AbstractType |
||
747 | */ |
||
748 | public function setRefuseManualStop(bool $RefuseManualStop): AbstractType |
||
753 | |||
754 | /** |
||
755 | * @return string |
||
756 | */ |
||
757 | public function getStartLimitAction(): string |
||
761 | |||
762 | /** |
||
763 | * @param string $StartLimitAction |
||
764 | * @return AbstractType |
||
765 | */ |
||
766 | public function setStartLimitAction(string $StartLimitAction): AbstractType |
||
771 | |||
772 | /** |
||
773 | * @return bool |
||
774 | */ |
||
775 | public function isStartLimitBurst(): bool |
||
779 | |||
780 | /** |
||
781 | * @param bool $StartLimitBurst |
||
782 | * @return AbstractType |
||
783 | */ |
||
784 | public function setStartLimitBurst(bool $StartLimitBurst): AbstractType |
||
789 | |||
790 | /** |
||
791 | * @return int |
||
792 | */ |
||
793 | public function getStartLimitInterval(): int |
||
797 | |||
798 | /** |
||
799 | * @param int $StartLimitInterval |
||
800 | * @return AbstractType |
||
801 | */ |
||
802 | public function setStartLimitInterval(int $StartLimitInterval): AbstractType |
||
807 | |||
808 | /** |
||
809 | * @return int |
||
810 | */ |
||
811 | public function getStartLimitIntervalSec(): int |
||
815 | |||
816 | /** |
||
817 | * @param int $StartLimitIntervalSec |
||
818 | * @return AbstractType |
||
819 | */ |
||
820 | public function setStartLimitIntervalSec(int $StartLimitIntervalSec): AbstractType |
||
825 | |||
826 | /** |
||
827 | * @return \DateTimeImmutable |
||
828 | */ |
||
829 | public function getStateChangeTimestamp(): \DateTimeImmutable |
||
833 | |||
834 | /** |
||
835 | * @param \DateTimeImmutable $StateChangeTimestamp |
||
836 | * @return AbstractType |
||
837 | */ |
||
838 | public function setStateChangeTimestamp(\DateTimeImmutable $StateChangeTimestamp): AbstractType |
||
843 | |||
844 | /** |
||
845 | * @return int |
||
846 | */ |
||
847 | public function getStateChangeTimestampMonotonic(): int |
||
851 | |||
852 | /** |
||
853 | * @param int $StateChangeTimestampMonotonic |
||
854 | * @return AbstractType |
||
855 | */ |
||
856 | public function setStateChangeTimestampMonotonic(int $StateChangeTimestampMonotonic): AbstractType |
||
861 | |||
862 | /** |
||
863 | * @return bool |
||
864 | */ |
||
865 | public function isStopWhenUnneeded(): bool |
||
869 | |||
870 | /** |
||
871 | * @param bool $StopWhenUnneeded |
||
872 | * @return AbstractType |
||
873 | */ |
||
874 | public function setStopWhenUnneeded(bool $StopWhenUnneeded): AbstractType |
||
879 | |||
880 | /** |
||
881 | * @return string |
||
882 | */ |
||
883 | public function getSubState(): string |
||
887 | |||
888 | /** |
||
889 | * @param string $SubState |
||
890 | * @return AbstractType |
||
891 | */ |
||
892 | public function setSubState(string $SubState): AbstractType |
||
897 | |||
898 | /** |
||
899 | * @return bool |
||
900 | */ |
||
901 | public function isTransient(): bool |
||
905 | |||
906 | /** |
||
907 | * @param bool $Transient |
||
908 | * @return AbstractType |
||
909 | */ |
||
910 | public function setTransient(bool $Transient): AbstractType |
||
915 | |||
916 | public function jsonSerialize() |
||
920 | } |
||
921 |