Complex classes like Configuration 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 Configuration, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
18 | class Configuration extends AbstractModel implements ConfigurationInterface |
||
19 | { |
||
20 | /** |
||
21 | * Type. |
||
22 | * |
||
23 | * @var string |
||
24 | * @db |
||
25 | */ |
||
26 | protected $type = self::TYPE_TIME; |
||
27 | |||
28 | /** |
||
29 | * Handling. |
||
30 | * |
||
31 | * @var string |
||
32 | * @db |
||
33 | */ |
||
34 | protected $handling = self::HANDLING_INCLUDE; |
||
35 | |||
36 | /** |
||
37 | * State. |
||
38 | * |
||
39 | * @var string |
||
40 | * @db |
||
41 | */ |
||
42 | protected $state = self::STATE_DEFAULT; |
||
43 | |||
44 | /** |
||
45 | * Start date. |
||
46 | * |
||
47 | * @var \DateTime |
||
48 | * @db |
||
49 | */ |
||
50 | protected $startDate; |
||
51 | |||
52 | /** |
||
53 | * End date. |
||
54 | * |
||
55 | * @var \DateTime |
||
56 | * @db |
||
57 | */ |
||
58 | protected $endDate; |
||
59 | |||
60 | /** |
||
61 | * End date dynamic. |
||
62 | * |
||
63 | * @var string |
||
64 | * @db |
||
65 | */ |
||
66 | protected $endDateDynamic; |
||
67 | |||
68 | /** |
||
69 | * Start time. |
||
70 | * |
||
71 | * @var int |
||
72 | * @db |
||
73 | */ |
||
74 | protected $startTime; |
||
75 | |||
76 | /** |
||
77 | * End time. |
||
78 | * |
||
79 | * @var int |
||
80 | * @db |
||
81 | */ |
||
82 | protected $endTime; |
||
83 | |||
84 | /** |
||
85 | * AllDay. |
||
86 | * |
||
87 | * @var bool |
||
88 | * @db |
||
89 | */ |
||
90 | protected $allDay; |
||
91 | |||
92 | /** |
||
93 | * OpenEndTime. |
||
94 | * |
||
95 | * @var bool |
||
96 | * @db |
||
97 | */ |
||
98 | protected $openEndTime; |
||
99 | |||
100 | /** |
||
101 | * External ICS url. |
||
102 | * |
||
103 | * @var string |
||
104 | * @db |
||
105 | */ |
||
106 | protected $externalIcsUrl; |
||
107 | |||
108 | /** |
||
109 | * Groups. |
||
110 | * |
||
111 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HDNET\Calendarize\Domain\Model\ConfigurationGroup> |
||
112 | * @db text |
||
113 | * @lazy |
||
114 | * @TYPO3\CMS\Extbase\Annotation\ORM\Lazy |
||
115 | */ |
||
116 | protected $groups; |
||
117 | |||
118 | /** |
||
119 | * Frequency. |
||
120 | * |
||
121 | * @var string |
||
122 | * @db |
||
123 | */ |
||
124 | protected $frequency = self::FREQUENCY_NONE; |
||
125 | |||
126 | /** |
||
127 | * Till date. |
||
128 | * |
||
129 | * @var \DateTime |
||
130 | * @db |
||
131 | */ |
||
132 | protected $tillDate; |
||
133 | |||
134 | /** |
||
135 | * Till days. |
||
136 | * |
||
137 | * @var int |
||
138 | * @db int(11) |
||
139 | */ |
||
140 | protected $tillDays; |
||
141 | |||
142 | /** |
||
143 | * Till days relative. |
||
144 | * |
||
145 | * @var bool |
||
146 | * @db tinyint(4) unsigned |
||
147 | */ |
||
148 | protected $tillDaysRelative; |
||
149 | |||
150 | /** |
||
151 | * Till days past. |
||
152 | * |
||
153 | * @var int |
||
154 | * @db int(11) |
||
155 | */ |
||
156 | protected $tillDaysPast; |
||
157 | |||
158 | /** |
||
159 | * Counter amount. |
||
160 | * |
||
161 | * @var int |
||
162 | * @db |
||
163 | */ |
||
164 | protected $counterAmount; |
||
165 | |||
166 | /** |
||
167 | * Counter interval. |
||
168 | * |
||
169 | * @var int |
||
170 | * @db |
||
171 | */ |
||
172 | protected $counterInterval; |
||
173 | |||
174 | /** |
||
175 | * Recurrence. |
||
176 | * |
||
177 | * @var string |
||
178 | * @db |
||
179 | */ |
||
180 | protected $recurrence = self::RECURRENCE_NONE; |
||
181 | |||
182 | /** |
||
183 | * Day property. |
||
184 | * |
||
185 | * @var string |
||
186 | * @db |
||
187 | */ |
||
188 | protected $day = self::DAY_NONE; |
||
189 | |||
190 | /** |
||
191 | * Import ID if the item is based on an ICS structure. |
||
192 | * |
||
193 | * @var string |
||
194 | * @db |
||
195 | */ |
||
196 | protected $importId; |
||
197 | |||
198 | /** |
||
199 | * Configuration constructor. |
||
200 | */ |
||
201 | public function __construct() |
||
205 | |||
206 | /** |
||
207 | * Get type. |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getType() |
||
215 | |||
216 | /** |
||
217 | * Set type. |
||
218 | * |
||
219 | * @param string $type |
||
220 | */ |
||
221 | public function setType($type) |
||
225 | |||
226 | /** |
||
227 | * Is all day. |
||
228 | * |
||
229 | * @return bool |
||
230 | */ |
||
231 | public function isAllDay() |
||
235 | |||
236 | /** |
||
237 | * Set all day. |
||
238 | * |
||
239 | * @param bool $allDay |
||
240 | */ |
||
241 | public function setAllDay($allDay) |
||
245 | |||
246 | /** |
||
247 | * Get end date. |
||
248 | * |
||
249 | * @return \DateTime |
||
250 | */ |
||
251 | public function getEndDate() |
||
259 | |||
260 | /** |
||
261 | * Set end date. |
||
262 | * |
||
263 | * @param \DateTime $endDate |
||
264 | */ |
||
265 | public function setEndDate($endDate) |
||
269 | |||
270 | /** |
||
271 | * Get end date dynamic. |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | public function getEndDateDynamic() |
||
279 | |||
280 | /** |
||
281 | * Set end date dynamic. |
||
282 | * |
||
283 | * @param string $endDateDynamic |
||
284 | */ |
||
285 | public function setEndDateDynamic($endDateDynamic) |
||
289 | |||
290 | /** |
||
291 | * Get end time. |
||
292 | * |
||
293 | * @return int |
||
294 | */ |
||
295 | public function getEndTime() |
||
299 | |||
300 | /** |
||
301 | * Set end time. |
||
302 | * |
||
303 | * @param int $endTime |
||
304 | */ |
||
305 | public function setEndTime($endTime) |
||
309 | |||
310 | /** |
||
311 | * Get start date. |
||
312 | * |
||
313 | * @return \DateTime |
||
314 | */ |
||
315 | public function getStartDate() |
||
323 | |||
324 | /** |
||
325 | * Set start date. |
||
326 | * |
||
327 | * @param \DateTime $startDate |
||
328 | */ |
||
329 | public function setStartDate($startDate) |
||
333 | |||
334 | /** |
||
335 | * Get start time. |
||
336 | * |
||
337 | * @return int |
||
338 | */ |
||
339 | public function getStartTime() |
||
343 | |||
344 | /** |
||
345 | * Set start time. |
||
346 | * |
||
347 | * @param int $startTime |
||
348 | */ |
||
349 | public function setStartTime($startTime) |
||
353 | |||
354 | /** |
||
355 | * Get groups. |
||
356 | * |
||
357 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
358 | */ |
||
359 | public function getGroups() |
||
367 | |||
368 | /** |
||
369 | * Set groups. |
||
370 | * |
||
371 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $groups |
||
372 | */ |
||
373 | public function setGroups($groups) |
||
377 | |||
378 | /** |
||
379 | * Get frequency. |
||
380 | * |
||
381 | * @return string |
||
382 | */ |
||
383 | public function getFrequency() |
||
387 | |||
388 | /** |
||
389 | * Set frequency. |
||
390 | * |
||
391 | * @param string $frequency |
||
392 | */ |
||
393 | public function setFrequency($frequency) |
||
397 | |||
398 | /** |
||
399 | * Get till date. |
||
400 | * |
||
401 | * @return \DateTime |
||
402 | */ |
||
403 | public function getTillDate() |
||
407 | |||
408 | /** |
||
409 | * Set till date. |
||
410 | * |
||
411 | * @param \DateTime $tillDate |
||
412 | */ |
||
413 | public function setTillDate($tillDate) |
||
417 | |||
418 | /** |
||
419 | * Get till days. |
||
420 | * |
||
421 | * @return int |
||
422 | */ |
||
423 | public function getTillDays() |
||
427 | |||
428 | /** |
||
429 | * Set till days. |
||
430 | * |
||
431 | * @param int $tillDays |
||
432 | */ |
||
433 | public function setTillDays(int $tillDays) |
||
437 | |||
438 | /** |
||
439 | * Is till days relative. |
||
440 | * |
||
441 | * @return bool |
||
442 | */ |
||
443 | public function isTillDaysRelative() |
||
447 | |||
448 | /** |
||
449 | * Set till days relative. |
||
450 | * |
||
451 | * @param bool $tillDaysRelative |
||
452 | */ |
||
453 | public function setTillDaysRelative(bool $tillDaysRelative) |
||
457 | |||
458 | /** |
||
459 | * Get till days past. |
||
460 | * |
||
461 | * @return int |
||
462 | */ |
||
463 | public function getTillDaysPast() |
||
467 | |||
468 | /** |
||
469 | * Set till days past. |
||
470 | * |
||
471 | * @param int $tillDaysPast |
||
472 | */ |
||
473 | public function setTillDaysPast(int $tillDaysPast) |
||
477 | |||
478 | /** |
||
479 | * Get counter amount. |
||
480 | * |
||
481 | * @return int |
||
482 | */ |
||
483 | public function getCounterAmount() |
||
487 | |||
488 | /** |
||
489 | * Set counter amount. |
||
490 | * |
||
491 | * @param int $counterAmount |
||
492 | */ |
||
493 | public function setCounterAmount($counterAmount) |
||
497 | |||
498 | /** |
||
499 | * Get counter interval. |
||
500 | * |
||
501 | * @return int |
||
502 | */ |
||
503 | public function getCounterInterval() |
||
507 | |||
508 | /** |
||
509 | * Set counter interval. |
||
510 | * |
||
511 | * @param int $counterInterval |
||
512 | */ |
||
513 | public function setCounterInterval($counterInterval) |
||
517 | |||
518 | /** |
||
519 | * Get external ICS URL. |
||
520 | * |
||
521 | * @return string |
||
522 | */ |
||
523 | public function getExternalIcsUrl() |
||
527 | |||
528 | /** |
||
529 | * Set external ICS URL. |
||
530 | * |
||
531 | * @param string $externalIcsUrl |
||
532 | */ |
||
533 | public function setExternalIcsUrl($externalIcsUrl) |
||
537 | |||
538 | /** |
||
539 | * Get day. |
||
540 | * |
||
541 | * @return string |
||
542 | */ |
||
543 | public function getDay() |
||
547 | |||
548 | /** |
||
549 | * Set day. |
||
550 | * |
||
551 | * @param string $day |
||
552 | */ |
||
553 | public function setDay($day) |
||
557 | |||
558 | /** |
||
559 | * Get recurrence. |
||
560 | * |
||
561 | * @return string |
||
562 | */ |
||
563 | public function getRecurrence() |
||
567 | |||
568 | /** |
||
569 | * Set recurrence. |
||
570 | * |
||
571 | * @param string $recurrence |
||
572 | */ |
||
573 | public function setRecurrence($recurrence) |
||
577 | |||
578 | /** |
||
579 | * Get handling. |
||
580 | * |
||
581 | * @return string |
||
582 | */ |
||
583 | public function getHandling() |
||
587 | |||
588 | /** |
||
589 | * Set handling. |
||
590 | * |
||
591 | * @param string $handling |
||
592 | */ |
||
593 | public function setHandling($handling) |
||
597 | |||
598 | /** |
||
599 | * Get state. |
||
600 | * |
||
601 | * @return string |
||
602 | */ |
||
603 | public function getState() |
||
607 | |||
608 | /** |
||
609 | * Set state. |
||
610 | * |
||
611 | * @param string $state |
||
612 | */ |
||
613 | public function setState($state) |
||
617 | |||
618 | /** |
||
619 | * @return bool |
||
620 | */ |
||
621 | public function isOpenEndTime() |
||
625 | |||
626 | /** |
||
627 | * @param bool $openEndTime |
||
628 | */ |
||
629 | public function setOpenEndTime(bool $openEndTime) |
||
633 | } |
||
634 |