Complex classes like Slice 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 Slice, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
5 | class Slice 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 $MemoryAccounting; |
||
42 | |||
43 | protected $MemoryCurrent; |
||
44 | |||
45 | protected $MemoryHigh; |
||
46 | |||
47 | protected $MemoryLimit; |
||
48 | |||
49 | protected $MemoryLow; |
||
50 | |||
51 | protected $MemoryMax; |
||
52 | |||
53 | protected $MemorySwapMax; |
||
54 | |||
55 | protected $RequiredBy = []; |
||
56 | |||
57 | protected $Requires = []; |
||
58 | |||
59 | protected $Slice; |
||
60 | |||
61 | protected $StartupBlockIOWeight; |
||
62 | |||
63 | protected $StartupCPUShares; |
||
64 | |||
65 | protected $StartupCPUWeight; |
||
66 | |||
67 | protected $StartupIOWeight; |
||
68 | |||
69 | protected $TasksAccounting; |
||
70 | |||
71 | protected $TasksCurrent; |
||
72 | |||
73 | protected $TasksMax; |
||
74 | |||
75 | protected $UnitFilePreset; |
||
76 | |||
77 | protected $UnitFileState; |
||
78 | |||
79 | protected $WantedBy = []; |
||
80 | |||
81 | /** |
||
82 | * @return array |
||
83 | */ |
||
84 | public function getAfter(): array |
||
88 | |||
89 | /** |
||
90 | * @param array $After |
||
91 | * @return Slice |
||
92 | */ |
||
93 | public function setAfter(array $After): Slice |
||
98 | |||
99 | /** |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function getBlockIOAccounting() |
||
106 | |||
107 | /** |
||
108 | * @param mixed $BlockIOAccounting |
||
109 | * @return Slice |
||
110 | */ |
||
111 | public function setBlockIOAccounting($BlockIOAccounting) |
||
116 | |||
117 | /** |
||
118 | * @return mixed |
||
119 | */ |
||
120 | public function getBlockIOWeight() |
||
124 | |||
125 | /** |
||
126 | * @param mixed $BlockIOWeight |
||
127 | * @return Slice |
||
128 | */ |
||
129 | public function setBlockIOWeight($BlockIOWeight) |
||
134 | |||
135 | /** |
||
136 | * @return mixed |
||
137 | */ |
||
138 | public function getCPUAccounting() |
||
142 | |||
143 | /** |
||
144 | * @param mixed $CPUAccounting |
||
145 | * @return Slice |
||
146 | */ |
||
147 | public function setCPUAccounting($CPUAccounting) |
||
152 | |||
153 | /** |
||
154 | * @return mixed |
||
155 | */ |
||
156 | public function getCPUQuotaPerSecUSec() |
||
160 | |||
161 | /** |
||
162 | * @param mixed $CPUQuotaPerSecUSec |
||
163 | * @return Slice |
||
164 | */ |
||
165 | public function setCPUQuotaPerSecUSec($CPUQuotaPerSecUSec) |
||
170 | |||
171 | /** |
||
172 | * @return mixed |
||
173 | */ |
||
174 | public function getCPUShares() |
||
178 | |||
179 | /** |
||
180 | * @param mixed $CPUShares |
||
181 | * @return Slice |
||
182 | */ |
||
183 | public function setCPUShares($CPUShares) |
||
188 | |||
189 | /** |
||
190 | * @return mixed |
||
191 | */ |
||
192 | public function getCPUUsageNSec() |
||
196 | |||
197 | /** |
||
198 | * @param mixed $CPUUsageNSec |
||
199 | * @return Slice |
||
200 | */ |
||
201 | public function setCPUUsageNSec($CPUUsageNSec) |
||
206 | |||
207 | /** |
||
208 | * @return mixed |
||
209 | */ |
||
210 | public function getCPUWeight() |
||
214 | |||
215 | /** |
||
216 | * @param mixed $CPUWeight |
||
217 | * @return Slice |
||
218 | */ |
||
219 | public function setCPUWeight($CPUWeight) |
||
224 | |||
225 | /** |
||
226 | * @return array |
||
227 | */ |
||
228 | public function getConflicts(): array |
||
232 | |||
233 | /** |
||
234 | * @param array $Conflicts |
||
235 | * @return Slice |
||
236 | */ |
||
237 | public function setConflicts(array $Conflicts): Slice |
||
242 | |||
243 | /** |
||
244 | * @return mixed |
||
245 | */ |
||
246 | public function getControlGroup() |
||
250 | |||
251 | /** |
||
252 | * @param mixed $ControlGroup |
||
253 | * @return Slice |
||
254 | */ |
||
255 | public function setControlGroup($ControlGroup) |
||
260 | |||
261 | /** |
||
262 | * @return mixed |
||
263 | */ |
||
264 | public function getDelegate() |
||
268 | |||
269 | /** |
||
270 | * @param mixed $Delegate |
||
271 | * @return Slice |
||
272 | */ |
||
273 | public function setDelegate($Delegate) |
||
278 | |||
279 | /** |
||
280 | * @return mixed |
||
281 | */ |
||
282 | public function getDevicePolicy() |
||
286 | |||
287 | /** |
||
288 | * @param mixed $DevicePolicy |
||
289 | * @return Slice |
||
290 | */ |
||
291 | public function setDevicePolicy($DevicePolicy) |
||
296 | |||
297 | /** |
||
298 | * @return array |
||
299 | */ |
||
300 | public function getDropInPaths(): array |
||
304 | |||
305 | /** |
||
306 | * @param array $DropInPaths |
||
307 | * @return Slice |
||
308 | */ |
||
309 | public function setDropInPaths(array $DropInPaths): Slice |
||
314 | |||
315 | /** |
||
316 | * @return array |
||
317 | */ |
||
318 | public function getDocumentation(): array |
||
322 | |||
323 | /** |
||
324 | * @param array $Documentation |
||
325 | * @return Slice |
||
326 | */ |
||
327 | public function setDocumentation(array $Documentation): Slice |
||
332 | |||
333 | /** |
||
334 | * @return mixed |
||
335 | */ |
||
336 | public function getFragmentPath() |
||
340 | |||
341 | /** |
||
342 | * @param mixed $FragmentPath |
||
343 | * @return Slice |
||
344 | */ |
||
345 | public function setFragmentPath($FragmentPath) |
||
350 | |||
351 | /** |
||
352 | * @return mixed |
||
353 | */ |
||
354 | public function getIOAccounting() |
||
358 | |||
359 | /** |
||
360 | * @param mixed $IOAccounting |
||
361 | * @return Slice |
||
362 | */ |
||
363 | public function setIOAccounting($IOAccounting) |
||
368 | |||
369 | /** |
||
370 | * @return mixed |
||
371 | */ |
||
372 | public function getIOWeight() |
||
376 | |||
377 | /** |
||
378 | * @param mixed $IOWeight |
||
379 | * @return Slice |
||
380 | */ |
||
381 | public function setIOWeight($IOWeight) |
||
386 | |||
387 | /** |
||
388 | * @return mixed |
||
389 | */ |
||
390 | public function getMemoryAccounting() |
||
394 | |||
395 | /** |
||
396 | * @param mixed $MemoryAccounting |
||
397 | * @return Slice |
||
398 | */ |
||
399 | public function setMemoryAccounting($MemoryAccounting) |
||
404 | |||
405 | /** |
||
406 | * @return mixed |
||
407 | */ |
||
408 | public function getMemoryCurrent() |
||
412 | |||
413 | /** |
||
414 | * @param mixed $MemoryCurrent |
||
415 | * @return Slice |
||
416 | */ |
||
417 | public function setMemoryCurrent($MemoryCurrent) |
||
422 | |||
423 | /** |
||
424 | * @return mixed |
||
425 | */ |
||
426 | public function getMemoryHigh() |
||
430 | |||
431 | /** |
||
432 | * @param mixed $MemoryHigh |
||
433 | * @return Slice |
||
434 | */ |
||
435 | public function setMemoryHigh($MemoryHigh) |
||
440 | |||
441 | /** |
||
442 | * @return mixed |
||
443 | */ |
||
444 | public function getMemoryLimit() |
||
448 | |||
449 | /** |
||
450 | * @param mixed $MemoryLimit |
||
451 | * @return Slice |
||
452 | */ |
||
453 | public function setMemoryLimit($MemoryLimit) |
||
458 | |||
459 | /** |
||
460 | * @return mixed |
||
461 | */ |
||
462 | public function getMemoryLow() |
||
466 | |||
467 | /** |
||
468 | * @param mixed $MemoryLow |
||
469 | * @return Slice |
||
470 | */ |
||
471 | public function setMemoryLow($MemoryLow) |
||
476 | |||
477 | /** |
||
478 | * @return mixed |
||
479 | */ |
||
480 | public function getMemoryMax() |
||
484 | |||
485 | /** |
||
486 | * @param mixed $MemoryMax |
||
487 | * @return Slice |
||
488 | */ |
||
489 | public function setMemoryMax($MemoryMax) |
||
494 | |||
495 | /** |
||
496 | * @return mixed |
||
497 | */ |
||
498 | public function getMemorySwapMax() |
||
502 | |||
503 | /** |
||
504 | * @param mixed $MemorySwapMax |
||
505 | * @return Slice |
||
506 | */ |
||
507 | public function setMemorySwapMax($MemorySwapMax) |
||
512 | |||
513 | /** |
||
514 | * @return array |
||
515 | */ |
||
516 | public function getRequiredBy(): array |
||
520 | |||
521 | /** |
||
522 | * @param array $RequiredBy |
||
523 | * @return Slice |
||
524 | */ |
||
525 | public function setRequiredBy(array $RequiredBy): Slice |
||
530 | |||
531 | /** |
||
532 | * @return array |
||
533 | */ |
||
534 | public function getRequires(): array |
||
538 | |||
539 | /** |
||
540 | * @param array $Requires |
||
541 | * @return Slice |
||
542 | */ |
||
543 | public function setRequires(array $Requires): Slice |
||
548 | |||
549 | /** |
||
550 | * @return mixed |
||
551 | */ |
||
552 | public function getSlice() |
||
556 | |||
557 | /** |
||
558 | * @param mixed $Slice |
||
559 | * @return Slice |
||
560 | */ |
||
561 | public function setSlice($Slice) |
||
566 | |||
567 | /** |
||
568 | * @return mixed |
||
569 | */ |
||
570 | public function getStartupBlockIOWeight() |
||
574 | |||
575 | /** |
||
576 | * @param mixed $StartupBlockIOWeight |
||
577 | * @return Slice |
||
578 | */ |
||
579 | public function setStartupBlockIOWeight($StartupBlockIOWeight) |
||
584 | |||
585 | /** |
||
586 | * @return mixed |
||
587 | */ |
||
588 | public function getStartupCPUShares() |
||
592 | |||
593 | /** |
||
594 | * @param mixed $StartupCPUShares |
||
595 | * @return Slice |
||
596 | */ |
||
597 | public function setStartupCPUShares($StartupCPUShares) |
||
602 | |||
603 | /** |
||
604 | * @return mixed |
||
605 | */ |
||
606 | public function getStartupCPUWeight() |
||
610 | |||
611 | /** |
||
612 | * @param mixed $StartupCPUWeight |
||
613 | * @return Slice |
||
614 | */ |
||
615 | public function setStartupCPUWeight($StartupCPUWeight) |
||
620 | |||
621 | /** |
||
622 | * @return mixed |
||
623 | */ |
||
624 | public function getStartupIOWeight() |
||
628 | |||
629 | /** |
||
630 | * @param mixed $StartupIOWeight |
||
631 | * @return Slice |
||
632 | */ |
||
633 | public function setStartupIOWeight($StartupIOWeight) |
||
638 | |||
639 | /** |
||
640 | * @return mixed |
||
641 | */ |
||
642 | public function getTasksAccounting() |
||
646 | |||
647 | /** |
||
648 | * @param mixed $TasksAccounting |
||
649 | * @return Slice |
||
650 | */ |
||
651 | public function setTasksAccounting($TasksAccounting) |
||
656 | |||
657 | /** |
||
658 | * @return mixed |
||
659 | */ |
||
660 | public function getTasksCurrent() |
||
664 | |||
665 | /** |
||
666 | * @param mixed $TasksCurrent |
||
667 | * @return Slice |
||
668 | */ |
||
669 | public function setTasksCurrent($TasksCurrent) |
||
674 | |||
675 | /** |
||
676 | * @return mixed |
||
677 | */ |
||
678 | public function getTasksMax() |
||
682 | |||
683 | /** |
||
684 | * @param mixed $TasksMax |
||
685 | * @return Slice |
||
686 | */ |
||
687 | public function setTasksMax($TasksMax) |
||
692 | |||
693 | /** |
||
694 | * @return mixed |
||
695 | */ |
||
696 | public function getUnitFilePreset() |
||
700 | |||
701 | /** |
||
702 | * @param mixed $UnitFilePreset |
||
703 | * @return Slice |
||
704 | */ |
||
705 | public function setUnitFilePreset($UnitFilePreset) |
||
710 | |||
711 | /** |
||
712 | * @return mixed |
||
713 | */ |
||
714 | public function getUnitFileState() |
||
718 | |||
719 | /** |
||
720 | * @param mixed $UnitFileState |
||
721 | * @return Slice |
||
722 | */ |
||
723 | public function setUnitFileState($UnitFileState) |
||
728 | |||
729 | /** |
||
730 | * @return array |
||
731 | */ |
||
732 | public function getWantedBy(): array |
||
736 | |||
737 | /** |
||
738 | * @param array $WantedBy |
||
739 | * @return Slice |
||
740 | */ |
||
741 | public function setWantedBy(array $WantedBy): Slice |
||
746 | } |
||
747 |