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 |
||
26 | class FolderResourceModel extends AbstractModel implements ResourceModelInterface |
||
27 | { |
||
28 | /** |
||
29 | * Folder ID. |
||
30 | * |
||
31 | * Comment: Folder ID |
||
32 | * |
||
33 | * @SA\Type("string") |
||
34 | * @SA\SerializedName("id") |
||
35 | * |
||
36 | * @var string|null |
||
37 | */ |
||
38 | protected $id; |
||
39 | |||
40 | /** |
||
41 | * Account ID. |
||
42 | * |
||
43 | * Comment: Account ID |
||
44 | * |
||
45 | * @SA\Type("string") |
||
46 | * @SA\SerializedName("accountId") |
||
47 | * |
||
48 | * @var string|null |
||
49 | */ |
||
50 | protected $accountId; |
||
51 | |||
52 | /** |
||
53 | * Title. |
||
54 | * |
||
55 | * @SA\Type("string") |
||
56 | * @SA\SerializedName("title") |
||
57 | * |
||
58 | * @var string|null |
||
59 | */ |
||
60 | protected $title; |
||
61 | |||
62 | /** |
||
63 | * Created date. |
||
64 | * |
||
65 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
66 | * |
||
67 | * @SA\Type("string") |
||
68 | * @SA\SerializedName("createdDate") |
||
69 | * |
||
70 | * @var string|null |
||
71 | */ |
||
72 | protected $createdDate; |
||
73 | |||
74 | /** |
||
75 | * Updated date. |
||
76 | * |
||
77 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
78 | * |
||
79 | * @SA\Type("string") |
||
80 | * @SA\SerializedName("updatedDate") |
||
81 | * |
||
82 | * @var string|null |
||
83 | */ |
||
84 | protected $updatedDate; |
||
85 | |||
86 | /** |
||
87 | * Brief description. |
||
88 | * |
||
89 | * Comment: Optional |
||
90 | * |
||
91 | * @SA\Type("string") |
||
92 | * @SA\SerializedName("briefDescription") |
||
93 | * |
||
94 | * @var string|null |
||
95 | */ |
||
96 | protected $briefDescription; |
||
97 | |||
98 | /** |
||
99 | * Description. |
||
100 | * |
||
101 | * @SA\Type("string") |
||
102 | * @SA\SerializedName("description") |
||
103 | * |
||
104 | * @var string|null |
||
105 | */ |
||
106 | protected $description; |
||
107 | |||
108 | /** |
||
109 | * Color. |
||
110 | * |
||
111 | * Folder color, Enum |
||
112 | * Comment: Optional |
||
113 | * |
||
114 | * @SA\Type("string") |
||
115 | * @SA\SerializedName("color") |
||
116 | * |
||
117 | * @var string|null |
||
118 | */ |
||
119 | protected $color; |
||
120 | |||
121 | /** |
||
122 | * List of user IDs, who share the folder. |
||
123 | * |
||
124 | * Comment: Contact ID list |
||
125 | * |
||
126 | * @SA\Type("array<string>") |
||
127 | * @SA\SerializedName("sharedIds") |
||
128 | * |
||
129 | * @var array|string[]|null |
||
130 | */ |
||
131 | protected $sharedIds; |
||
132 | |||
133 | /** |
||
134 | * List of parent folder IDs. |
||
135 | * |
||
136 | * Comment: Folder ID list |
||
137 | * |
||
138 | * @SA\Type("array<string>") |
||
139 | * @SA\SerializedName("parentIds") |
||
140 | * |
||
141 | * @var array|string[]|null |
||
142 | */ |
||
143 | protected $parentIds; |
||
144 | |||
145 | /** |
||
146 | * List of child folder IDs. |
||
147 | * |
||
148 | * Comment: Folder ID list |
||
149 | * |
||
150 | * @SA\Type("array<string>") |
||
151 | * @SA\SerializedName("childIds") |
||
152 | * |
||
153 | * @var array|string[]|null |
||
154 | */ |
||
155 | protected $childIds; |
||
156 | |||
157 | /** |
||
158 | * List of super parent folder IDs. |
||
159 | * |
||
160 | * Comment: Folder ID list |
||
161 | * |
||
162 | * @SA\Type("array<string>") |
||
163 | * @SA\SerializedName("superParentIds") |
||
164 | * |
||
165 | * @var array|string[]|null |
||
166 | */ |
||
167 | protected $superParentIds; |
||
168 | |||
169 | /** |
||
170 | * Folder scope. |
||
171 | * |
||
172 | * Folder scope, Enum |
||
173 | * |
||
174 | * @SA\Type("string") |
||
175 | * @SA\SerializedName("scope") |
||
176 | * |
||
177 | * @var string|null |
||
178 | */ |
||
179 | protected $scope; |
||
180 | |||
181 | /** |
||
182 | * True if folder has attachments. |
||
183 | * |
||
184 | * @SA\Type("boolean") |
||
185 | * @SA\SerializedName("hasAttachments") |
||
186 | * |
||
187 | * @var string|null |
||
188 | */ |
||
189 | protected $hasAttachments; |
||
190 | |||
191 | /** |
||
192 | * Total count of folder attachments. |
||
193 | * |
||
194 | * Comment: Optional |
||
195 | * |
||
196 | * @SA\Type("integer") |
||
197 | * @SA\SerializedName("attachmentCount") |
||
198 | * |
||
199 | * @var string|null |
||
200 | */ |
||
201 | protected $attachmentCount; |
||
202 | |||
203 | /** |
||
204 | * Link to open folder in web workspace, if user has appropriate access. |
||
205 | * |
||
206 | * @SA\Type("string") |
||
207 | * @SA\SerializedName("permalink") |
||
208 | * |
||
209 | * @var string|null |
||
210 | */ |
||
211 | protected $permalink; |
||
212 | |||
213 | /** |
||
214 | * Folder workflow ID. |
||
215 | * |
||
216 | * Comment: Workflow ID |
||
217 | * |
||
218 | * @SA\Type("string") |
||
219 | * @SA\SerializedName("workflowId") |
||
220 | * |
||
221 | * @var string|null |
||
222 | */ |
||
223 | protected $workflowId; |
||
224 | |||
225 | /** |
||
226 | * List of folder metadata entries. |
||
227 | * |
||
228 | * Metadata entry key-value pair |
||
229 | * Metadata entries are isolated on per-client (application) basis |
||
230 | * Comment: Optional |
||
231 | * |
||
232 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\MetadataModel>") |
||
233 | * @SA\SerializedName("metadata") |
||
234 | * |
||
235 | * @var array|MetadataModel[]|null |
||
236 | */ |
||
237 | protected $metadata; |
||
238 | |||
239 | /** |
||
240 | * Custom fields. |
||
241 | * |
||
242 | * Comment: Optional |
||
243 | * |
||
244 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\CustomFieldModel>") |
||
245 | * @SA\SerializedName("customFields") |
||
246 | * |
||
247 | * @var array|CustomFieldModel[]|null |
||
248 | */ |
||
249 | protected $customFields; |
||
250 | |||
251 | /** |
||
252 | * Custom column IDs. |
||
253 | * |
||
254 | * Comment: Optional |
||
255 | * Comment: Custom Field ID |
||
256 | * |
||
257 | * @SA\Type("array<string>") |
||
258 | * @SA\SerializedName("customColumnIds") |
||
259 | * |
||
260 | * @var array|string[]|null |
||
261 | */ |
||
262 | protected $customColumnIds; |
||
263 | |||
264 | /** |
||
265 | * Project details, present only for project folders. |
||
266 | * |
||
267 | * Comment: Optional |
||
268 | * |
||
269 | * @SA\Type("Zibios\WrikePhpJmsserializer\Model\Common\ProjectModel") |
||
270 | * @SA\SerializedName("project") |
||
271 | * |
||
272 | * @var ProjectModel|null |
||
273 | */ |
||
274 | protected $project; |
||
275 | |||
276 | /** |
||
277 | * @return null|string |
||
278 | */ |
||
279 | 1 | public function getId() |
|
283 | |||
284 | /** |
||
285 | * @param null|string $id |
||
286 | * |
||
287 | * @return $this |
||
288 | */ |
||
289 | 1 | public function setId($id) |
|
295 | |||
296 | /** |
||
297 | * @return null|string |
||
298 | */ |
||
299 | 1 | public function getAccountId() |
|
303 | |||
304 | /** |
||
305 | * @param null|string $accountId |
||
306 | * |
||
307 | * @return $this |
||
308 | */ |
||
309 | 1 | public function setAccountId($accountId) |
|
315 | |||
316 | /** |
||
317 | * @return null|string |
||
318 | */ |
||
319 | 1 | public function getTitle() |
|
323 | |||
324 | /** |
||
325 | * @param null|string $title |
||
326 | * |
||
327 | * @return $this |
||
328 | */ |
||
329 | 1 | public function setTitle($title) |
|
335 | |||
336 | /** |
||
337 | * @return string|null |
||
338 | */ |
||
339 | 1 | public function getCreatedDate() |
|
343 | |||
344 | /** |
||
345 | * @param string|null $createdDate |
||
346 | * |
||
347 | * @return $this |
||
348 | */ |
||
349 | 1 | public function setCreatedDate($createdDate) |
|
355 | |||
356 | /** |
||
357 | * @return string|null |
||
358 | */ |
||
359 | 1 | public function getUpdatedDate() |
|
363 | |||
364 | /** |
||
365 | * @param string|null $updatedDate |
||
366 | * |
||
367 | * @return $this |
||
368 | */ |
||
369 | 1 | public function setUpdatedDate($updatedDate) |
|
375 | |||
376 | /** |
||
377 | * @return null|string |
||
378 | */ |
||
379 | 1 | public function getBriefDescription() |
|
383 | |||
384 | /** |
||
385 | * @param null|string $briefDescription |
||
386 | * |
||
387 | * @return $this |
||
388 | */ |
||
389 | 1 | public function setBriefDescription($briefDescription) |
|
395 | |||
396 | /** |
||
397 | * @return null|string |
||
398 | */ |
||
399 | 1 | public function getDescription() |
|
403 | |||
404 | /** |
||
405 | * @param null|string $description |
||
406 | * |
||
407 | * @return $this |
||
408 | */ |
||
409 | 1 | public function setDescription($description) |
|
415 | |||
416 | /** |
||
417 | * @return null|string |
||
418 | */ |
||
419 | 1 | public function getColor() |
|
423 | |||
424 | /** |
||
425 | * @param null|string $color |
||
426 | * |
||
427 | * @return $this |
||
428 | */ |
||
429 | 1 | public function setColor($color) |
|
435 | |||
436 | /** |
||
437 | * @return array|null|\string[] |
||
438 | */ |
||
439 | 1 | public function getSharedIds() |
|
443 | |||
444 | /** |
||
445 | * @param array|null|\string[] $sharedIds |
||
446 | * |
||
447 | * @return $this |
||
448 | */ |
||
449 | 1 | public function setSharedIds($sharedIds) |
|
455 | |||
456 | /** |
||
457 | * @return array|null|\string[] |
||
458 | */ |
||
459 | 1 | public function getParentIds() |
|
463 | |||
464 | /** |
||
465 | * @param array|null|\string[] $parentIds |
||
466 | * |
||
467 | * @return $this |
||
468 | */ |
||
469 | 1 | public function setParentIds($parentIds) |
|
475 | |||
476 | /** |
||
477 | * @return array|null|\string[] |
||
478 | */ |
||
479 | 1 | public function getChildIds() |
|
483 | |||
484 | /** |
||
485 | * @param array|null|\string[] $childIds |
||
486 | * |
||
487 | * @return $this |
||
488 | */ |
||
489 | 1 | public function setChildIds($childIds) |
|
495 | |||
496 | /** |
||
497 | * @return array|null|\string[] |
||
498 | */ |
||
499 | 1 | public function getSuperParentIds() |
|
503 | |||
504 | /** |
||
505 | * @param array|null|\string[] $superParentIds |
||
506 | * |
||
507 | * @return $this |
||
508 | */ |
||
509 | 1 | public function setSuperParentIds($superParentIds) |
|
515 | |||
516 | /** |
||
517 | * @return null|string |
||
518 | */ |
||
519 | 1 | public function getScope() |
|
523 | |||
524 | /** |
||
525 | * @param null|string $scope |
||
526 | * |
||
527 | * @return $this |
||
528 | */ |
||
529 | 1 | public function setScope($scope) |
|
535 | |||
536 | /** |
||
537 | * @return null|string |
||
538 | */ |
||
539 | 1 | public function getHasAttachments() |
|
543 | |||
544 | /** |
||
545 | * @param null|string $hasAttachments |
||
546 | * |
||
547 | * @return $this |
||
548 | */ |
||
549 | 1 | public function setHasAttachments($hasAttachments) |
|
555 | |||
556 | /** |
||
557 | * @return null|string |
||
558 | */ |
||
559 | 1 | public function getAttachmentCount() |
|
563 | |||
564 | /** |
||
565 | * @param null|string $attachmentCount |
||
566 | * |
||
567 | * @return $this |
||
568 | */ |
||
569 | 1 | public function setAttachmentCount($attachmentCount) |
|
575 | |||
576 | /** |
||
577 | * @return null|string |
||
578 | */ |
||
579 | 1 | public function getPermalink() |
|
583 | |||
584 | /** |
||
585 | * @param null|string $permalink |
||
586 | * |
||
587 | * @return $this |
||
588 | */ |
||
589 | 1 | public function setPermalink($permalink) |
|
595 | |||
596 | /** |
||
597 | * @return null|string |
||
598 | */ |
||
599 | 1 | public function getWorkflowId() |
|
603 | |||
604 | /** |
||
605 | * @param null|string $workflowId |
||
606 | * |
||
607 | * @return $this |
||
608 | */ |
||
609 | 1 | public function setWorkflowId($workflowId) |
|
615 | |||
616 | /** |
||
617 | * @return array|null|MetadataModel[] |
||
618 | */ |
||
619 | 1 | public function getMetadata() |
|
623 | |||
624 | /** |
||
625 | * @param array|null|MetadataModel[] $metadata |
||
626 | * |
||
627 | * @return $this |
||
628 | */ |
||
629 | 1 | public function setMetadata($metadata) |
|
635 | |||
636 | /** |
||
637 | * @return array|null|CustomFieldModel[] |
||
638 | */ |
||
639 | 1 | public function getCustomFields() |
|
643 | |||
644 | /** |
||
645 | * @param array|null|CustomFieldModel[] $customFields |
||
646 | * |
||
647 | * @return $this |
||
648 | */ |
||
649 | 1 | public function setCustomFields($customFields) |
|
655 | |||
656 | /** |
||
657 | * @return array|null|\string[] |
||
658 | */ |
||
659 | 1 | public function getCustomColumnIds() |
|
663 | |||
664 | /** |
||
665 | * @param array|null|\string[] $customColumnIds |
||
666 | * |
||
667 | * @return $this |
||
668 | */ |
||
669 | 1 | public function setCustomColumnIds($customColumnIds) |
|
675 | |||
676 | /** |
||
677 | * @return null|ProjectModel |
||
678 | */ |
||
679 | 1 | public function getProject() |
|
683 | |||
684 | /** |
||
685 | * @param null|ProjectModel $project |
||
686 | * |
||
687 | * @return $this |
||
688 | */ |
||
689 | 1 | public function setProject($project) |
|
695 | } |
||
696 |