Complex classes like FolderResourceModel 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 FolderResourceModel, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
22 | class FolderResourceModel implements ResourceModelInterface |
||
23 | { |
||
24 | /** |
||
25 | * Folder ID. |
||
26 | * |
||
27 | * Comment: Folder ID |
||
28 | * |
||
29 | * @SA\Type("string") |
||
30 | * @SA\SerializedName("id") |
||
31 | * |
||
32 | * @var string|null |
||
33 | */ |
||
34 | protected $id; |
||
35 | |||
36 | /** |
||
37 | * Account ID. |
||
38 | * |
||
39 | * Comment: Account ID |
||
40 | * |
||
41 | * @SA\Type("string") |
||
42 | * @SA\SerializedName("accountId") |
||
43 | * |
||
44 | * @var string|null |
||
45 | */ |
||
46 | protected $accountId; |
||
47 | |||
48 | /** |
||
49 | * Title. |
||
50 | * |
||
51 | * @SA\Type("string") |
||
52 | * @SA\SerializedName("title") |
||
53 | * |
||
54 | * @var string|null |
||
55 | */ |
||
56 | protected $title; |
||
57 | |||
58 | /** |
||
59 | * Created date. |
||
60 | * |
||
61 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
62 | * |
||
63 | * @SA\Type("DateTime<'Y-m-d\TH:i:s\Z'>") |
||
64 | * @SA\SerializedName("createdDate") |
||
65 | * |
||
66 | * @var \DateTime|null |
||
67 | */ |
||
68 | protected $createdDate; |
||
69 | |||
70 | /** |
||
71 | * Updated date. |
||
72 | * |
||
73 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
74 | * |
||
75 | * @SA\Type("DateTime<'Y-m-d\TH:i:s\Z'>") |
||
76 | * @SA\SerializedName("updatedDate") |
||
77 | * |
||
78 | * @var \DateTime|null |
||
79 | */ |
||
80 | protected $updatedDate; |
||
81 | |||
82 | /** |
||
83 | * Brief description. |
||
84 | * |
||
85 | * Comment: Optional |
||
86 | * |
||
87 | * @SA\Type("string") |
||
88 | * @SA\SerializedName("briefDescription") |
||
89 | * |
||
90 | * @var string|null |
||
91 | */ |
||
92 | protected $briefDescription; |
||
93 | |||
94 | /** |
||
95 | * Description. |
||
96 | * |
||
97 | * @SA\Type("string") |
||
98 | * @SA\SerializedName("description") |
||
99 | * |
||
100 | * @var string|null |
||
101 | */ |
||
102 | protected $description; |
||
103 | |||
104 | /** |
||
105 | * Color. |
||
106 | * |
||
107 | * Folder color, Enum |
||
108 | * Comment: Optional |
||
109 | * |
||
110 | * @SA\Type("string") |
||
111 | * @SA\SerializedName("color") |
||
112 | * |
||
113 | * @var string|null |
||
114 | */ |
||
115 | protected $color; |
||
116 | |||
117 | /** |
||
118 | * List of user IDs, who share the folder. |
||
119 | * |
||
120 | * Comment: Contact ID list |
||
121 | * |
||
122 | * @SA\Type("array<string>") |
||
123 | * @SA\SerializedName("sharedIds") |
||
124 | * |
||
125 | * @var array|string[]|null |
||
126 | */ |
||
127 | protected $sharedIds; |
||
128 | |||
129 | /** |
||
130 | * List of parent folder IDs. |
||
131 | * |
||
132 | * Comment: Folder ID list |
||
133 | * |
||
134 | * @SA\Type("array<string>") |
||
135 | * @SA\SerializedName("parentIds") |
||
136 | * |
||
137 | * @var array|string[]|null |
||
138 | */ |
||
139 | protected $parentIds; |
||
140 | |||
141 | /** |
||
142 | * List of child folder IDs. |
||
143 | * |
||
144 | * Comment: Folder ID list |
||
145 | * |
||
146 | * @SA\Type("array<string>") |
||
147 | * @SA\SerializedName("childIds") |
||
148 | * |
||
149 | * @var array|string[]|null |
||
150 | */ |
||
151 | protected $childIds; |
||
152 | |||
153 | /** |
||
154 | * List of super parent folder IDs. |
||
155 | * |
||
156 | * Comment: Folder ID list |
||
157 | * |
||
158 | * @SA\Type("array<string>") |
||
159 | * @SA\SerializedName("superParentIds") |
||
160 | * |
||
161 | * @var array|string[]|null |
||
162 | */ |
||
163 | protected $superParentIds; |
||
164 | |||
165 | /** |
||
166 | * Folder scope. |
||
167 | * |
||
168 | * Folder scope, Enum |
||
169 | * |
||
170 | * @SA\Type("string") |
||
171 | * @SA\SerializedName("scope") |
||
172 | * |
||
173 | * @var string|null |
||
174 | */ |
||
175 | protected $scope; |
||
176 | |||
177 | /** |
||
178 | * True if folder has attachments. |
||
179 | * |
||
180 | * @SA\Type("boolean") |
||
181 | * @SA\SerializedName("hasAttachments") |
||
182 | * |
||
183 | * @var string|null |
||
184 | */ |
||
185 | protected $hasAttachments; |
||
186 | |||
187 | /** |
||
188 | * Total count of folder attachments. |
||
189 | * |
||
190 | * Comment: Optional |
||
191 | * |
||
192 | * @SA\Type("integer") |
||
193 | * @SA\SerializedName("attachmentCount") |
||
194 | * |
||
195 | * @var string|null |
||
196 | */ |
||
197 | protected $attachmentCount; |
||
198 | |||
199 | /** |
||
200 | * Link to open folder in web workspace, if user has appropriate access. |
||
201 | * |
||
202 | * @SA\Type("string") |
||
203 | * @SA\SerializedName("permalink") |
||
204 | * |
||
205 | * @var string|null |
||
206 | */ |
||
207 | protected $permalink; |
||
208 | |||
209 | /** |
||
210 | * Folder workflow ID. |
||
211 | * |
||
212 | * Comment: Workflow ID |
||
213 | * |
||
214 | * @SA\Type("string") |
||
215 | * @SA\SerializedName("workflowId") |
||
216 | * |
||
217 | * @var string|null |
||
218 | */ |
||
219 | protected $workflowId; |
||
220 | |||
221 | /** |
||
222 | * List of folder metadata entries. |
||
223 | * |
||
224 | * Metadata entry key-value pair |
||
225 | * Metadata entries are isolated on per-client (application) basis |
||
226 | * Comment: Optional |
||
227 | * |
||
228 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\MetadataModel>") |
||
229 | * @SA\SerializedName("metadata") |
||
230 | * |
||
231 | * @var array|MetadataModel[]|null |
||
232 | */ |
||
233 | protected $metadata; |
||
234 | |||
235 | /** |
||
236 | * Custom fields. |
||
237 | * |
||
238 | * Comment: Optional |
||
239 | * |
||
240 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\CustomFieldModel>") |
||
241 | * @SA\SerializedName("customFields") |
||
242 | * |
||
243 | * @var array|CustomFieldModel[]|null |
||
244 | */ |
||
245 | protected $customFields; |
||
246 | |||
247 | /** |
||
248 | * Custom column IDs. |
||
249 | * |
||
250 | * Comment: Optional |
||
251 | * Comment: Custom Field ID |
||
252 | * |
||
253 | * @SA\Type("array<string>") |
||
254 | * @SA\SerializedName("customColumnIds") |
||
255 | * |
||
256 | * @var array|string[]|null |
||
257 | */ |
||
258 | protected $customColumnIds; |
||
259 | |||
260 | /** |
||
261 | * Project details, present only for project folders. |
||
262 | * |
||
263 | * Comment: Optional |
||
264 | * |
||
265 | * @SA\Type("Zibios\WrikePhpJmsserializer\Model\Common\ProjectModel") |
||
266 | * @SA\SerializedName("project") |
||
267 | * |
||
268 | * @var ProjectModel|null |
||
269 | */ |
||
270 | protected $project; |
||
271 | |||
272 | /** |
||
273 | * @return null|string |
||
274 | */ |
||
275 | 1 | public function getId() |
|
279 | |||
280 | /** |
||
281 | * @param null|string $id |
||
282 | * |
||
283 | * @return $this |
||
284 | */ |
||
285 | 1 | public function setId($id) |
|
291 | |||
292 | /** |
||
293 | * @return null|string |
||
294 | */ |
||
295 | 1 | public function getAccountId() |
|
299 | |||
300 | /** |
||
301 | * @param null|string $accountId |
||
302 | * |
||
303 | * @return $this |
||
304 | */ |
||
305 | 1 | public function setAccountId($accountId) |
|
311 | |||
312 | /** |
||
313 | * @return null|string |
||
314 | */ |
||
315 | 1 | public function getTitle() |
|
319 | |||
320 | /** |
||
321 | * @param null|string $title |
||
322 | * |
||
323 | * @return $this |
||
324 | */ |
||
325 | 1 | public function setTitle($title) |
|
331 | |||
332 | /** |
||
333 | * @return \DateTime|null |
||
334 | */ |
||
335 | 1 | public function getCreatedDate() |
|
339 | |||
340 | /** |
||
341 | * @param \DateTime|null $createdDate |
||
342 | * |
||
343 | * @return $this |
||
344 | */ |
||
345 | 1 | public function setCreatedDate($createdDate) |
|
351 | |||
352 | /** |
||
353 | * @return \DateTime|null |
||
354 | */ |
||
355 | 1 | public function getUpdatedDate() |
|
359 | |||
360 | /** |
||
361 | * @param \DateTime|null $updatedDate |
||
362 | * |
||
363 | * @return $this |
||
364 | */ |
||
365 | 1 | public function setUpdatedDate($updatedDate) |
|
371 | |||
372 | /** |
||
373 | * @return null|string |
||
374 | */ |
||
375 | 1 | public function getBriefDescription() |
|
379 | |||
380 | /** |
||
381 | * @param null|string $briefDescription |
||
382 | * |
||
383 | * @return $this |
||
384 | */ |
||
385 | 1 | public function setBriefDescription($briefDescription) |
|
391 | |||
392 | /** |
||
393 | * @return null|string |
||
394 | */ |
||
395 | 1 | public function getDescription() |
|
399 | |||
400 | /** |
||
401 | * @param null|string $description |
||
402 | * |
||
403 | * @return $this |
||
404 | */ |
||
405 | 1 | public function setDescription($description) |
|
411 | |||
412 | /** |
||
413 | * @return null|string |
||
414 | */ |
||
415 | 1 | public function getColor() |
|
419 | |||
420 | /** |
||
421 | * @param null|string $color |
||
422 | * |
||
423 | * @return $this |
||
424 | */ |
||
425 | 1 | public function setColor($color) |
|
431 | |||
432 | /** |
||
433 | * @return array|null|\string[] |
||
434 | */ |
||
435 | 1 | public function getSharedIds() |
|
439 | |||
440 | /** |
||
441 | * @param array|null|\string[] $sharedIds |
||
442 | * |
||
443 | * @return $this |
||
444 | */ |
||
445 | 1 | public function setSharedIds($sharedIds) |
|
451 | |||
452 | /** |
||
453 | * @return array|null|\string[] |
||
454 | */ |
||
455 | 1 | public function getParentIds() |
|
459 | |||
460 | /** |
||
461 | * @param array|null|\string[] $parentIds |
||
462 | * |
||
463 | * @return $this |
||
464 | */ |
||
465 | 1 | public function setParentIds($parentIds) |
|
471 | |||
472 | /** |
||
473 | * @return array|null|\string[] |
||
474 | */ |
||
475 | 1 | public function getChildIds() |
|
479 | |||
480 | /** |
||
481 | * @param array|null|\string[] $childIds |
||
482 | * |
||
483 | * @return $this |
||
484 | */ |
||
485 | 1 | public function setChildIds($childIds) |
|
491 | |||
492 | /** |
||
493 | * @return array|null|\string[] |
||
494 | */ |
||
495 | 1 | public function getSuperParentIds() |
|
499 | |||
500 | /** |
||
501 | * @param array|null|\string[] $superParentIds |
||
502 | * |
||
503 | * @return $this |
||
504 | */ |
||
505 | 1 | public function setSuperParentIds($superParentIds) |
|
511 | |||
512 | /** |
||
513 | * @return null|string |
||
514 | */ |
||
515 | 1 | public function getScope() |
|
519 | |||
520 | /** |
||
521 | * @param null|string $scope |
||
522 | * |
||
523 | * @return $this |
||
524 | */ |
||
525 | 1 | public function setScope($scope) |
|
531 | |||
532 | /** |
||
533 | * @return null|string |
||
534 | */ |
||
535 | 1 | public function getHasAttachments() |
|
539 | |||
540 | /** |
||
541 | * @param null|string $hasAttachments |
||
542 | * |
||
543 | * @return $this |
||
544 | */ |
||
545 | 1 | public function setHasAttachments($hasAttachments) |
|
551 | |||
552 | /** |
||
553 | * @return null|string |
||
554 | */ |
||
555 | 1 | public function getAttachmentCount() |
|
559 | |||
560 | /** |
||
561 | * @param null|string $attachmentCount |
||
562 | * |
||
563 | * @return $this |
||
564 | */ |
||
565 | 1 | public function setAttachmentCount($attachmentCount) |
|
571 | |||
572 | /** |
||
573 | * @return null|string |
||
574 | */ |
||
575 | 1 | public function getPermalink() |
|
579 | |||
580 | /** |
||
581 | * @param null|string $permalink |
||
582 | * |
||
583 | * @return $this |
||
584 | */ |
||
585 | 1 | public function setPermalink($permalink) |
|
591 | |||
592 | /** |
||
593 | * @return null|string |
||
594 | */ |
||
595 | 1 | public function getWorkflowId() |
|
599 | |||
600 | /** |
||
601 | * @param null|string $workflowId |
||
602 | * |
||
603 | * @return $this |
||
604 | */ |
||
605 | 1 | public function setWorkflowId($workflowId) |
|
611 | |||
612 | /** |
||
613 | * @return array|null|MetadataModel[] |
||
614 | */ |
||
615 | 1 | public function getMetadata() |
|
619 | |||
620 | /** |
||
621 | * @param array|null|MetadataModel[] $metadata |
||
622 | * |
||
623 | * @return $this |
||
624 | */ |
||
625 | 1 | public function setMetadata($metadata) |
|
631 | |||
632 | /** |
||
633 | * @return array|null|CustomFieldModel[] |
||
634 | */ |
||
635 | 1 | public function getCustomFields() |
|
639 | |||
640 | /** |
||
641 | * @param array|null|CustomFieldModel[] $customFields |
||
642 | * |
||
643 | * @return $this |
||
644 | */ |
||
645 | 1 | public function setCustomFields($customFields) |
|
651 | |||
652 | /** |
||
653 | * @return array|null|\string[] |
||
654 | */ |
||
655 | 1 | public function getCustomColumnIds() |
|
659 | |||
660 | /** |
||
661 | * @param array|null|\string[] $customColumnIds |
||
662 | * |
||
663 | * @return $this |
||
664 | */ |
||
665 | 1 | public function setCustomColumnIds($customColumnIds) |
|
671 | |||
672 | /** |
||
673 | * @return null|ProjectModel |
||
674 | */ |
||
675 | 1 | public function getProject() |
|
679 | |||
680 | /** |
||
681 | * @param null|ProjectModel $project |
||
682 | * |
||
683 | * @return $this |
||
684 | */ |
||
685 | 1 | public function setProject($project) |
|
691 | } |
||
692 |