Complex classes like Scope 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 Scope, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class Scope extends AbstractType |
||
6 | { |
||
7 | protected $After = []; |
||
8 | |||
9 | protected $BlockIOAccounting; |
||
10 | |||
11 | protected $BlockIOWeight; |
||
12 | |||
13 | protected $CPUAccounting; |
||
14 | |||
15 | protected $CPUQuotaPerSecUSec; |
||
16 | |||
17 | protected $CPUShares; |
||
18 | |||
19 | protected $CPUUsageNSec; |
||
20 | |||
21 | protected $CPUWeight; |
||
22 | |||
23 | protected $Conflicts = []; |
||
24 | |||
25 | protected $ControlGroup; |
||
26 | |||
27 | protected $Delegate; |
||
28 | |||
29 | protected $DevicePolicy; |
||
30 | |||
31 | protected $Documentation; |
||
32 | |||
33 | protected $DropInPaths = []; |
||
34 | |||
35 | protected $FragmentPath; |
||
36 | |||
37 | protected $IOAccounting; |
||
38 | |||
39 | protected $IOWeight; |
||
40 | |||
41 | protected $KillMode; |
||
42 | |||
43 | protected $KillSignal; |
||
44 | |||
45 | protected $MemoryAccounting; |
||
46 | |||
47 | protected $MemoryCurrent; |
||
48 | |||
49 | protected $MemoryHigh; |
||
50 | |||
51 | protected $MemoryLimit; |
||
52 | |||
53 | protected $MemoryLow; |
||
54 | |||
55 | protected $MemoryMax; |
||
56 | |||
57 | protected $MemorySwapMax; |
||
58 | |||
59 | protected $Requires = []; |
||
60 | |||
61 | protected $Result; |
||
62 | |||
63 | protected $SendSIGHUP; |
||
64 | |||
65 | protected $SendSIGKILL; |
||
66 | |||
67 | protected $Slice; |
||
68 | |||
69 | protected $StartupBlockIOWeight; |
||
70 | |||
71 | protected $StartupCPUShares; |
||
72 | |||
73 | protected $StartupCPUWeight; |
||
74 | |||
75 | protected $StartupIOWeight; |
||
76 | |||
77 | protected $TasksAccounting; |
||
78 | |||
79 | protected $TasksCurrent; |
||
80 | |||
81 | protected $TasksMax; |
||
82 | |||
83 | protected $TimeoutStopUSec; |
||
84 | |||
85 | protected $UnitFilePreset; |
||
86 | |||
87 | protected $UnitFileState; |
||
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | public function getAfter(): array |
||
96 | |||
97 | /** |
||
98 | * @param array $After |
||
99 | * @return Scope |
||
100 | */ |
||
101 | public function setAfter(array $After): Scope |
||
106 | |||
107 | /** |
||
108 | * @return mixed |
||
109 | */ |
||
110 | public function getBlockIOAccounting() |
||
114 | |||
115 | /** |
||
116 | * @param mixed $BlockIOAccounting |
||
117 | * @return Scope |
||
118 | */ |
||
119 | public function setBlockIOAccounting($BlockIOAccounting) |
||
124 | |||
125 | /** |
||
126 | * @return mixed |
||
127 | */ |
||
128 | public function getBlockIOWeight() |
||
132 | |||
133 | /** |
||
134 | * @param mixed $BlockIOWeight |
||
135 | * @return Scope |
||
136 | */ |
||
137 | public function setBlockIOWeight($BlockIOWeight) |
||
142 | |||
143 | /** |
||
144 | * @return mixed |
||
145 | */ |
||
146 | public function getCPUAccounting() |
||
150 | |||
151 | /** |
||
152 | * @param mixed $CPUAccounting |
||
153 | * @return Scope |
||
154 | */ |
||
155 | public function setCPUAccounting($CPUAccounting) |
||
160 | |||
161 | /** |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function getCPUQuotaPerSecUSec() |
||
168 | |||
169 | /** |
||
170 | * @param mixed $CPUQuotaPerSecUSec |
||
171 | * @return Scope |
||
172 | */ |
||
173 | public function setCPUQuotaPerSecUSec($CPUQuotaPerSecUSec) |
||
178 | |||
179 | /** |
||
180 | * @return mixed |
||
181 | */ |
||
182 | public function getCPUShares() |
||
186 | |||
187 | /** |
||
188 | * @param mixed $CPUShares |
||
189 | * @return Scope |
||
190 | */ |
||
191 | public function setCPUShares($CPUShares) |
||
196 | |||
197 | /** |
||
198 | * @return mixed |
||
199 | */ |
||
200 | public function getCPUUsageNSec() |
||
204 | |||
205 | /** |
||
206 | * @param mixed $CPUUsageNSec |
||
207 | * @return Scope |
||
208 | */ |
||
209 | public function setCPUUsageNSec($CPUUsageNSec) |
||
214 | |||
215 | /** |
||
216 | * @return mixed |
||
217 | */ |
||
218 | public function getCPUWeight() |
||
222 | |||
223 | /** |
||
224 | * @param mixed $CPUWeight |
||
225 | * @return Scope |
||
226 | */ |
||
227 | public function setCPUWeight($CPUWeight) |
||
232 | |||
233 | /** |
||
234 | * @return array |
||
235 | */ |
||
236 | public function getConflicts(): array |
||
240 | |||
241 | /** |
||
242 | * @param array $Conflicts |
||
243 | * @return Scope |
||
244 | */ |
||
245 | public function setConflicts(array $Conflicts): Scope |
||
250 | |||
251 | /** |
||
252 | * @return mixed |
||
253 | */ |
||
254 | public function getControlGroup() |
||
258 | |||
259 | /** |
||
260 | * @param mixed $ControlGroup |
||
261 | * @return Scope |
||
262 | */ |
||
263 | public function setControlGroup($ControlGroup) |
||
268 | |||
269 | /** |
||
270 | * @return mixed |
||
271 | */ |
||
272 | public function getDelegate() |
||
276 | |||
277 | /** |
||
278 | * @param mixed $Delegate |
||
279 | * @return Scope |
||
280 | */ |
||
281 | public function setDelegate($Delegate) |
||
286 | |||
287 | /** |
||
288 | * @return mixed |
||
289 | */ |
||
290 | public function getDevicePolicy() |
||
294 | |||
295 | /** |
||
296 | * @param mixed $DevicePolicy |
||
297 | * @return Scope |
||
298 | */ |
||
299 | public function setDevicePolicy($DevicePolicy) |
||
304 | |||
305 | /** |
||
306 | * @return array |
||
307 | */ |
||
308 | public function getDropInPaths(): array |
||
312 | |||
313 | /** |
||
314 | * @param array $DropInPaths |
||
315 | * @return Scope |
||
316 | */ |
||
317 | public function setDropInPaths(array $DropInPaths): Scope |
||
322 | |||
323 | /** |
||
324 | * @return mixed |
||
325 | */ |
||
326 | public function getDocumentation() |
||
330 | |||
331 | /** |
||
332 | * @param mixed $Documentation |
||
333 | * @return Scope |
||
334 | */ |
||
335 | public function setDocumentation($Documentation) |
||
340 | |||
341 | /** |
||
342 | * @return mixed |
||
343 | */ |
||
344 | public function getFragmentPath() |
||
348 | |||
349 | /** |
||
350 | * @param mixed $FragmentPath |
||
351 | * @return Scope |
||
352 | */ |
||
353 | public function setFragmentPath($FragmentPath) |
||
358 | |||
359 | /** |
||
360 | * @return mixed |
||
361 | */ |
||
362 | public function getIOAccounting() |
||
366 | |||
367 | /** |
||
368 | * @param mixed $IOAccounting |
||
369 | * @return Scope |
||
370 | */ |
||
371 | public function setIOAccounting($IOAccounting) |
||
376 | |||
377 | /** |
||
378 | * @return mixed |
||
379 | */ |
||
380 | public function getIOWeight() |
||
384 | |||
385 | /** |
||
386 | * @param mixed $IOWeight |
||
387 | * @return Scope |
||
388 | */ |
||
389 | public function setIOWeight($IOWeight) |
||
394 | |||
395 | /** |
||
396 | * @return mixed |
||
397 | */ |
||
398 | public function getKillMode() |
||
402 | |||
403 | /** |
||
404 | * @param mixed $KillMode |
||
405 | * @return Scope |
||
406 | */ |
||
407 | public function setKillMode($KillMode) |
||
412 | |||
413 | /** |
||
414 | * @return mixed |
||
415 | */ |
||
416 | public function getKillSignal() |
||
420 | |||
421 | /** |
||
422 | * @param mixed $KillSignal |
||
423 | * @return Scope |
||
424 | */ |
||
425 | public function setKillSignal($KillSignal) |
||
430 | |||
431 | /** |
||
432 | * @return mixed |
||
433 | */ |
||
434 | public function getMemoryAccounting() |
||
438 | |||
439 | /** |
||
440 | * @param mixed $MemoryAccounting |
||
441 | * @return Scope |
||
442 | */ |
||
443 | public function setMemoryAccounting($MemoryAccounting) |
||
448 | |||
449 | /** |
||
450 | * @return mixed |
||
451 | */ |
||
452 | public function getMemoryCurrent() |
||
456 | |||
457 | /** |
||
458 | * @param mixed $MemoryCurrent |
||
459 | * @return Scope |
||
460 | */ |
||
461 | public function setMemoryCurrent($MemoryCurrent) |
||
466 | |||
467 | /** |
||
468 | * @return mixed |
||
469 | */ |
||
470 | public function getMemoryHigh() |
||
474 | |||
475 | /** |
||
476 | * @param mixed $MemoryHigh |
||
477 | * @return Scope |
||
478 | */ |
||
479 | public function setMemoryHigh($MemoryHigh) |
||
484 | |||
485 | /** |
||
486 | * @return mixed |
||
487 | */ |
||
488 | public function getMemoryLimit() |
||
492 | |||
493 | /** |
||
494 | * @param mixed $MemoryLimit |
||
495 | * @return Scope |
||
496 | */ |
||
497 | public function setMemoryLimit($MemoryLimit) |
||
502 | |||
503 | /** |
||
504 | * @return mixed |
||
505 | */ |
||
506 | public function getMemoryLow() |
||
510 | |||
511 | /** |
||
512 | * @param mixed $MemoryLow |
||
513 | * @return Scope |
||
514 | */ |
||
515 | public function setMemoryLow($MemoryLow) |
||
520 | |||
521 | /** |
||
522 | * @return mixed |
||
523 | */ |
||
524 | public function getMemoryMax() |
||
528 | |||
529 | /** |
||
530 | * @param mixed $MemoryMax |
||
531 | * @return Scope |
||
532 | */ |
||
533 | public function setMemoryMax($MemoryMax) |
||
538 | |||
539 | /** |
||
540 | * @return mixed |
||
541 | */ |
||
542 | public function getMemorySwapMax() |
||
546 | |||
547 | /** |
||
548 | * @param mixed $MemorySwapMax |
||
549 | * @return Scope |
||
550 | */ |
||
551 | public function setMemorySwapMax($MemorySwapMax) |
||
556 | |||
557 | /** |
||
558 | * @return array |
||
559 | */ |
||
560 | public function getRequires(): array |
||
564 | |||
565 | /** |
||
566 | * @param array $Requires |
||
567 | * @return Scope |
||
568 | */ |
||
569 | public function setRequires(array $Requires): Scope |
||
574 | |||
575 | /** |
||
576 | * @return mixed |
||
577 | */ |
||
578 | public function getResult() |
||
582 | |||
583 | /** |
||
584 | * @param mixed $Result |
||
585 | * @return Scope |
||
586 | */ |
||
587 | public function setResult($Result) |
||
592 | |||
593 | /** |
||
594 | * @return mixed |
||
595 | */ |
||
596 | public function getSendSIGHUP() |
||
600 | |||
601 | /** |
||
602 | * @param mixed $SendSIGHUP |
||
603 | * @return Scope |
||
604 | */ |
||
605 | public function setSendSIGHUP($SendSIGHUP) |
||
610 | |||
611 | /** |
||
612 | * @return mixed |
||
613 | */ |
||
614 | public function getSendSIGKILL() |
||
618 | |||
619 | /** |
||
620 | * @param mixed $SendSIGKILL |
||
621 | * @return Scope |
||
622 | */ |
||
623 | public function setSendSIGKILL($SendSIGKILL) |
||
628 | |||
629 | /** |
||
630 | * @return mixed |
||
631 | */ |
||
632 | public function getSlice() |
||
636 | |||
637 | /** |
||
638 | * @param mixed $Slice |
||
639 | * @return Scope |
||
640 | */ |
||
641 | public function setSlice($Slice) |
||
646 | |||
647 | /** |
||
648 | * @return mixed |
||
649 | */ |
||
650 | public function getStartupBlockIOWeight() |
||
654 | |||
655 | /** |
||
656 | * @param mixed $StartupBlockIOWeight |
||
657 | * @return Scope |
||
658 | */ |
||
659 | public function setStartupBlockIOWeight($StartupBlockIOWeight) |
||
664 | |||
665 | /** |
||
666 | * @return mixed |
||
667 | */ |
||
668 | public function getStartupCPUShares() |
||
672 | |||
673 | /** |
||
674 | * @param mixed $StartupCPUShares |
||
675 | * @return Scope |
||
676 | */ |
||
677 | public function setStartupCPUShares($StartupCPUShares) |
||
682 | |||
683 | /** |
||
684 | * @return mixed |
||
685 | */ |
||
686 | public function getStartupCPUWeight() |
||
690 | |||
691 | /** |
||
692 | * @param mixed $StartupCPUWeight |
||
693 | * @return Scope |
||
694 | */ |
||
695 | public function setStartupCPUWeight($StartupCPUWeight) |
||
700 | |||
701 | /** |
||
702 | * @return mixed |
||
703 | */ |
||
704 | public function getStartupIOWeight() |
||
708 | |||
709 | /** |
||
710 | * @param mixed $StartupIOWeight |
||
711 | * @return Scope |
||
712 | */ |
||
713 | public function setStartupIOWeight($StartupIOWeight) |
||
718 | |||
719 | /** |
||
720 | * @return mixed |
||
721 | */ |
||
722 | public function getTasksAccounting() |
||
726 | |||
727 | /** |
||
728 | * @param mixed $TasksAccounting |
||
729 | * @return Scope |
||
730 | */ |
||
731 | public function setTasksAccounting($TasksAccounting) |
||
736 | |||
737 | /** |
||
738 | * @return mixed |
||
739 | */ |
||
740 | public function getTasksCurrent() |
||
744 | |||
745 | /** |
||
746 | * @param mixed $TasksCurrent |
||
747 | * @return Scope |
||
748 | */ |
||
749 | public function setTasksCurrent($TasksCurrent) |
||
754 | |||
755 | /** |
||
756 | * @return mixed |
||
757 | */ |
||
758 | public function getTasksMax() |
||
762 | |||
763 | /** |
||
764 | * @param mixed $TasksMax |
||
765 | * @return Scope |
||
766 | */ |
||
767 | public function setTasksMax($TasksMax) |
||
772 | |||
773 | /** |
||
774 | * @return mixed |
||
775 | */ |
||
776 | public function getTimeoutStopUSec() |
||
780 | |||
781 | /** |
||
782 | * @param mixed $TimeoutStopUSec |
||
783 | * @return Scope |
||
784 | */ |
||
785 | public function setTimeoutStopUSec($TimeoutStopUSec) |
||
790 | |||
791 | /** |
||
792 | * @return mixed |
||
793 | */ |
||
794 | public function getUnitFilePreset() |
||
798 | |||
799 | /** |
||
800 | * @param mixed $UnitFilePreset |
||
801 | * @return Scope |
||
802 | */ |
||
803 | public function setUnitFilePreset($UnitFilePreset) |
||
808 | |||
809 | /** |
||
810 | * @return mixed |
||
811 | */ |
||
812 | public function getUnitFileState() |
||
816 | |||
817 | /** |
||
818 | * @param mixed $UnitFileState |
||
819 | * @return Scope |
||
820 | */ |
||
821 | public function setUnitFileState($UnitFileState) |
||
826 | } |
||
827 |