Complex classes like TaskResourceModel 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 TaskResourceModel, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
28 | class TaskResourceModel extends AbstractModel implements ResourceModelInterface |
||
29 | { |
||
30 | /** |
||
31 | * Task ID. |
||
32 | * |
||
33 | * Comment: Task ID |
||
34 | * |
||
35 | * @SA\Type("string") |
||
36 | * @SA\SerializedName("id") |
||
37 | * |
||
38 | * @var string|null |
||
39 | */ |
||
40 | protected $id; |
||
41 | |||
42 | /** |
||
43 | * Account ID. |
||
44 | * |
||
45 | * Comment: Account ID |
||
46 | * |
||
47 | * @SA\Type("string") |
||
48 | * @SA\SerializedName("accountId") |
||
49 | * |
||
50 | * @var string|null |
||
51 | */ |
||
52 | protected $accountId; |
||
53 | |||
54 | /** |
||
55 | * Title, cannot be empty. |
||
56 | * |
||
57 | * @SA\Type("string") |
||
58 | * @SA\SerializedName("title") |
||
59 | * |
||
60 | * @var string|null |
||
61 | */ |
||
62 | protected $title; |
||
63 | |||
64 | /** |
||
65 | * Description. |
||
66 | * |
||
67 | * Comment: Optional |
||
68 | * |
||
69 | * @SA\Type("string") |
||
70 | * @SA\SerializedName("description") |
||
71 | * |
||
72 | * @var string|null |
||
73 | */ |
||
74 | protected $description; |
||
75 | |||
76 | /** |
||
77 | * Brief description. |
||
78 | * |
||
79 | * Comment: Optional |
||
80 | * |
||
81 | * @SA\Type("string") |
||
82 | * @SA\SerializedName("briefDescription") |
||
83 | * |
||
84 | * @var string|null |
||
85 | */ |
||
86 | protected $briefDescription; |
||
87 | |||
88 | /** |
||
89 | * List of task parent folder IDs. |
||
90 | * |
||
91 | * Comment: Folder ID list |
||
92 | * Comment: Optional |
||
93 | * |
||
94 | * @SA\Type("array<string>") |
||
95 | * @SA\SerializedName("parentIds") |
||
96 | * |
||
97 | * @var array|string[]|null |
||
98 | */ |
||
99 | protected $parentIds; |
||
100 | |||
101 | /** |
||
102 | * List of task super parent folder IDs. |
||
103 | * |
||
104 | * Comment: Folder ID list |
||
105 | * Comment: Optional |
||
106 | * |
||
107 | * @SA\Type("array<string>") |
||
108 | * @SA\SerializedName("superParentIds") |
||
109 | * |
||
110 | * @var array|string[]|null |
||
111 | */ |
||
112 | protected $superParentIds; |
||
113 | |||
114 | /** |
||
115 | * List of user IDs, who share the task. |
||
116 | * |
||
117 | * Comment: Contact ID list |
||
118 | * Comment: Optional |
||
119 | * |
||
120 | * @SA\Type("array<string>") |
||
121 | * @SA\SerializedName("sharedIds") |
||
122 | * |
||
123 | * @var array|string[]|null |
||
124 | */ |
||
125 | protected $sharedIds; |
||
126 | |||
127 | /** |
||
128 | * List of responsible user IDs. |
||
129 | * |
||
130 | * Comment: Contact ID list |
||
131 | * Comment: Optional |
||
132 | * |
||
133 | * @SA\Type("array<string>") |
||
134 | * @SA\SerializedName("responsibleIds") |
||
135 | * |
||
136 | * @var array|string[]|null |
||
137 | */ |
||
138 | protected $responsibleIds; |
||
139 | |||
140 | /** |
||
141 | * Status of task. |
||
142 | * |
||
143 | * Task Status, Enum: Active, Completed, Deferred, Cancelled |
||
144 | * |
||
145 | * @see \Zibios\WrikePhpLibrary\Enum\TaskStatusEnum |
||
146 | * |
||
147 | * @SA\Type("string") |
||
148 | * @SA\SerializedName("status") |
||
149 | * |
||
150 | * @var string|null |
||
151 | */ |
||
152 | protected $status; |
||
153 | |||
154 | /** |
||
155 | * Importance of task. |
||
156 | * |
||
157 | * Task Importance, Enum: High, Normal, Low |
||
158 | * |
||
159 | * @see \Zibios\WrikePhpLibrary\Enum\TaskImportanceEnum |
||
160 | * |
||
161 | * @SA\Type("string") |
||
162 | * @SA\SerializedName("importance") |
||
163 | * |
||
164 | * @var string|null |
||
165 | */ |
||
166 | protected $importance; |
||
167 | |||
168 | /** |
||
169 | * Created date. |
||
170 | * |
||
171 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
172 | * |
||
173 | * @SA\Type("string") |
||
174 | * @SA\SerializedName("createdDate") |
||
175 | * |
||
176 | * @var string|null |
||
177 | */ |
||
178 | protected $createdDate; |
||
179 | |||
180 | /** |
||
181 | * Updated date. |
||
182 | * |
||
183 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
184 | * |
||
185 | * @SA\Type("string") |
||
186 | * @SA\SerializedName("updatedDate") |
||
187 | * |
||
188 | * @var string|null |
||
189 | */ |
||
190 | protected $updatedDate; |
||
191 | |||
192 | /** |
||
193 | * Completed date, field is present for tasks with 'Completed' status. |
||
194 | * |
||
195 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
196 | * |
||
197 | * @SA\Type("string") |
||
198 | * @SA\SerializedName("completedDate") |
||
199 | * |
||
200 | * @var string|null |
||
201 | */ |
||
202 | protected $completedDate; |
||
203 | |||
204 | /** |
||
205 | * Task dates. |
||
206 | * |
||
207 | * @SA\Type("Zibios\WrikePhpJmsserializer\Model\Common\TaskDatesModel") |
||
208 | * @SA\SerializedName("dates") |
||
209 | * |
||
210 | * @var TaskDatesModel|null |
||
211 | */ |
||
212 | protected $dates; |
||
213 | |||
214 | /** |
||
215 | * Task scope. |
||
216 | * |
||
217 | * Tree Scope, Enum: WsRoot, RbRoot, WsFolder, RbFolder, WsTask, RbTask |
||
218 | * |
||
219 | * @see \Zibios\WrikePhpLibrary\Enum\TreeScopeEnum |
||
220 | * |
||
221 | * @SA\Type("string") |
||
222 | * @SA\SerializedName("scope") |
||
223 | * |
||
224 | * @var string|null |
||
225 | */ |
||
226 | protected $scope; |
||
227 | |||
228 | /** |
||
229 | * List of author IDs (currently contains 1 element). |
||
230 | * |
||
231 | * Comment: Contact ID list |
||
232 | * Comment: Optional |
||
233 | * |
||
234 | * @SA\Type("array<string>") |
||
235 | * @SA\SerializedName("authorIds") |
||
236 | * |
||
237 | * @var array|string[]|null |
||
238 | */ |
||
239 | protected $authorIds; |
||
240 | |||
241 | /** |
||
242 | * Custom status ID. |
||
243 | * |
||
244 | * Comment: Custom status ID |
||
245 | * |
||
246 | * @SA\Type("string") |
||
247 | * @SA\SerializedName("customStatusId") |
||
248 | * |
||
249 | * @var string|null |
||
250 | */ |
||
251 | protected $customStatusId; |
||
252 | |||
253 | /** |
||
254 | * Has attachments. |
||
255 | * |
||
256 | * @SA\Type("boolean") |
||
257 | * @SA\SerializedName("hasAttachments") |
||
258 | * |
||
259 | * @var bool|null |
||
260 | */ |
||
261 | protected $hasAttachments; |
||
262 | |||
263 | /** |
||
264 | * Total count of task attachments. |
||
265 | * |
||
266 | * Comment: Optional |
||
267 | * |
||
268 | * @SA\Type("integer") |
||
269 | * @SA\SerializedName("attachmentCount") |
||
270 | * |
||
271 | * @var string|null |
||
272 | */ |
||
273 | protected $attachmentCount; |
||
274 | |||
275 | /** |
||
276 | * Link to open task in web workspace, if user has appropriate access. |
||
277 | * |
||
278 | * @SA\Type("string") |
||
279 | * @SA\SerializedName("permalink") |
||
280 | * |
||
281 | * @var string|null |
||
282 | */ |
||
283 | protected $permalink; |
||
284 | |||
285 | /** |
||
286 | * Ordering key that defines task order in tasklist. |
||
287 | * |
||
288 | * @SA\Type("string") |
||
289 | * @SA\SerializedName("priority") |
||
290 | * |
||
291 | * @var string|null |
||
292 | */ |
||
293 | protected $priority; |
||
294 | |||
295 | /** |
||
296 | * Is a task followed by me. |
||
297 | * |
||
298 | * Comment: Optional |
||
299 | * |
||
300 | * @SA\Type("boolean") |
||
301 | * @SA\SerializedName("followedByMe") |
||
302 | * |
||
303 | * @var bool|null |
||
304 | */ |
||
305 | protected $followedByMe; |
||
306 | |||
307 | /** |
||
308 | * List of user IDs, who follows task. |
||
309 | * |
||
310 | * Comment: Contact ID list |
||
311 | * Comment: Optional |
||
312 | * |
||
313 | * @SA\Type("array<string>") |
||
314 | * @SA\SerializedName("followerIds") |
||
315 | * |
||
316 | * @var array|string[]|null |
||
317 | */ |
||
318 | protected $followerIds; |
||
319 | |||
320 | /** |
||
321 | * Is a task recurrent. |
||
322 | * |
||
323 | * Comment: Optional |
||
324 | * |
||
325 | * @SA\Type("boolean") |
||
326 | * @SA\SerializedName("recurrent") |
||
327 | * |
||
328 | * @var bool|null |
||
329 | */ |
||
330 | protected $recurrent; |
||
331 | |||
332 | /** |
||
333 | * List of super task IDs. |
||
334 | * |
||
335 | * Comment: Task ID list |
||
336 | * Comment: Optional |
||
337 | * |
||
338 | * @SA\Type("array<string>") |
||
339 | * @SA\SerializedName("superTaskIds") |
||
340 | * |
||
341 | * @var array|string[]|null |
||
342 | */ |
||
343 | protected $superTaskIds; |
||
344 | |||
345 | /** |
||
346 | * List of subtask IDs. |
||
347 | * |
||
348 | * Comment: Task ID list |
||
349 | * Comment: Optional |
||
350 | * |
||
351 | * @SA\Type("array<string>") |
||
352 | * @SA\SerializedName("subTaskIds") |
||
353 | * |
||
354 | * @var array|string[]|null |
||
355 | */ |
||
356 | protected $subTaskIds; |
||
357 | |||
358 | /** |
||
359 | * List of dependency IDs. |
||
360 | * |
||
361 | * Comment: Dependency ID list |
||
362 | * Comment: Optional |
||
363 | * |
||
364 | * @SA\Type("array<string>") |
||
365 | * @SA\SerializedName("dependencyIds") |
||
366 | * |
||
367 | * @var array|string[]|null |
||
368 | */ |
||
369 | protected $dependencyIds; |
||
370 | |||
371 | /** |
||
372 | * List of task metadata entries. |
||
373 | * |
||
374 | * Metadata entry key-value pair |
||
375 | * Metadata entries are isolated on per-client (application) basis |
||
376 | * Comment: Optional |
||
377 | * |
||
378 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\MetadataModel>") |
||
379 | * @SA\SerializedName("metadata") |
||
380 | * |
||
381 | * @var array|MetadataModel[]|null |
||
382 | */ |
||
383 | protected $metadata; |
||
384 | |||
385 | /** |
||
386 | * Custom fields. |
||
387 | * |
||
388 | * Comment: Optional |
||
389 | * |
||
390 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\CustomFieldModel>") |
||
391 | * @SA\SerializedName("customFields") |
||
392 | * |
||
393 | * @var array|CustomFieldModel[]|null |
||
394 | */ |
||
395 | protected $customFields; |
||
396 | |||
397 | /** |
||
398 | * @return null|string |
||
399 | */ |
||
400 | 1 | public function getId() |
|
404 | |||
405 | /** |
||
406 | * @param null|string $id |
||
407 | * |
||
408 | * @return $this |
||
409 | */ |
||
410 | 1 | public function setId($id) |
|
416 | |||
417 | /** |
||
418 | * @return null|string |
||
419 | */ |
||
420 | 1 | public function getAccountId() |
|
424 | |||
425 | /** |
||
426 | * @param null|string $accountId |
||
427 | * |
||
428 | * @return $this |
||
429 | */ |
||
430 | 1 | public function setAccountId($accountId) |
|
436 | |||
437 | /** |
||
438 | * @return null|string |
||
439 | */ |
||
440 | 1 | public function getTitle() |
|
444 | |||
445 | /** |
||
446 | * @param null|string $title |
||
447 | * |
||
448 | * @return $this |
||
449 | */ |
||
450 | 1 | public function setTitle($title) |
|
456 | |||
457 | /** |
||
458 | * @return null|string |
||
459 | */ |
||
460 | 1 | public function getDescription() |
|
464 | |||
465 | /** |
||
466 | * @param null|string $description |
||
467 | * |
||
468 | * @return $this |
||
469 | */ |
||
470 | 1 | public function setDescription($description) |
|
476 | |||
477 | /** |
||
478 | * @return null|string |
||
479 | */ |
||
480 | 1 | public function getBriefDescription() |
|
484 | |||
485 | /** |
||
486 | * @param null|string $briefDescription |
||
487 | * |
||
488 | * @return $this |
||
489 | */ |
||
490 | 1 | public function setBriefDescription($briefDescription) |
|
496 | |||
497 | /** |
||
498 | * @return array|null|\string[] |
||
499 | */ |
||
500 | 1 | public function getParentIds() |
|
504 | |||
505 | /** |
||
506 | * @param array|null|\string[] $parentIds |
||
507 | * |
||
508 | * @return $this |
||
509 | */ |
||
510 | 1 | public function setParentIds($parentIds) |
|
516 | |||
517 | /** |
||
518 | * @return array|null|\string[] |
||
519 | */ |
||
520 | 1 | public function getSuperParentIds() |
|
524 | |||
525 | /** |
||
526 | * @param array|null|\string[] $superParentIds |
||
527 | * |
||
528 | * @return $this |
||
529 | */ |
||
530 | 1 | public function setSuperParentIds($superParentIds) |
|
536 | |||
537 | /** |
||
538 | * @return array|null|\string[] |
||
539 | */ |
||
540 | 1 | public function getSharedIds() |
|
544 | |||
545 | /** |
||
546 | * @param array|null|\string[] $sharedIds |
||
547 | * |
||
548 | * @return $this |
||
549 | */ |
||
550 | 1 | public function setSharedIds($sharedIds) |
|
556 | |||
557 | /** |
||
558 | * @return array|null|\string[] |
||
559 | */ |
||
560 | 1 | public function getResponsibleIds() |
|
564 | |||
565 | /** |
||
566 | * @param array|null|\string[] $responsibleIds |
||
567 | * |
||
568 | * @return $this |
||
569 | */ |
||
570 | 1 | public function setResponsibleIds($responsibleIds) |
|
576 | |||
577 | /** |
||
578 | * @return null|string |
||
579 | */ |
||
580 | 1 | public function getStatus() |
|
584 | |||
585 | /** |
||
586 | * @param null|string $status |
||
587 | * |
||
588 | * @return $this |
||
589 | */ |
||
590 | 1 | public function setStatus($status) |
|
596 | |||
597 | /** |
||
598 | * @return null|string |
||
599 | */ |
||
600 | 1 | public function getImportance() |
|
604 | |||
605 | /** |
||
606 | * @param null|string $importance |
||
607 | * |
||
608 | * @return $this |
||
609 | */ |
||
610 | 1 | public function setImportance($importance) |
|
616 | |||
617 | /** |
||
618 | * @return string|null |
||
619 | */ |
||
620 | 1 | public function getCreatedDate() |
|
624 | |||
625 | /** |
||
626 | * @param string|null $createdDate |
||
627 | * |
||
628 | * @return $this |
||
629 | */ |
||
630 | 1 | public function setCreatedDate($createdDate) |
|
636 | |||
637 | /** |
||
638 | * @return string|null |
||
639 | */ |
||
640 | 1 | public function getUpdatedDate() |
|
644 | |||
645 | /** |
||
646 | * @param string|null $updatedDate |
||
647 | * |
||
648 | * @return $this |
||
649 | */ |
||
650 | 1 | public function setUpdatedDate($updatedDate) |
|
656 | |||
657 | /** |
||
658 | * @return string|null |
||
659 | */ |
||
660 | 1 | public function getCompletedDate() |
|
664 | |||
665 | /** |
||
666 | * @param string|null $completedDate |
||
667 | * |
||
668 | * @return $this |
||
669 | */ |
||
670 | 1 | public function setCompletedDate($completedDate) |
|
676 | |||
677 | /** |
||
678 | * @return null|TaskDatesModel |
||
679 | */ |
||
680 | 1 | public function getDates() |
|
684 | |||
685 | /** |
||
686 | * @param null|TaskDatesModel $dates |
||
687 | * |
||
688 | * @return $this |
||
689 | */ |
||
690 | 1 | public function setDates($dates) |
|
696 | |||
697 | /** |
||
698 | * @return null|string |
||
699 | */ |
||
700 | 1 | public function getScope() |
|
704 | |||
705 | /** |
||
706 | * @param null|string $scope |
||
707 | * |
||
708 | * @return $this |
||
709 | */ |
||
710 | 1 | public function setScope($scope) |
|
716 | |||
717 | /** |
||
718 | * @return array|null|\string[] |
||
719 | */ |
||
720 | 1 | public function getAuthorIds() |
|
724 | |||
725 | /** |
||
726 | * @param array|null|\string[] $authorIds |
||
727 | * |
||
728 | * @return $this |
||
729 | */ |
||
730 | 1 | public function setAuthorIds($authorIds) |
|
736 | |||
737 | /** |
||
738 | * @return null|string |
||
739 | */ |
||
740 | 1 | public function getCustomStatusId() |
|
744 | |||
745 | /** |
||
746 | * @param null|string $customStatusId |
||
747 | * |
||
748 | * @return $this |
||
749 | */ |
||
750 | 1 | public function setCustomStatusId($customStatusId) |
|
756 | |||
757 | /** |
||
758 | * @return bool|null |
||
759 | */ |
||
760 | 1 | public function getHasAttachments() |
|
764 | |||
765 | /** |
||
766 | * @param bool|null $hasAttachments |
||
767 | * |
||
768 | * @return $this |
||
769 | */ |
||
770 | 1 | public function setHasAttachments($hasAttachments) |
|
776 | |||
777 | /** |
||
778 | * @return null|string |
||
779 | */ |
||
780 | 1 | public function getAttachmentCount() |
|
784 | |||
785 | /** |
||
786 | * @param null|string $attachmentCount |
||
787 | * |
||
788 | * @return $this |
||
789 | */ |
||
790 | 1 | public function setAttachmentCount($attachmentCount) |
|
796 | |||
797 | /** |
||
798 | * @return null|string |
||
799 | */ |
||
800 | 1 | public function getPermalink() |
|
804 | |||
805 | /** |
||
806 | * @param null|string $permalink |
||
807 | * |
||
808 | * @return $this |
||
809 | */ |
||
810 | 1 | public function setPermalink($permalink) |
|
816 | |||
817 | /** |
||
818 | * @return null|string |
||
819 | */ |
||
820 | 1 | public function getPriority() |
|
824 | |||
825 | /** |
||
826 | * @param null|string $priority |
||
827 | * |
||
828 | * @return $this |
||
829 | */ |
||
830 | 1 | public function setPriority($priority) |
|
836 | |||
837 | /** |
||
838 | * @return bool|null |
||
839 | */ |
||
840 | 1 | public function getFollowedByMe() |
|
844 | |||
845 | /** |
||
846 | * @param bool|null $followedByMe |
||
847 | * |
||
848 | * @return $this |
||
849 | */ |
||
850 | 1 | public function setFollowedByMe($followedByMe) |
|
856 | |||
857 | /** |
||
858 | * @return array|null|\string[] |
||
859 | */ |
||
860 | 1 | public function getFollowerIds() |
|
864 | |||
865 | /** |
||
866 | * @param array|null|\string[] $followerIds |
||
867 | * |
||
868 | * @return $this |
||
869 | */ |
||
870 | 1 | public function setFollowerIds($followerIds) |
|
876 | |||
877 | /** |
||
878 | * @return bool|null |
||
879 | */ |
||
880 | 1 | public function getRecurrent() |
|
884 | |||
885 | /** |
||
886 | * @param bool|null $recurrent |
||
887 | * |
||
888 | * @return $this |
||
889 | */ |
||
890 | 1 | public function setRecurrent($recurrent) |
|
896 | |||
897 | /** |
||
898 | * @return array|null|\string[] |
||
899 | */ |
||
900 | 1 | public function getSuperTaskIds() |
|
904 | |||
905 | /** |
||
906 | * @param array|null|\string[] $superTaskIds |
||
907 | * |
||
908 | * @return $this |
||
909 | */ |
||
910 | 1 | public function setSuperTaskIds($superTaskIds) |
|
916 | |||
917 | /** |
||
918 | * @return array|null|\string[] |
||
919 | */ |
||
920 | 1 | public function getSubTaskIds() |
|
924 | |||
925 | /** |
||
926 | * @param array|null|\string[] $subTaskIds |
||
927 | * |
||
928 | * @return $this |
||
929 | */ |
||
930 | 1 | public function setSubTaskIds($subTaskIds) |
|
936 | |||
937 | /** |
||
938 | * @return array|null|\string[] |
||
939 | */ |
||
940 | 1 | public function getDependencyIds() |
|
944 | |||
945 | /** |
||
946 | * @param array|null|\string[] $dependencyIds |
||
947 | * |
||
948 | * @return $this |
||
949 | */ |
||
950 | 1 | public function setDependencyIds($dependencyIds) |
|
956 | |||
957 | /** |
||
958 | * @return array|null|MetadataModel[] |
||
959 | */ |
||
960 | 1 | public function getMetadata() |
|
964 | |||
965 | /** |
||
966 | * @param array|null|MetadataModel[] $metadata |
||
967 | * |
||
968 | * @return $this |
||
969 | */ |
||
970 | 1 | public function setMetadata($metadata) |
|
976 | |||
977 | /** |
||
978 | * @return array|null|CustomFieldModel[] |
||
979 | */ |
||
980 | 1 | public function getCustomFields() |
|
984 | |||
985 | /** |
||
986 | * @param array|null|CustomFieldModel[] $customFields |
||
987 | * |
||
988 | * @return $this |
||
989 | */ |
||
990 | 1 | public function setCustomFields($customFields) |
|
996 | } |
||
997 |