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 |
||
7 | final class FacadeCisItemResponse |
||
8 | { |
||
9 | public const STATUS_EMITTED = 'EMITTED'; |
||
10 | public const STATUS_APPLIED = 'APPLIED'; |
||
11 | public const STATUS_INTRODUCED = 'INTRODUCED'; |
||
12 | public const STATUS_WRITTEN_OFF = 'WRITTEN_OFF'; |
||
13 | public const STATUS_RETIRED = 'RETIRED'; |
||
14 | public const STATUS_DISAGGREGATION = 'DISAGGREGATION'; |
||
15 | |||
16 | /** @var string */ |
||
17 | private $cis; |
||
18 | /** @var string|null */ |
||
19 | private $gtin = null; |
||
20 | /** @var string|null */ |
||
21 | private $producerName = null; |
||
22 | /** @var string */ |
||
23 | private $status; |
||
24 | /** @var string */ |
||
25 | private $emissionDate; |
||
26 | /** @var string */ |
||
27 | private $emissionType; |
||
28 | /** @var string|null */ |
||
29 | private $producedDate = null; |
||
30 | /** @var string|null */ |
||
31 | private $packType; |
||
32 | /** @var string|null */ |
||
33 | private $ownerName = null; |
||
34 | /** @var string|null */ |
||
35 | private $ownerInn = null; |
||
36 | /** @var string|null */ |
||
37 | private $productName = null; |
||
38 | /** @var string|null */ |
||
39 | private $brand = null; |
||
40 | /** @var string[]|null */ |
||
41 | private $prevCises = null; |
||
42 | /** @var string[]|null */ |
||
43 | private $nextCises = null; |
||
44 | /** @var string|null */ |
||
45 | private $statusEx = null; |
||
46 | /** @var FacadeCisItemResponse[] */ |
||
47 | private $children = []; |
||
48 | /** @var int|null */ |
||
49 | private $countChildren = null; |
||
50 | /**ъ @var string|null */ |
||
51 | private $parent= null; |
||
52 | /** @var string|null */ |
||
53 | private $lastDocId= null; |
||
54 | /** @var string|null */ |
||
55 | private $introductionDate= null; |
||
56 | /** @var string|null */ |
||
57 | private $agentInn= null; |
||
58 | /** @var string|null */ |
||
59 | private $agentName= null; |
||
60 | /** @var string */ |
||
61 | private $lastStatusChangeDate; |
||
62 | /** @var string|null */ |
||
63 | private $turnoverType= null; |
||
64 | /** @var string */ |
||
65 | private $productGroup; |
||
66 | /** @var string|null */ |
||
67 | private $tnVed10= null; |
||
68 | /** @var bool|null */ |
||
69 | private $markWithdraw = null; |
||
70 | |||
71 | 1 | public function getCis(): string |
|
75 | |||
76 | 1 | public function setCis(string $cis): void |
|
80 | |||
81 | public function getGtin(): ?string |
||
85 | |||
86 | public function setGtin(?string $gtin): void |
||
90 | |||
91 | public function getProducerName(): ?string |
||
95 | |||
96 | public function setProducerName(?string $producerName): void |
||
100 | |||
101 | public function getStatus(): string |
||
105 | |||
106 | public function setStatus(string $status): void |
||
110 | |||
111 | public function getEmissionDate(): string |
||
115 | |||
116 | public function setEmissionDate(string $emissionDate): void |
||
120 | |||
121 | public function getEmissionType(): string |
||
125 | |||
126 | public function setEmissionType(string $emissionType): void |
||
130 | |||
131 | public function getProducedDate(): ?string |
||
135 | |||
136 | public function setProducedDate(?string $producedDate): void |
||
140 | |||
141 | public function getPackType(): string |
||
145 | |||
146 | public function setPackType(string $packType): void |
||
150 | |||
151 | public function getOwnerName(): ?string |
||
155 | |||
156 | public function setOwnerName(?string $ownerName): void |
||
160 | |||
161 | public function getOwnerInn(): ?string |
||
165 | |||
166 | public function setOwnerInn(?string $ownerInn): void |
||
170 | |||
171 | public function getProductName(): ?string |
||
175 | |||
176 | public function setProductName(?string $productName): void |
||
180 | |||
181 | public function getBrand(): ?string |
||
185 | |||
186 | public function setBrand(?string $brand): void |
||
190 | |||
191 | public function getPrevCises(): ?array |
||
195 | |||
196 | public function setPrevCises(?array $prevCises): void |
||
200 | |||
201 | public function getNextCises(): ?array |
||
205 | |||
206 | public function setNextCises(?array $nextCises): void |
||
210 | |||
211 | public function getStatusEx(): ?string |
||
215 | |||
216 | public function setStatusEx(?string $statusEx): void |
||
220 | |||
221 | public function getChildren(): ?array |
||
225 | |||
226 | public function setChildren(array $children): void |
||
230 | |||
231 | public function getCountChildren(): ?int |
||
235 | |||
236 | public function setCountChildren(?int $countChildren): void |
||
240 | |||
241 | public function getParent(): ?string |
||
245 | |||
246 | public function setParent(?string $parent): void |
||
250 | |||
251 | public function getLastDocId(): ?string |
||
255 | |||
256 | public function setLastDocId(?string $lastDocId): void |
||
260 | |||
261 | public function getIntroductionDate(): ?string |
||
265 | |||
266 | public function setIntroductionDate(?string $introductionDate): void |
||
270 | |||
271 | public function getAgentInn(): ?string |
||
275 | |||
276 | public function setAgentInn(?string $agentInn): void |
||
280 | |||
281 | public function getAgentName(): ?string |
||
285 | |||
286 | public function setAgentName(?string $agentName): void |
||
290 | |||
291 | public function getLastStatusChangeDate(): string |
||
295 | |||
296 | public function setLastStatusChangeDate(string $lastStatusChangeDate): void |
||
300 | |||
301 | public function getTurnoverType(): ?string |
||
305 | |||
306 | public function setTurnoverType(?string $turnoverType): void |
||
310 | |||
311 | public function getProductGroup(): string |
||
315 | |||
316 | public function setProductGroup(string $productGroup): void |
||
320 | |||
321 | public function getTnVed10(): ?string |
||
325 | |||
326 | public function setTnVed10(?string $tnVed10): void |
||
330 | |||
331 | public function getMarkWithdraw(): ?bool |
||
335 | |||
336 | public function setMarkWithdraw(?bool $markWithdraw): void |
||
340 | } |
||
341 |