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 |
||
22 | class TaskResourceModel implements ResourceModelInterface |
||
23 | { |
||
24 | /** |
||
25 | * Task ID. |
||
26 | * |
||
27 | * Comment: Task 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, cannot be empty. |
||
50 | * |
||
51 | * @SA\Type("string") |
||
52 | * @SA\SerializedName("title") |
||
53 | * |
||
54 | * @var string|null |
||
55 | */ |
||
56 | protected $title; |
||
57 | |||
58 | /** |
||
59 | * Description. |
||
60 | * |
||
61 | * Comment: Optional |
||
62 | * |
||
63 | * @SA\Type("string") |
||
64 | * @SA\SerializedName("description") |
||
65 | * |
||
66 | * @var string|null |
||
67 | */ |
||
68 | protected $description; |
||
69 | |||
70 | /** |
||
71 | * Brief description. |
||
72 | * |
||
73 | * Comment: Optional |
||
74 | * |
||
75 | * @SA\Type("string") |
||
76 | * @SA\SerializedName("briefDescription") |
||
77 | * |
||
78 | * @var string|null |
||
79 | */ |
||
80 | protected $briefDescription; |
||
81 | |||
82 | /** |
||
83 | * List of task parent folder IDs. |
||
84 | * |
||
85 | * Comment: Folder ID list |
||
86 | * Comment: Optional |
||
87 | * |
||
88 | * @SA\Type("array<string>") |
||
89 | * @SA\SerializedName("parentIds") |
||
90 | * |
||
91 | * @var array|string[]|null |
||
92 | */ |
||
93 | protected $parentIds; |
||
94 | |||
95 | /** |
||
96 | * List of task super parent folder IDs. |
||
97 | * |
||
98 | * Comment: Folder ID list |
||
99 | * Comment: Optional |
||
100 | * |
||
101 | * @SA\Type("array<string>") |
||
102 | * @SA\SerializedName("superParentIds") |
||
103 | * |
||
104 | * @var array|string[]|null |
||
105 | */ |
||
106 | protected $superParentIds; |
||
107 | |||
108 | /** |
||
109 | * List of user IDs, who share the task. |
||
110 | * |
||
111 | * Comment: Contact ID list |
||
112 | * Comment: Optional |
||
113 | * |
||
114 | * @SA\Type("array<string>") |
||
115 | * @SA\SerializedName("sharedIds") |
||
116 | * |
||
117 | * @var array|string[]|null |
||
118 | */ |
||
119 | protected $sharedIds; |
||
120 | |||
121 | /** |
||
122 | * List of responsible user IDs. |
||
123 | * |
||
124 | * Comment: Contact ID list |
||
125 | * Comment: Optional |
||
126 | * |
||
127 | * @SA\Type("array<string>") |
||
128 | * @SA\SerializedName("responsibleIds") |
||
129 | * |
||
130 | * @var array|string[]|null |
||
131 | */ |
||
132 | protected $responsibleIds; |
||
133 | |||
134 | /** |
||
135 | * Status of task. |
||
136 | * |
||
137 | * Task Status, Enum: Active, Completed, Deferred, Cancelled |
||
138 | * |
||
139 | * @see \Zibios\WrikePhpLibrary\Enum\TaskStatusEnum |
||
140 | * |
||
141 | * @SA\Type("string") |
||
142 | * @SA\SerializedName("status") |
||
143 | * |
||
144 | * @var string|null |
||
145 | */ |
||
146 | protected $status; |
||
147 | |||
148 | /** |
||
149 | * Importance of task. |
||
150 | * |
||
151 | * Task Importance, Enum: High, Normal, Low |
||
152 | * |
||
153 | * @see \Zibios\WrikePhpLibrary\Enum\TaskImportanceEnum |
||
154 | * |
||
155 | * @SA\Type("string") |
||
156 | * @SA\SerializedName("importance") |
||
157 | * |
||
158 | * @var string|null |
||
159 | */ |
||
160 | protected $importance; |
||
161 | |||
162 | /** |
||
163 | * Created date. |
||
164 | * |
||
165 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
166 | * |
||
167 | * @SA\Type("DateTime<'Y-m-d\TH:i:s\Z'>") |
||
168 | * @SA\SerializedName("createdDate") |
||
169 | * |
||
170 | * @var \DateTime|null |
||
171 | */ |
||
172 | protected $createdDate; |
||
173 | |||
174 | /** |
||
175 | * Updated date. |
||
176 | * |
||
177 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
178 | * |
||
179 | * @SA\Type("DateTime<'Y-m-d\TH:i:s\Z'>") |
||
180 | * @SA\SerializedName("updatedDate") |
||
181 | * |
||
182 | * @var \DateTime|null |
||
183 | */ |
||
184 | protected $updatedDate; |
||
185 | |||
186 | /** |
||
187 | * Completed date, field is present for tasks with 'Completed' status. |
||
188 | * |
||
189 | * Format: yyyy-MM-dd'T'HH:mm:ss'Z' |
||
190 | * |
||
191 | * @SA\Type("DateTime<'Y-m-d\TH:i:s\Z'>") |
||
192 | * @SA\SerializedName("completedDate") |
||
193 | * |
||
194 | * @var \DateTime|null |
||
195 | */ |
||
196 | protected $completedDate; |
||
197 | |||
198 | /** |
||
199 | * Task dates. |
||
200 | * |
||
201 | * @SA\Type("Zibios\WrikePhpJmsserializer\Model\Common\TaskDatesModel") |
||
202 | * @SA\SerializedName("dates") |
||
203 | * |
||
204 | * @var TaskDatesModel|null |
||
205 | */ |
||
206 | protected $dates; |
||
207 | |||
208 | /** |
||
209 | * Task scope. |
||
210 | * |
||
211 | * Tree Scope, Enum: WsRoot, RbRoot, WsFolder, RbFolder, WsTask, RbTask |
||
212 | * |
||
213 | * @see \Zibios\WrikePhpLibrary\Enum\TreeScopeEnum |
||
214 | * |
||
215 | * @SA\Type("string") |
||
216 | * @SA\SerializedName("scope") |
||
217 | * |
||
218 | * @var string|null |
||
219 | */ |
||
220 | protected $scope; |
||
221 | |||
222 | /** |
||
223 | * List of author IDs (currently contains 1 element). |
||
224 | * |
||
225 | * Comment: Contact ID list |
||
226 | * Comment: Optional |
||
227 | * |
||
228 | * @SA\Type("array<string>") |
||
229 | * @SA\SerializedName("authorIds") |
||
230 | * |
||
231 | * @var array|string[]|null |
||
232 | */ |
||
233 | protected $authorIds; |
||
234 | |||
235 | /** |
||
236 | * Custom status ID. |
||
237 | * |
||
238 | * Comment: Custom status ID |
||
239 | * |
||
240 | * @SA\Type("string") |
||
241 | * @SA\SerializedName("customStatusId") |
||
242 | * |
||
243 | * @var string|null |
||
244 | */ |
||
245 | protected $customStatusId; |
||
246 | |||
247 | /** |
||
248 | * Has attachments. |
||
249 | * |
||
250 | * @SA\Type("boolean") |
||
251 | * @SA\SerializedName("hasAttachments") |
||
252 | * |
||
253 | * @var bool|null |
||
254 | */ |
||
255 | protected $hasAttachments; |
||
256 | |||
257 | /** |
||
258 | * Total count of task attachments. |
||
259 | * |
||
260 | * Comment: Optional |
||
261 | * |
||
262 | * @SA\Type("integer") |
||
263 | * @SA\SerializedName("attachmentCount") |
||
264 | * |
||
265 | * @var string|null |
||
266 | */ |
||
267 | protected $attachmentCount; |
||
268 | |||
269 | /** |
||
270 | * Link to open task in web workspace, if user has appropriate access. |
||
271 | * |
||
272 | * @SA\Type("string") |
||
273 | * @SA\SerializedName("permalink") |
||
274 | * |
||
275 | * @var string|null |
||
276 | */ |
||
277 | protected $permalink; |
||
278 | |||
279 | /** |
||
280 | * Ordering key that defines task order in tasklist. |
||
281 | * |
||
282 | * @SA\Type("string") |
||
283 | * @SA\SerializedName("priority") |
||
284 | * |
||
285 | * @var string|null |
||
286 | */ |
||
287 | protected $priority; |
||
288 | |||
289 | /** |
||
290 | * Is a task followed by me. |
||
291 | * |
||
292 | * Comment: Optional |
||
293 | * |
||
294 | * @SA\Type("boolean") |
||
295 | * @SA\SerializedName("followedByMe") |
||
296 | * |
||
297 | * @var bool|null |
||
298 | */ |
||
299 | protected $followedByMe; |
||
300 | |||
301 | /** |
||
302 | * List of user IDs, who follows task. |
||
303 | * |
||
304 | * Comment: Contact ID list |
||
305 | * Comment: Optional |
||
306 | * |
||
307 | * @SA\Type("array<string>") |
||
308 | * @SA\SerializedName("followerIds") |
||
309 | * |
||
310 | * @var array|string[]|null |
||
311 | */ |
||
312 | protected $followerIds; |
||
313 | |||
314 | /** |
||
315 | * Is a task recurrent. |
||
316 | * |
||
317 | * Comment: Optional |
||
318 | * |
||
319 | * @SA\Type("boolean") |
||
320 | * @SA\SerializedName("recurrent") |
||
321 | * |
||
322 | * @var bool|null |
||
323 | */ |
||
324 | protected $recurrent; |
||
325 | |||
326 | /** |
||
327 | * List of super task IDs. |
||
328 | * |
||
329 | * Comment: Task ID list |
||
330 | * Comment: Optional |
||
331 | * |
||
332 | * @SA\Type("array<string>") |
||
333 | * @SA\SerializedName("superTaskIds") |
||
334 | * |
||
335 | * @var array|string[]|null |
||
336 | */ |
||
337 | protected $superTaskIds; |
||
338 | |||
339 | /** |
||
340 | * List of subtask IDs. |
||
341 | * |
||
342 | * Comment: Task ID list |
||
343 | * Comment: Optional |
||
344 | * |
||
345 | * @SA\Type("array<string>") |
||
346 | * @SA\SerializedName("subTaskIds") |
||
347 | * |
||
348 | * @var array|string[]|null |
||
349 | */ |
||
350 | protected $subTaskIds; |
||
351 | |||
352 | /** |
||
353 | * List of dependency IDs. |
||
354 | * |
||
355 | * Comment: Dependency ID list |
||
356 | * Comment: Optional |
||
357 | * |
||
358 | * @SA\Type("array<string>") |
||
359 | * @SA\SerializedName("dependencyIds") |
||
360 | * |
||
361 | * @var array|string[]|null |
||
362 | */ |
||
363 | protected $dependencyIds; |
||
364 | |||
365 | /** |
||
366 | * List of task metadata entries. |
||
367 | * |
||
368 | * Metadata entry key-value pair |
||
369 | * Metadata entries are isolated on per-client (application) basis |
||
370 | * Comment: Optional |
||
371 | * |
||
372 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\MetadataModel>") |
||
373 | * @SA\SerializedName("metadata") |
||
374 | * |
||
375 | * @var array|MetadataModel[]|null |
||
376 | */ |
||
377 | protected $metadata; |
||
378 | |||
379 | /** |
||
380 | * Custom fields. |
||
381 | * |
||
382 | * Comment: Optional |
||
383 | * |
||
384 | * @SA\Type("array<Zibios\WrikePhpJmsserializer\Model\Common\CustomFieldModel>") |
||
385 | * @SA\SerializedName("customFields") |
||
386 | * |
||
387 | * @var array|CustomFieldModel[]|null |
||
388 | */ |
||
389 | protected $customFields; |
||
390 | |||
391 | /** |
||
392 | * @return null|string |
||
393 | */ |
||
394 | 1 | public function getId() |
|
398 | |||
399 | /** |
||
400 | * @param null|string $id |
||
401 | * |
||
402 | * @return $this |
||
403 | */ |
||
404 | 1 | public function setId($id) |
|
410 | |||
411 | /** |
||
412 | * @return null|string |
||
413 | */ |
||
414 | 1 | public function getAccountId() |
|
418 | |||
419 | /** |
||
420 | * @param null|string $accountId |
||
421 | * |
||
422 | * @return $this |
||
423 | */ |
||
424 | 1 | public function setAccountId($accountId) |
|
430 | |||
431 | /** |
||
432 | * @return null|string |
||
433 | */ |
||
434 | 1 | public function getTitle() |
|
438 | |||
439 | /** |
||
440 | * @param null|string $title |
||
441 | * |
||
442 | * @return $this |
||
443 | */ |
||
444 | 1 | public function setTitle($title) |
|
450 | |||
451 | /** |
||
452 | * @return null|string |
||
453 | */ |
||
454 | 1 | public function getDescription() |
|
458 | |||
459 | /** |
||
460 | * @param null|string $description |
||
461 | * |
||
462 | * @return $this |
||
463 | */ |
||
464 | 1 | public function setDescription($description) |
|
470 | |||
471 | /** |
||
472 | * @return null|string |
||
473 | */ |
||
474 | 1 | public function getBriefDescription() |
|
478 | |||
479 | /** |
||
480 | * @param null|string $briefDescription |
||
481 | * |
||
482 | * @return $this |
||
483 | */ |
||
484 | 1 | public function setBriefDescription($briefDescription) |
|
490 | |||
491 | /** |
||
492 | * @return array|null|\string[] |
||
493 | */ |
||
494 | 1 | public function getParentIds() |
|
498 | |||
499 | /** |
||
500 | * @param array|null|\string[] $parentIds |
||
501 | * |
||
502 | * @return $this |
||
503 | */ |
||
504 | 1 | public function setParentIds($parentIds) |
|
510 | |||
511 | /** |
||
512 | * @return array|null|\string[] |
||
513 | */ |
||
514 | 1 | public function getSuperParentIds() |
|
518 | |||
519 | /** |
||
520 | * @param array|null|\string[] $superParentIds |
||
521 | * |
||
522 | * @return $this |
||
523 | */ |
||
524 | 1 | public function setSuperParentIds($superParentIds) |
|
530 | |||
531 | /** |
||
532 | * @return array|null|\string[] |
||
533 | */ |
||
534 | 1 | public function getSharedIds() |
|
538 | |||
539 | /** |
||
540 | * @param array|null|\string[] $sharedIds |
||
541 | * |
||
542 | * @return $this |
||
543 | */ |
||
544 | 1 | public function setSharedIds($sharedIds) |
|
550 | |||
551 | /** |
||
552 | * @return array|null|\string[] |
||
553 | */ |
||
554 | 1 | public function getResponsibleIds() |
|
558 | |||
559 | /** |
||
560 | * @param array|null|\string[] $responsibleIds |
||
561 | * |
||
562 | * @return $this |
||
563 | */ |
||
564 | 1 | public function setResponsibleIds($responsibleIds) |
|
570 | |||
571 | /** |
||
572 | * @return null|string |
||
573 | */ |
||
574 | 1 | public function getStatus() |
|
578 | |||
579 | /** |
||
580 | * @param null|string $status |
||
581 | * |
||
582 | * @return $this |
||
583 | */ |
||
584 | 1 | public function setStatus($status) |
|
590 | |||
591 | /** |
||
592 | * @return null|string |
||
593 | */ |
||
594 | 1 | public function getImportance() |
|
598 | |||
599 | /** |
||
600 | * @param null|string $importance |
||
601 | * |
||
602 | * @return $this |
||
603 | */ |
||
604 | 1 | public function setImportance($importance) |
|
610 | |||
611 | /** |
||
612 | * @return \DateTime|null |
||
613 | */ |
||
614 | 1 | public function getCreatedDate() |
|
618 | |||
619 | /** |
||
620 | * @param \DateTime|null $createdDate |
||
621 | * |
||
622 | * @return $this |
||
623 | */ |
||
624 | 1 | public function setCreatedDate($createdDate) |
|
630 | |||
631 | /** |
||
632 | * @return \DateTime|null |
||
633 | */ |
||
634 | 1 | public function getUpdatedDate() |
|
638 | |||
639 | /** |
||
640 | * @param \DateTime|null $updatedDate |
||
641 | * |
||
642 | * @return $this |
||
643 | */ |
||
644 | 1 | public function setUpdatedDate($updatedDate) |
|
650 | |||
651 | /** |
||
652 | * @return \DateTime|null |
||
653 | */ |
||
654 | 1 | public function getCompletedDate() |
|
658 | |||
659 | /** |
||
660 | * @param \DateTime|null $completedDate |
||
661 | * |
||
662 | * @return $this |
||
663 | */ |
||
664 | 1 | public function setCompletedDate($completedDate) |
|
670 | |||
671 | /** |
||
672 | * @return null|TaskDatesModel |
||
673 | */ |
||
674 | 1 | public function getDates() |
|
678 | |||
679 | /** |
||
680 | * @param null|TaskDatesModel $dates |
||
681 | * |
||
682 | * @return $this |
||
683 | */ |
||
684 | 1 | public function setDates($dates) |
|
690 | |||
691 | /** |
||
692 | * @return null|string |
||
693 | */ |
||
694 | 1 | public function getScope() |
|
698 | |||
699 | /** |
||
700 | * @param null|string $scope |
||
701 | * |
||
702 | * @return $this |
||
703 | */ |
||
704 | 1 | public function setScope($scope) |
|
710 | |||
711 | /** |
||
712 | * @return array|null|\string[] |
||
713 | */ |
||
714 | 1 | public function getAuthorIds() |
|
718 | |||
719 | /** |
||
720 | * @param array|null|\string[] $authorIds |
||
721 | * |
||
722 | * @return $this |
||
723 | */ |
||
724 | 1 | public function setAuthorIds($authorIds) |
|
730 | |||
731 | /** |
||
732 | * @return null|string |
||
733 | */ |
||
734 | 1 | public function getCustomStatusId() |
|
738 | |||
739 | /** |
||
740 | * @param null|string $customStatusId |
||
741 | * |
||
742 | * @return $this |
||
743 | */ |
||
744 | 1 | public function setCustomStatusId($customStatusId) |
|
750 | |||
751 | /** |
||
752 | * @return bool|null |
||
753 | */ |
||
754 | 1 | public function getHasAttachments() |
|
758 | |||
759 | /** |
||
760 | * @param bool|null $hasAttachments |
||
761 | * |
||
762 | * @return $this |
||
763 | */ |
||
764 | 1 | public function setHasAttachments($hasAttachments) |
|
770 | |||
771 | /** |
||
772 | * @return null|string |
||
773 | */ |
||
774 | 1 | public function getAttachmentCount() |
|
778 | |||
779 | /** |
||
780 | * @param null|string $attachmentCount |
||
781 | * |
||
782 | * @return $this |
||
783 | */ |
||
784 | 1 | public function setAttachmentCount($attachmentCount) |
|
790 | |||
791 | /** |
||
792 | * @return null|string |
||
793 | */ |
||
794 | 1 | public function getPermalink() |
|
798 | |||
799 | /** |
||
800 | * @param null|string $permalink |
||
801 | * |
||
802 | * @return $this |
||
803 | */ |
||
804 | 1 | public function setPermalink($permalink) |
|
810 | |||
811 | /** |
||
812 | * @return null|string |
||
813 | */ |
||
814 | 1 | public function getPriority() |
|
818 | |||
819 | /** |
||
820 | * @param null|string $priority |
||
821 | * |
||
822 | * @return $this |
||
823 | */ |
||
824 | 1 | public function setPriority($priority) |
|
830 | |||
831 | /** |
||
832 | * @return bool|null |
||
833 | */ |
||
834 | 1 | public function getFollowedByMe() |
|
838 | |||
839 | /** |
||
840 | * @param bool|null $followedByMe |
||
841 | * |
||
842 | * @return $this |
||
843 | */ |
||
844 | 1 | public function setFollowedByMe($followedByMe) |
|
850 | |||
851 | /** |
||
852 | * @return array|null|\string[] |
||
853 | */ |
||
854 | 1 | public function getFollowerIds() |
|
858 | |||
859 | /** |
||
860 | * @param array|null|\string[] $followerIds |
||
861 | * |
||
862 | * @return $this |
||
863 | */ |
||
864 | 1 | public function setFollowerIds($followerIds) |
|
870 | |||
871 | /** |
||
872 | * @return bool|null |
||
873 | */ |
||
874 | 1 | public function getRecurrent() |
|
878 | |||
879 | /** |
||
880 | * @param bool|null $recurrent |
||
881 | * |
||
882 | * @return $this |
||
883 | */ |
||
884 | 1 | public function setRecurrent($recurrent) |
|
890 | |||
891 | /** |
||
892 | * @return array|null|\string[] |
||
893 | */ |
||
894 | 1 | public function getSuperTaskIds() |
|
898 | |||
899 | /** |
||
900 | * @param array|null|\string[] $superTaskIds |
||
901 | * |
||
902 | * @return $this |
||
903 | */ |
||
904 | 1 | public function setSuperTaskIds($superTaskIds) |
|
910 | |||
911 | /** |
||
912 | * @return array|null|\string[] |
||
913 | */ |
||
914 | 1 | public function getSubTaskIds() |
|
918 | |||
919 | /** |
||
920 | * @param array|null|\string[] $subTaskIds |
||
921 | * |
||
922 | * @return $this |
||
923 | */ |
||
924 | 1 | public function setSubTaskIds($subTaskIds) |
|
930 | |||
931 | /** |
||
932 | * @return array|null|\string[] |
||
933 | */ |
||
934 | 1 | public function getDependencyIds() |
|
938 | |||
939 | /** |
||
940 | * @param array|null|\string[] $dependencyIds |
||
941 | * |
||
942 | * @return $this |
||
943 | */ |
||
944 | 1 | public function setDependencyIds($dependencyIds) |
|
950 | |||
951 | /** |
||
952 | * @return array|null|MetadataModel[] |
||
953 | */ |
||
954 | 1 | public function getMetadata() |
|
958 | |||
959 | /** |
||
960 | * @param array|null|MetadataModel[] $metadata |
||
961 | * |
||
962 | * @return $this |
||
963 | */ |
||
964 | 1 | public function setMetadata($metadata) |
|
970 | |||
971 | /** |
||
972 | * @return array|null|CustomFieldModel[] |
||
973 | */ |
||
974 | 1 | public function getCustomFields() |
|
978 | |||
979 | /** |
||
980 | * @param array|null|CustomFieldModel[] $customFields |
||
981 | * |
||
982 | * @return $this |
||
983 | */ |
||
984 | 1 | public function setCustomFields($customFields) |
|
990 | } |
||
991 |