Complex classes like FacadeCisItemResponse 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 FacadeCisItemResponse, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 9 | final class FacadeCisItemResponse |
||
| 10 | { |
||
| 11 | public const STATUS_EMITTED = 'EMITTED'; |
||
| 12 | public const STATUS_APPLIED = 'APPLIED'; |
||
| 13 | public const STATUS_INTRODUCED = 'INTRODUCED'; |
||
| 14 | public const STATUS_WRITTEN_OFF = 'WRITTEN_OFF'; |
||
| 15 | public const STATUS_RETIRED = 'RETIRED'; |
||
| 16 | public const STATUS_DISAGGREGATION = 'DISAGGREGATION'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $cis; |
||
| 22 | /** |
||
| 23 | * @var string|null |
||
| 24 | */ |
||
| 25 | private $gtin = null; |
||
| 26 | /** |
||
| 27 | * @var string|null |
||
| 28 | * @SerializedName("producerName") |
||
| 29 | */ |
||
| 30 | private $producerName = null; |
||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | private $status; |
||
| 35 | /** |
||
| 36 | * @var string |
||
| 37 | * @SerializedName("emissionDate") |
||
| 38 | */ |
||
| 39 | private $emissionDate; |
||
| 40 | /** @var string */ |
||
| 41 | private $emissionType; |
||
| 42 | /** @var string|null */ |
||
| 43 | private $producedDate = null; |
||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | * @SerializedName("packType") |
||
| 47 | */ |
||
| 48 | private $packType; |
||
| 49 | /** |
||
| 50 | * @var string|null |
||
| 51 | * @SerializedName("ownerName") |
||
| 52 | */ |
||
| 53 | private $ownerName = null; |
||
| 54 | /** |
||
| 55 | * @var string|null |
||
| 56 | * @SerializedName("ownerInn") |
||
| 57 | */ |
||
| 58 | private $ownerInn = null; |
||
| 59 | /** |
||
| 60 | * @var string|null |
||
| 61 | * @SerializedName("productName") |
||
| 62 | */ |
||
| 63 | private $productName = null; |
||
| 64 | /** |
||
| 65 | * @var string|null |
||
| 66 | */ |
||
| 67 | private $brand = null; |
||
| 68 | /** @var string[]|null */ |
||
| 69 | private $prevCises = null; |
||
| 70 | /** @var string[]|null */ |
||
| 71 | private $nextCises = null; |
||
| 72 | /** @var string|null */ |
||
| 73 | private $statusEx = null; |
||
| 74 | /** |
||
| 75 | * @var FacadeCisItemResponse[] |
||
| 76 | */ |
||
| 77 | private $children = []; |
||
| 78 | /** |
||
| 79 | * @var int|null |
||
| 80 | * @SerializedName("countChildren") |
||
| 81 | */ |
||
| 82 | private $countChildren = null; |
||
| 83 | /** |
||
| 84 | * @var string|null |
||
| 85 | */ |
||
| 86 | private $parent= null; |
||
| 87 | /** |
||
| 88 | * @var string|null |
||
| 89 | * @SerializedName("agentInn") |
||
| 90 | */ |
||
| 91 | private $lastDocId= null; |
||
| 92 | /** @var string|null */ |
||
| 93 | private $introductionDate= null; |
||
| 94 | /** @var string|null */ |
||
| 95 | private $agentInn= null; |
||
| 96 | /** |
||
| 97 | * @var string|null |
||
| 98 | * @SerializedName("agentName") |
||
| 99 | */ |
||
| 100 | private $agentName= null; |
||
| 101 | /** @var string */ |
||
| 102 | private $lastStatusChangeDate; |
||
| 103 | /** @var string|null */ |
||
| 104 | private $turnoverType= null; |
||
| 105 | /** @var string */ |
||
| 106 | private $productGroup; |
||
| 107 | /** @var string|null */ |
||
| 108 | private $tnVed10= null; |
||
| 109 | /** @var bool|null */ |
||
| 110 | private $markWithdraw = null; |
||
| 111 | |||
| 112 | 1 | public function getCis(): string |
|
| 116 | |||
| 117 | 1 | public function setCis(string $cis): void |
|
| 121 | |||
| 122 | public function getGtin(): ?string |
||
| 126 | |||
| 127 | public function setGtin(?string $gtin): void |
||
| 131 | |||
| 132 | public function getProducerName(): ?string |
||
| 136 | |||
| 137 | public function setProducerName(?string $producerName): void |
||
| 141 | |||
| 142 | public function getStatus(): string |
||
| 146 | |||
| 147 | public function setStatus(string $status): void |
||
| 151 | |||
| 152 | public function getEmissionDate(): string |
||
| 156 | |||
| 157 | public function setEmissionDate(string $emissionDate): void |
||
| 161 | |||
| 162 | public function getEmissionType(): string |
||
| 166 | |||
| 167 | public function setEmissionType(string $emissionType): void |
||
| 171 | |||
| 172 | public function getProducedDate(): ?string |
||
| 176 | |||
| 177 | public function setProducedDate(?string $producedDate): void |
||
| 181 | |||
| 182 | public function getPackType(): string |
||
| 186 | |||
| 187 | public function setPackType(string $packType): void |
||
| 191 | |||
| 192 | public function getOwnerName(): ?string |
||
| 196 | |||
| 197 | public function setOwnerName(?string $ownerName): void |
||
| 201 | |||
| 202 | public function getOwnerInn(): ?string |
||
| 206 | |||
| 207 | public function setOwnerInn(?string $ownerInn): void |
||
| 211 | |||
| 212 | public function getProductName(): ?string |
||
| 216 | |||
| 217 | public function setProductName(?string $productName): void |
||
| 221 | |||
| 222 | public function getBrand(): ?string |
||
| 226 | |||
| 227 | public function setBrand(?string $brand): void |
||
| 231 | |||
| 232 | public function getPrevCises(): ?array |
||
| 236 | |||
| 237 | public function setPrevCises(?array $prevCises): void |
||
| 241 | |||
| 242 | public function getNextCises(): ?array |
||
| 246 | |||
| 247 | public function setNextCises(?array $nextCises): void |
||
| 251 | |||
| 252 | public function getStatusEx(): ?string |
||
| 256 | |||
| 257 | public function setStatusEx(?string $statusEx): void |
||
| 261 | |||
| 262 | public function getChildren(): ?array |
||
| 266 | |||
| 267 | public function setChildren(array $children): void |
||
| 271 | |||
| 272 | public function getCountChildren(): ?int |
||
| 276 | |||
| 277 | public function setCountChildren(?int $countChildren): void |
||
| 281 | |||
| 282 | public function getParent(): ?string |
||
| 286 | |||
| 287 | public function setParent(?string $parent): void |
||
| 291 | |||
| 292 | public function getLastDocId(): ?string |
||
| 296 | |||
| 297 | public function setLastDocId(?string $lastDocId): void |
||
| 301 | |||
| 302 | public function getIntroductionDate(): ?string |
||
| 306 | |||
| 307 | public function setIntroductionDate(?string $introductionDate): void |
||
| 311 | |||
| 312 | public function getAgentInn(): ?string |
||
| 316 | |||
| 317 | public function setAgentInn(?string $agentInn): void |
||
| 321 | |||
| 322 | public function getAgentName(): ?string |
||
| 326 | |||
| 327 | public function setAgentName(?string $agentName): void |
||
| 331 | |||
| 332 | public function getLastStatusChangeDate(): string |
||
| 336 | |||
| 337 | public function setLastStatusChangeDate(string $lastStatusChangeDate): void |
||
| 341 | |||
| 342 | public function getTurnoverType(): ?string |
||
| 346 | |||
| 347 | public function setTurnoverType(?string $turnoverType): void |
||
| 351 | |||
| 352 | public function getProductGroup(): string |
||
| 356 | |||
| 357 | public function setProductGroup(string $productGroup): void |
||
| 361 | |||
| 362 | public function getTnVed10(): ?string |
||
| 366 | |||
| 367 | public function setTnVed10(?string $tnVed10): void |
||
| 371 | |||
| 372 | public function getMarkWithdraw(): ?bool |
||
| 376 | |||
| 377 | public function setMarkWithdraw(?bool $markWithdraw): void |
||
| 381 | } |
||
| 382 |