| Total Complexity | 40 |
| Total Lines | 142 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like Config 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.
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 Config, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | final class Config |
||
| 17 | { |
||
| 18 | /** @var int<0, max> */ |
||
| 19 | public int $bytesPerPart = 0; |
||
| 20 | public bool $canContinue = true; |
||
| 21 | public string $tempDir = ''; |
||
| 22 | public string $targetDir = ''; |
||
| 23 | /** @var string|Interfaces\IUppTranslations|null */ |
||
| 24 | public $lang = null; |
||
| 25 | /** @var string|Interfaces\IOperations|null */ |
||
| 26 | public $target = null; |
||
| 27 | /** @var string|DrivingFile\DataEncoders\AEncoder|null */ |
||
| 28 | public $dataEncoder = null; |
||
| 29 | /** @var string|DrivingFile\DataModifiers\AModifier|null */ |
||
| 30 | public $dataModifier = null; |
||
| 31 | /** @var string|DrivingFile\KeyEncoders\AEncoder|null */ |
||
| 32 | public $keyEncoder = null; |
||
| 33 | /** @var string|DrivingFile\KeyModifiers\AModifier|null */ |
||
| 34 | public $keyModifier = null; |
||
| 35 | /** @var int|string|object|null */ |
||
| 36 | public $drivingFileStorage = null; |
||
| 37 | /** @var int|string|object|null */ |
||
| 38 | public $temporaryStorage = null; |
||
| 39 | /** @var string|Local\TemporaryStorage\KeyEncoders\AEncoder|null */ |
||
| 40 | public $temporaryEncoder = null; |
||
| 41 | /** @var int|string|object|null */ |
||
| 42 | public $finalStorage = null; |
||
| 43 | /** @var string|Local\FinalStorage\KeyEncoders\AEncoder|null */ |
||
| 44 | public $finalEncoder = null; |
||
| 45 | /** @var string|null */ |
||
| 46 | public ?string $checksum = null; |
||
| 47 | /** @var string|null */ |
||
| 48 | public ?string $decoder = null; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param array<string, string|int|bool|object|array<string|int|bool|object>|null> $params |
||
| 52 | */ |
||
| 53 | public function __construct(array $params) |
||
| 160 |