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 | private $After = []; |
||
| 8 | |||
| 9 | private $BlockIOAccounting; |
||
| 10 | |||
| 11 | private $BlockIOWeight; |
||
| 12 | |||
| 13 | private $CPUAccounting; |
||
| 14 | |||
| 15 | private $CPUQuotaPerSecUSec; |
||
| 16 | |||
| 17 | private $CPUShares; |
||
| 18 | |||
| 19 | private $CPUUsageNSec; |
||
| 20 | |||
| 21 | private $CPUWeight; |
||
| 22 | |||
| 23 | private $Conflicts = []; |
||
| 24 | |||
| 25 | private $ControlGroup; |
||
| 26 | |||
| 27 | private $Delegate; |
||
| 28 | |||
| 29 | private $DevicePolicy; |
||
| 30 | |||
| 31 | private $Documentation; |
||
| 32 | |||
| 33 | private $FragmentPath; |
||
| 34 | |||
| 35 | private $IOAccounting; |
||
| 36 | |||
| 37 | private $IOWeight; |
||
| 38 | |||
| 39 | private $KillMode; |
||
| 40 | |||
| 41 | private $KillSignal; |
||
| 42 | |||
| 43 | private $MemoryAccounting; |
||
| 44 | |||
| 45 | private $MemoryCurrent; |
||
| 46 | |||
| 47 | private $MemoryHigh; |
||
| 48 | |||
| 49 | private $MemoryLimit; |
||
| 50 | |||
| 51 | private $MemoryLow; |
||
| 52 | |||
| 53 | private $MemoryMax; |
||
| 54 | |||
| 55 | private $MemorySwapMax; |
||
| 56 | |||
| 57 | private $Requires = []; |
||
| 58 | |||
| 59 | private $Result; |
||
| 60 | |||
| 61 | private $SendSIGHUP; |
||
| 62 | |||
| 63 | private $SendSIGKILL; |
||
| 64 | |||
| 65 | private $Slice; |
||
| 66 | |||
| 67 | private $StartupBlockIOWeight; |
||
| 68 | |||
| 69 | private $StartupCPUShares; |
||
| 70 | |||
| 71 | private $StartupCPUWeight; |
||
| 72 | |||
| 73 | private $StartupIOWeight; |
||
| 74 | |||
| 75 | private $TasksAccounting; |
||
| 76 | |||
| 77 | private $TasksCurrent; |
||
| 78 | |||
| 79 | private $TasksMax; |
||
| 80 | |||
| 81 | private $TimeoutStopUSec; |
||
| 82 | |||
| 83 | private $UnitFilePreset; |
||
| 84 | |||
| 85 | private $UnitFileState; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return array |
||
| 89 | */ |
||
| 90 | public function getAfter(): array |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @param array $After |
||
| 97 | * @return Scope |
||
| 98 | */ |
||
| 99 | public function setAfter(array $After): Scope |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return mixed |
||
| 107 | */ |
||
| 108 | public function getBlockIOAccounting() |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @param mixed $BlockIOAccounting |
||
| 115 | * @return Scope |
||
| 116 | */ |
||
| 117 | public function setBlockIOAccounting($BlockIOAccounting) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @return mixed |
||
| 125 | */ |
||
| 126 | public function getBlockIOWeight() |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @param mixed $BlockIOWeight |
||
| 133 | * @return Scope |
||
| 134 | */ |
||
| 135 | public function setBlockIOWeight($BlockIOWeight) |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @return mixed |
||
| 143 | */ |
||
| 144 | public function getCPUAccounting() |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param mixed $CPUAccounting |
||
| 151 | * @return Scope |
||
| 152 | */ |
||
| 153 | public function setCPUAccounting($CPUAccounting) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @return mixed |
||
| 161 | */ |
||
| 162 | public function getCPUQuotaPerSecUSec() |
||
| 166 | |||
| 167 | /** |
||
| 168 | * @param mixed $CPUQuotaPerSecUSec |
||
| 169 | * @return Scope |
||
| 170 | */ |
||
| 171 | public function setCPUQuotaPerSecUSec($CPUQuotaPerSecUSec) |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @return mixed |
||
| 179 | */ |
||
| 180 | public function getCPUShares() |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @param mixed $CPUShares |
||
| 187 | * @return Scope |
||
| 188 | */ |
||
| 189 | public function setCPUShares($CPUShares) |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @return mixed |
||
| 197 | */ |
||
| 198 | public function getCPUUsageNSec() |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @param mixed $CPUUsageNSec |
||
| 205 | * @return Scope |
||
| 206 | */ |
||
| 207 | public function setCPUUsageNSec($CPUUsageNSec) |
||
| 212 | |||
| 213 | /** |
||
| 214 | * @return mixed |
||
| 215 | */ |
||
| 216 | public function getCPUWeight() |
||
| 220 | |||
| 221 | /** |
||
| 222 | * @param mixed $CPUWeight |
||
| 223 | * @return Scope |
||
| 224 | */ |
||
| 225 | public function setCPUWeight($CPUWeight) |
||
| 230 | |||
| 231 | /** |
||
| 232 | * @return array |
||
| 233 | */ |
||
| 234 | public function getConflicts(): array |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @param array $Conflicts |
||
| 241 | * @return Scope |
||
| 242 | */ |
||
| 243 | public function setConflicts(array $Conflicts): Scope |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @return mixed |
||
| 251 | */ |
||
| 252 | public function getControlGroup() |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @param mixed $ControlGroup |
||
| 259 | * @return Scope |
||
| 260 | */ |
||
| 261 | public function setControlGroup($ControlGroup) |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @return mixed |
||
| 269 | */ |
||
| 270 | public function getDelegate() |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @param mixed $Delegate |
||
| 277 | * @return Scope |
||
| 278 | */ |
||
| 279 | public function setDelegate($Delegate) |
||
| 284 | |||
| 285 | /** |
||
| 286 | * @return mixed |
||
| 287 | */ |
||
| 288 | public function getDevicePolicy() |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @param mixed $DevicePolicy |
||
| 295 | * @return Scope |
||
| 296 | */ |
||
| 297 | public function setDevicePolicy($DevicePolicy) |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @return mixed |
||
| 305 | */ |
||
| 306 | public function getDocumentation() |
||
| 310 | |||
| 311 | /** |
||
| 312 | * @param mixed $Documentation |
||
| 313 | * @return Scope |
||
| 314 | */ |
||
| 315 | public function setDocumentation($Documentation) |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @return mixed |
||
| 323 | */ |
||
| 324 | public function getFragmentPath() |
||
| 328 | |||
| 329 | /** |
||
| 330 | * @param mixed $FragmentPath |
||
| 331 | * @return Scope |
||
| 332 | */ |
||
| 333 | public function setFragmentPath($FragmentPath) |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return mixed |
||
| 341 | */ |
||
| 342 | public function getIOAccounting() |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @param mixed $IOAccounting |
||
| 349 | * @return Scope |
||
| 350 | */ |
||
| 351 | public function setIOAccounting($IOAccounting) |
||
| 356 | |||
| 357 | /** |
||
| 358 | * @return mixed |
||
| 359 | */ |
||
| 360 | public function getIOWeight() |
||
| 364 | |||
| 365 | /** |
||
| 366 | * @param mixed $IOWeight |
||
| 367 | * @return Scope |
||
| 368 | */ |
||
| 369 | public function setIOWeight($IOWeight) |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @return mixed |
||
| 377 | */ |
||
| 378 | public function getKillMode() |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @param mixed $KillMode |
||
| 385 | * @return Scope |
||
| 386 | */ |
||
| 387 | public function setKillMode($KillMode) |
||
| 392 | |||
| 393 | /** |
||
| 394 | * @return mixed |
||
| 395 | */ |
||
| 396 | public function getKillSignal() |
||
| 400 | |||
| 401 | /** |
||
| 402 | * @param mixed $KillSignal |
||
| 403 | * @return Scope |
||
| 404 | */ |
||
| 405 | public function setKillSignal($KillSignal) |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @return mixed |
||
| 413 | */ |
||
| 414 | public function getMemoryAccounting() |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @param mixed $MemoryAccounting |
||
| 421 | * @return Scope |
||
| 422 | */ |
||
| 423 | public function setMemoryAccounting($MemoryAccounting) |
||
| 428 | |||
| 429 | /** |
||
| 430 | * @return mixed |
||
| 431 | */ |
||
| 432 | public function getMemoryCurrent() |
||
| 436 | |||
| 437 | /** |
||
| 438 | * @param mixed $MemoryCurrent |
||
| 439 | * @return Scope |
||
| 440 | */ |
||
| 441 | public function setMemoryCurrent($MemoryCurrent) |
||
| 446 | |||
| 447 | /** |
||
| 448 | * @return mixed |
||
| 449 | */ |
||
| 450 | public function getMemoryHigh() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @param mixed $MemoryHigh |
||
| 457 | * @return Scope |
||
| 458 | */ |
||
| 459 | public function setMemoryHigh($MemoryHigh) |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @return mixed |
||
| 467 | */ |
||
| 468 | public function getMemoryLimit() |
||
| 472 | |||
| 473 | /** |
||
| 474 | * @param mixed $MemoryLimit |
||
| 475 | * @return Scope |
||
| 476 | */ |
||
| 477 | public function setMemoryLimit($MemoryLimit) |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @return mixed |
||
| 485 | */ |
||
| 486 | public function getMemoryLow() |
||
| 490 | |||
| 491 | /** |
||
| 492 | * @param mixed $MemoryLow |
||
| 493 | * @return Scope |
||
| 494 | */ |
||
| 495 | public function setMemoryLow($MemoryLow) |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @return mixed |
||
| 503 | */ |
||
| 504 | public function getMemoryMax() |
||
| 508 | |||
| 509 | /** |
||
| 510 | * @param mixed $MemoryMax |
||
| 511 | * @return Scope |
||
| 512 | */ |
||
| 513 | public function setMemoryMax($MemoryMax) |
||
| 518 | |||
| 519 | /** |
||
| 520 | * @return mixed |
||
| 521 | */ |
||
| 522 | public function getMemorySwapMax() |
||
| 526 | |||
| 527 | /** |
||
| 528 | * @param mixed $MemorySwapMax |
||
| 529 | * @return Scope |
||
| 530 | */ |
||
| 531 | public function setMemorySwapMax($MemorySwapMax) |
||
| 536 | |||
| 537 | /** |
||
| 538 | * @return array |
||
| 539 | */ |
||
| 540 | public function getRequires(): array |
||
| 544 | |||
| 545 | /** |
||
| 546 | * @param array $Requires |
||
| 547 | * @return Scope |
||
| 548 | */ |
||
| 549 | public function setRequires(array $Requires): Scope |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @return mixed |
||
| 557 | */ |
||
| 558 | public function getResult() |
||
| 562 | |||
| 563 | /** |
||
| 564 | * @param mixed $Result |
||
| 565 | * @return Scope |
||
| 566 | */ |
||
| 567 | public function setResult($Result) |
||
| 572 | |||
| 573 | /** |
||
| 574 | * @return mixed |
||
| 575 | */ |
||
| 576 | public function getSendSIGHUP() |
||
| 580 | |||
| 581 | /** |
||
| 582 | * @param mixed $SendSIGHUP |
||
| 583 | * @return Scope |
||
| 584 | */ |
||
| 585 | public function setSendSIGHUP($SendSIGHUP) |
||
| 590 | |||
| 591 | /** |
||
| 592 | * @return mixed |
||
| 593 | */ |
||
| 594 | public function getSendSIGKILL() |
||
| 598 | |||
| 599 | /** |
||
| 600 | * @param mixed $SendSIGKILL |
||
| 601 | * @return Scope |
||
| 602 | */ |
||
| 603 | public function setSendSIGKILL($SendSIGKILL) |
||
| 608 | |||
| 609 | /** |
||
| 610 | * @return mixed |
||
| 611 | */ |
||
| 612 | public function getSlice() |
||
| 616 | |||
| 617 | /** |
||
| 618 | * @param mixed $Slice |
||
| 619 | * @return Scope |
||
| 620 | */ |
||
| 621 | public function setSlice($Slice) |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @return mixed |
||
| 629 | */ |
||
| 630 | public function getStartupBlockIOWeight() |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @param mixed $StartupBlockIOWeight |
||
| 637 | * @return Scope |
||
| 638 | */ |
||
| 639 | public function setStartupBlockIOWeight($StartupBlockIOWeight) |
||
| 644 | |||
| 645 | /** |
||
| 646 | * @return mixed |
||
| 647 | */ |
||
| 648 | public function getStartupCPUShares() |
||
| 652 | |||
| 653 | /** |
||
| 654 | * @param mixed $StartupCPUShares |
||
| 655 | * @return Scope |
||
| 656 | */ |
||
| 657 | public function setStartupCPUShares($StartupCPUShares) |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @return mixed |
||
| 665 | */ |
||
| 666 | public function getStartupCPUWeight() |
||
| 670 | |||
| 671 | /** |
||
| 672 | * @param mixed $StartupCPUWeight |
||
| 673 | * @return Scope |
||
| 674 | */ |
||
| 675 | public function setStartupCPUWeight($StartupCPUWeight) |
||
| 680 | |||
| 681 | /** |
||
| 682 | * @return mixed |
||
| 683 | */ |
||
| 684 | public function getStartupIOWeight() |
||
| 688 | |||
| 689 | /** |
||
| 690 | * @param mixed $StartupIOWeight |
||
| 691 | * @return Scope |
||
| 692 | */ |
||
| 693 | public function setStartupIOWeight($StartupIOWeight) |
||
| 698 | |||
| 699 | /** |
||
| 700 | * @return mixed |
||
| 701 | */ |
||
| 702 | public function getTasksAccounting() |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @param mixed $TasksAccounting |
||
| 709 | * @return Scope |
||
| 710 | */ |
||
| 711 | public function setTasksAccounting($TasksAccounting) |
||
| 716 | |||
| 717 | /** |
||
| 718 | * @return mixed |
||
| 719 | */ |
||
| 720 | public function getTasksCurrent() |
||
| 724 | |||
| 725 | /** |
||
| 726 | * @param mixed $TasksCurrent |
||
| 727 | * @return Scope |
||
| 728 | */ |
||
| 729 | public function setTasksCurrent($TasksCurrent) |
||
| 734 | |||
| 735 | /** |
||
| 736 | * @return mixed |
||
| 737 | */ |
||
| 738 | public function getTasksMax() |
||
| 742 | |||
| 743 | /** |
||
| 744 | * @param mixed $TasksMax |
||
| 745 | * @return Scope |
||
| 746 | */ |
||
| 747 | public function setTasksMax($TasksMax) |
||
| 752 | |||
| 753 | /** |
||
| 754 | * @return mixed |
||
| 755 | */ |
||
| 756 | public function getTimeoutStopUSec() |
||
| 760 | |||
| 761 | /** |
||
| 762 | * @param mixed $TimeoutStopUSec |
||
| 763 | * @return Scope |
||
| 764 | */ |
||
| 765 | public function setTimeoutStopUSec($TimeoutStopUSec) |
||
| 770 | |||
| 771 | /** |
||
| 772 | * @return mixed |
||
| 773 | */ |
||
| 774 | public function getUnitFilePreset() |
||
| 778 | |||
| 779 | /** |
||
| 780 | * @param mixed $UnitFilePreset |
||
| 781 | * @return Scope |
||
| 782 | */ |
||
| 783 | public function setUnitFilePreset($UnitFilePreset) |
||
| 788 | |||
| 789 | /** |
||
| 790 | * @return mixed |
||
| 791 | */ |
||
| 792 | public function getUnitFileState() |
||
| 796 | |||
| 797 | /** |
||
| 798 | * @param mixed $UnitFileState |
||
| 799 | * @return Scope |
||
| 800 | */ |
||
| 801 | public function setUnitFileState($UnitFileState) |
||
| 806 | } |
||
| 807 |