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 | 12 | /** |
|
124 | * Year |
||
125 | 12 | * |
|
126 | 12 | * @var int |
|
127 | */ |
||
128 | protected $year; |
||
129 | |||
130 | /** |
||
131 | * Month |
||
132 | * |
||
133 | 31 | * @var int |
|
134 | */ |
||
135 | 31 | protected $month; |
|
136 | |||
137 | /** |
||
138 | * Day |
||
139 | * |
||
140 | * @var int |
||
141 | */ |
||
142 | protected $day; |
||
143 | |||
144 | /** |
||
145 | 32 | * Search Demand |
|
146 | * |
||
147 | 32 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand |
|
148 | 32 | */ |
|
149 | protected $searchDemand = null; |
||
150 | |||
151 | /** |
||
152 | * Organisator |
||
153 | * |
||
154 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
155 | 32 | */ |
|
156 | protected $organisator = null; |
||
157 | 32 | ||
158 | /** |
||
159 | * Sets the displayMode |
||
160 | * |
||
161 | * @param string $displayMode Displaymode |
||
162 | * |
||
163 | * @return void |
||
164 | */ |
||
165 | public function setDisplayMode($displayMode) |
||
169 | 3 | ||
170 | 3 | /** |
|
171 | * Returns the displayMode |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getDisplayMode() |
||
179 | 4 | ||
180 | 3 | /** |
|
181 | * Sets the storage page |
||
182 | 1 | * |
|
183 | * @param string $storagePage Storagepage |
||
184 | * |
||
185 | * @return void |
||
186 | */ |
||
187 | public function setStoragePage($storagePage) |
||
191 | |||
192 | 8 | /** |
|
193 | * Returns the storage page |
||
194 | 8 | * |
|
195 | 8 | * @return string |
|
196 | */ |
||
197 | public function getStoragePage() |
||
201 | |||
202 | 32 | /** |
|
203 | * Sets the current DateTime |
||
204 | 32 | * |
|
205 | * @param \DateTime $currentDateTime CurrentDateTime |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | public function setCurrentDateTime(\DateTime $currentDateTime) |
||
213 | |||
214 | 6 | /** |
|
215 | * Returns the current datetime |
||
216 | * |
||
217 | * @return \DateTime |
||
218 | */ |
||
219 | public function getCurrentDateTime() |
||
227 | |||
228 | /** |
||
229 | * Sets the category (seperated by comma) |
||
230 | * |
||
231 | * @param string $category Category |
||
232 | * |
||
233 | 32 | * @return void |
|
234 | */ |
||
235 | 32 | public function setCategory($category) |
|
239 | |||
240 | /** |
||
241 | * Returns the category (seperated by comma) |
||
242 | * |
||
243 | * @return string |
||
244 | */ |
||
245 | 4 | public function getCategory() |
|
249 | |||
250 | /** |
||
251 | * Returns includeSubcategories |
||
252 | * |
||
253 | * @return bool |
||
254 | */ |
||
255 | 8 | public function getIncludeSubcategories() |
|
259 | |||
260 | /** |
||
261 | * Sets includeSubcategories |
||
262 | * |
||
263 | * @param bool $includeSubcategories |
||
264 | * @return void |
||
265 | */ |
||
266 | public function setIncludeSubcategories($includeSubcategories) |
||
270 | 8 | ||
271 | /** |
||
272 | * Returns topEventRestriction |
||
273 | * |
||
274 | * @return int |
||
275 | */ |
||
276 | public function getTopEventRestriction() |
||
280 | |||
281 | /** |
||
282 | * Sets topEventRestriction |
||
283 | * |
||
284 | * @param int $topEventRestriction TopEventRestriction |
||
285 | * |
||
286 | * @return void |
||
287 | */ |
||
288 | public function setTopEventRestriction($topEventRestriction) |
||
292 | 8 | ||
293 | /** |
||
294 | * Returns the order direction |
||
295 | * |
||
296 | * @return string |
||
297 | */ |
||
298 | public function getOrderDirection() |
||
302 | |||
303 | /** |
||
304 | * Sets the order direction |
||
305 | * |
||
306 | * @param string $orderDirection OrderDirection |
||
307 | * |
||
308 | * @return void |
||
309 | */ |
||
310 | public function setOrderDirection($orderDirection) |
||
314 | 2 | ||
315 | /** |
||
316 | * Returns the order field |
||
317 | * |
||
318 | * @return string |
||
319 | */ |
||
320 | public function getOrderField() |
||
324 | |||
325 | /** |
||
326 | * Sets the order field |
||
327 | * |
||
328 | * @param string $orderField OrderField |
||
329 | * |
||
330 | * @return void |
||
331 | */ |
||
332 | public function setOrderField($orderField) |
||
336 | 4 | ||
337 | /** |
||
338 | * Returns orderFieldAllowed |
||
339 | * |
||
340 | * @return string |
||
341 | */ |
||
342 | public function getOrderFieldAllowed() |
||
346 | |||
347 | /** |
||
348 | * Sets orderFieldAllowed |
||
349 | * |
||
350 | * @param string $orderFieldAllowed |
||
351 | * @return void |
||
352 | */ |
||
353 | public function setOrderFieldAllowed($orderFieldAllowed) |
||
357 | 3 | ||
358 | 3 | /** |
|
359 | * Returns the query limit |
||
360 | * |
||
361 | * @return int |
||
362 | */ |
||
363 | public function getQueryLimit() |
||
367 | 32 | ||
368 | /** |
||
369 | * Sets the query limit |
||
370 | * |
||
371 | * @param int $queryLimit QueryLimit |
||
372 | * |
||
373 | * @return void |
||
374 | */ |
||
375 | public function setQueryLimit($queryLimit) |
||
379 | 3 | ||
380 | 3 | /** |
|
381 | * Returns the location |
||
382 | * |
||
383 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
384 | */ |
||
385 | public function getLocation() |
||
389 | 30 | ||
390 | /** |
||
391 | * Sets the location |
||
392 | * |
||
393 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location |
||
394 | * |
||
395 | * @return void |
||
396 | */ |
||
397 | public function setLocation($location) |
||
401 | 4 | ||
402 | /** |
||
403 | * Returns locationCity |
||
404 | * |
||
405 | * @return string |
||
406 | */ |
||
407 | public function getLocationCity() |
||
411 | |||
412 | /** |
||
413 | * Sets locationCity |
||
414 | * |
||
415 | * @param string $locationCity LocationCity |
||
416 | * |
||
417 | * @return void |
||
418 | */ |
||
419 | public function setLocationCity($locationCity) |
||
423 | |||
424 | /** |
||
425 | * Returns locationCountry |
||
426 | * |
||
427 | * @return string |
||
428 | */ |
||
429 | public function getLocationCountry() |
||
433 | |||
434 | /** |
||
435 | * Sets locationCountry |
||
436 | * |
||
437 | * @param string $locationCountry LocationCountry |
||
438 | * |
||
439 | * @return void |
||
440 | */ |
||
441 | public function setLocationCountry($locationCountry) |
||
445 | |||
446 | /** |
||
447 | * Returns year |
||
448 | * |
||
449 | * @return int |
||
450 | */ |
||
451 | public function getYear() |
||
455 | |||
456 | /** |
||
457 | * Sets year |
||
458 | * |
||
459 | * @param int $year |
||
460 | * @return void |
||
461 | */ |
||
462 | public function setYear($year) |
||
466 | |||
467 | /** |
||
468 | * Returns month |
||
469 | * |
||
470 | * @return int |
||
471 | */ |
||
472 | public function getMonth() |
||
476 | |||
477 | /** |
||
478 | * Sets month |
||
479 | * |
||
480 | * @param int $month |
||
481 | * @return void |
||
482 | */ |
||
483 | public function setMonth($month) |
||
487 | |||
488 | /** |
||
489 | * Returns day |
||
490 | * |
||
491 | * @return int |
||
492 | */ |
||
493 | public function getDay() |
||
497 | |||
498 | /** |
||
499 | * @param int $day |
||
500 | * @return void |
||
501 | */ |
||
502 | public function setDay($day) |
||
506 | |||
507 | /** |
||
508 | * Returns the searchDemand |
||
509 | * |
||
510 | * @return SearchDemand |
||
511 | */ |
||
512 | public function getSearchDemand() |
||
516 | |||
517 | /** |
||
518 | * Sets the searchDemand |
||
519 | * |
||
520 | * @param SearchDemand $searchDemand |
||
521 | * @return void |
||
522 | */ |
||
523 | public function setSearchDemand($searchDemand) |
||
527 | |||
528 | /** |
||
529 | * Returns organisator |
||
530 | * |
||
531 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
532 | */ |
||
533 | public function getOrganisator() |
||
537 | |||
538 | /** |
||
539 | * Sets organisator |
||
540 | * |
||
541 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Organisator $organisator |
||
542 | * @return void |
||
543 | */ |
||
544 | public function setOrganisator($organisator) |
||
548 | |||
549 | /** |
||
550 | * Returns categoryConjuction |
||
551 | * |
||
552 | * @return string |
||
553 | */ |
||
554 | public function getCategoryConjunction() |
||
558 | |||
559 | /** |
||
560 | * Sets categoryConjuction |
||
561 | * |
||
562 | * @param string $categoryConjunction |
||
563 | * @return void |
||
564 | */ |
||
565 | public function setCategoryConjunction($categoryConjunction) |
||
569 | |||
570 | /** |
||
571 | * Returns speaker |
||
572 | * |
||
573 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Speaker |
||
574 | */ |
||
575 | public function getSpeaker() |
||
579 | |||
580 | /** |
||
581 | * Sets speaker |
||
582 | * |
||
583 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker |
||
584 | * @return void |
||
585 | */ |
||
586 | public function setSpeaker($speaker) |
||
590 | } |
||
591 |