Complex classes like EventDemand 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 EventDemand, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
16 | class EventDemand extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity |
||
17 | { |
||
18 | /** |
||
19 | * Display mode |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $displayMode = 'all'; |
||
24 | |||
25 | /** |
||
26 | * Storage page |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $storagePage = ''; |
||
31 | |||
32 | /** |
||
33 | * Current DateTime |
||
34 | * |
||
35 | * @var \DateTime |
||
36 | */ |
||
37 | protected $currentDateTime = null; |
||
38 | |||
39 | /** |
||
40 | * Category |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $category; |
||
45 | |||
46 | /** |
||
47 | * Include subcategories |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $includeSubcategories = false; |
||
52 | |||
53 | /** |
||
54 | * Category Conjunction |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $categoryConjunction = ''; |
||
59 | |||
60 | /** |
||
61 | * Top event |
||
62 | * |
||
63 | * @var int |
||
64 | */ |
||
65 | protected $topEventRestriction = 0; |
||
66 | |||
67 | /** |
||
68 | * Order field |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $orderField = ''; |
||
73 | |||
74 | /** |
||
75 | * Allowed order fields |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $orderFieldAllowed = ''; |
||
80 | |||
81 | /** |
||
82 | * Order direction |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $orderDirection = ''; |
||
87 | |||
88 | /** |
||
89 | * Query limit |
||
90 | * |
||
91 | * @var int |
||
92 | */ |
||
93 | protected $queryLimit = null; |
||
94 | |||
95 | /** |
||
96 | * Location |
||
97 | * |
||
98 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
99 | */ |
||
100 | protected $location = null; |
||
101 | |||
102 | /** |
||
103 | * Speaker |
||
104 | * |
||
105 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Speaker |
||
106 | */ |
||
107 | protected $speaker = null; |
||
108 | |||
109 | /** |
||
110 | * City for location |
||
111 | * |
||
112 | * @var string |
||
113 | */ |
||
114 | protected $locationCity = ''; |
||
115 | |||
116 | /** |
||
117 | * Country for location |
||
118 | * |
||
119 | * @var string |
||
120 | */ |
||
121 | protected $locationCountry = ''; |
||
122 | |||
123 | /** |
||
124 | * Year |
||
125 | * |
||
126 | * @var int |
||
127 | */ |
||
128 | protected $year; |
||
129 | |||
130 | /** |
||
131 | * Month |
||
132 | * |
||
133 | * @var int |
||
134 | */ |
||
135 | protected $month; |
||
136 | |||
137 | /** |
||
138 | * Day |
||
139 | * |
||
140 | * @var int |
||
141 | */ |
||
142 | protected $day; |
||
143 | |||
144 | /** |
||
145 | * Search Demand |
||
146 | * |
||
147 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand |
||
148 | */ |
||
149 | protected $searchDemand = null; |
||
150 | |||
151 | /** |
||
152 | * Organisator |
||
153 | * |
||
154 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
155 | */ |
||
156 | protected $organisator = null; |
||
157 | |||
158 | /** |
||
159 | * @var bool |
||
160 | */ |
||
161 | protected $ignoreEnableFields = false; |
||
162 | |||
163 | /** |
||
164 | * Sets the displayMode |
||
165 | * |
||
166 | * @param string $displayMode Displaymode |
||
167 | * |
||
168 | * @return void |
||
169 | */ |
||
170 | public function setDisplayMode($displayMode) |
||
174 | |||
175 | /** |
||
176 | * Returns the displayMode |
||
177 | * |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getDisplayMode() |
||
184 | |||
185 | /** |
||
186 | * Sets the storage page |
||
187 | * |
||
188 | * @param string $storagePage Storagepage |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | public function setStoragePage($storagePage) |
||
196 | |||
197 | /** |
||
198 | * Returns the storage page |
||
199 | * |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getStoragePage() |
||
206 | |||
207 | /** |
||
208 | * Sets the current DateTime |
||
209 | * |
||
210 | * @param \DateTime $currentDateTime CurrentDateTime |
||
211 | * |
||
212 | * @return void |
||
213 | */ |
||
214 | public function setCurrentDateTime(\DateTime $currentDateTime) |
||
218 | |||
219 | /** |
||
220 | * Returns the current datetime |
||
221 | * |
||
222 | * @return \DateTime |
||
223 | */ |
||
224 | public function getCurrentDateTime() |
||
232 | |||
233 | /** |
||
234 | * Sets the category (seperated by comma) |
||
235 | * |
||
236 | * @param string $category Category |
||
237 | * |
||
238 | * @return void |
||
239 | */ |
||
240 | public function setCategory($category) |
||
244 | |||
245 | /** |
||
246 | * Returns the category (seperated by comma) |
||
247 | * |
||
248 | * @return string |
||
249 | */ |
||
250 | public function getCategory() |
||
254 | |||
255 | /** |
||
256 | * Returns includeSubcategories |
||
257 | * |
||
258 | * @return bool |
||
259 | */ |
||
260 | public function getIncludeSubcategories() |
||
264 | |||
265 | /** |
||
266 | * Sets includeSubcategories |
||
267 | * |
||
268 | * @param bool $includeSubcategories |
||
269 | * @return void |
||
270 | */ |
||
271 | public function setIncludeSubcategories($includeSubcategories) |
||
275 | |||
276 | /** |
||
277 | * Returns topEventRestriction |
||
278 | * |
||
279 | * @return int |
||
280 | */ |
||
281 | public function getTopEventRestriction() |
||
285 | |||
286 | /** |
||
287 | * Sets topEventRestriction |
||
288 | * |
||
289 | * @param int $topEventRestriction TopEventRestriction |
||
290 | * |
||
291 | * @return void |
||
292 | */ |
||
293 | public function setTopEventRestriction($topEventRestriction) |
||
297 | |||
298 | /** |
||
299 | * Returns the order direction |
||
300 | * |
||
301 | * @return string |
||
302 | */ |
||
303 | public function getOrderDirection() |
||
307 | |||
308 | /** |
||
309 | * Sets the order direction |
||
310 | * |
||
311 | * @param string $orderDirection OrderDirection |
||
312 | * |
||
313 | * @return void |
||
314 | */ |
||
315 | public function setOrderDirection($orderDirection) |
||
319 | |||
320 | /** |
||
321 | * Returns the order field |
||
322 | * |
||
323 | * @return string |
||
324 | */ |
||
325 | public function getOrderField() |
||
329 | |||
330 | /** |
||
331 | * Sets the order field |
||
332 | * |
||
333 | * @param string $orderField OrderField |
||
334 | * |
||
335 | * @return void |
||
336 | */ |
||
337 | public function setOrderField($orderField) |
||
341 | |||
342 | /** |
||
343 | * Returns orderFieldAllowed |
||
344 | * |
||
345 | * @return string |
||
346 | */ |
||
347 | public function getOrderFieldAllowed() |
||
351 | |||
352 | /** |
||
353 | * Sets orderFieldAllowed |
||
354 | * |
||
355 | * @param string $orderFieldAllowed |
||
356 | * @return void |
||
357 | */ |
||
358 | public function setOrderFieldAllowed($orderFieldAllowed) |
||
362 | |||
363 | /** |
||
364 | * Returns the query limit |
||
365 | * |
||
366 | * @return int |
||
367 | */ |
||
368 | public function getQueryLimit() |
||
372 | |||
373 | /** |
||
374 | * Sets the query limit |
||
375 | * |
||
376 | * @param int $queryLimit QueryLimit |
||
377 | * |
||
378 | * @return void |
||
379 | */ |
||
380 | public function setQueryLimit($queryLimit) |
||
384 | |||
385 | /** |
||
386 | * Returns the location |
||
387 | * |
||
388 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
389 | */ |
||
390 | public function getLocation() |
||
394 | |||
395 | /** |
||
396 | * Sets the location |
||
397 | * |
||
398 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location |
||
399 | * |
||
400 | * @return void |
||
401 | */ |
||
402 | public function setLocation($location) |
||
406 | |||
407 | /** |
||
408 | * Returns locationCity |
||
409 | * |
||
410 | * @return string |
||
411 | */ |
||
412 | public function getLocationCity() |
||
416 | |||
417 | /** |
||
418 | * Sets locationCity |
||
419 | * |
||
420 | * @param string $locationCity LocationCity |
||
421 | * |
||
422 | * @return void |
||
423 | */ |
||
424 | public function setLocationCity($locationCity) |
||
428 | |||
429 | /** |
||
430 | * Returns locationCountry |
||
431 | * |
||
432 | * @return string |
||
433 | */ |
||
434 | public function getLocationCountry() |
||
438 | |||
439 | /** |
||
440 | * Sets locationCountry |
||
441 | * |
||
442 | * @param string $locationCountry LocationCountry |
||
443 | * |
||
444 | * @return void |
||
445 | */ |
||
446 | public function setLocationCountry($locationCountry) |
||
450 | |||
451 | /** |
||
452 | * Returns year |
||
453 | * |
||
454 | * @return int |
||
455 | */ |
||
456 | public function getYear() |
||
460 | |||
461 | /** |
||
462 | * Sets year |
||
463 | * |
||
464 | * @param int $year |
||
465 | * @return void |
||
466 | */ |
||
467 | public function setYear($year) |
||
471 | |||
472 | /** |
||
473 | * Returns month |
||
474 | * |
||
475 | * @return int |
||
476 | */ |
||
477 | public function getMonth() |
||
481 | |||
482 | /** |
||
483 | * Sets month |
||
484 | * |
||
485 | * @param int $month |
||
486 | * @return void |
||
487 | */ |
||
488 | public function setMonth($month) |
||
492 | |||
493 | /** |
||
494 | * Returns day |
||
495 | * |
||
496 | * @return int |
||
497 | */ |
||
498 | public function getDay() |
||
502 | |||
503 | /** |
||
504 | * @param int $day |
||
505 | * @return void |
||
506 | */ |
||
507 | public function setDay($day) |
||
511 | |||
512 | /** |
||
513 | * Returns the searchDemand |
||
514 | * |
||
515 | * @return SearchDemand |
||
516 | */ |
||
517 | public function getSearchDemand() |
||
521 | |||
522 | /** |
||
523 | * Sets the searchDemand |
||
524 | * |
||
525 | * @param SearchDemand $searchDemand |
||
526 | * @return void |
||
527 | */ |
||
528 | public function setSearchDemand($searchDemand) |
||
532 | |||
533 | /** |
||
534 | * Returns organisator |
||
535 | * |
||
536 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
537 | */ |
||
538 | public function getOrganisator() |
||
542 | |||
543 | /** |
||
544 | * Sets organisator |
||
545 | * |
||
546 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Organisator $organisator |
||
547 | * @return void |
||
548 | */ |
||
549 | public function setOrganisator($organisator) |
||
553 | |||
554 | /** |
||
555 | * Returns categoryConjuction |
||
556 | * |
||
557 | * @return string |
||
558 | */ |
||
559 | public function getCategoryConjunction() |
||
563 | |||
564 | /** |
||
565 | * Sets categoryConjuction |
||
566 | * |
||
567 | * @param string $categoryConjunction |
||
568 | * @return void |
||
569 | */ |
||
570 | public function setCategoryConjunction($categoryConjunction) |
||
574 | |||
575 | /** |
||
576 | * Returns speaker |
||
577 | * |
||
578 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Speaker |
||
579 | */ |
||
580 | public function getSpeaker() |
||
584 | |||
585 | /** |
||
586 | * Sets speaker |
||
587 | * |
||
588 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker |
||
589 | * @return void |
||
590 | */ |
||
591 | public function setSpeaker($speaker) |
||
595 | |||
596 | /** |
||
597 | * @return bool |
||
598 | */ |
||
599 | public function getIgnoreEnableFields(): bool |
||
603 | |||
604 | /** |
||
605 | * @param bool $ignoreEnableFields |
||
606 | */ |
||
607 | public function setIgnoreEnableFields(bool $ignoreEnableFields): void |
||
611 | } |
||
612 |