Completed
Push — master ( 17edcb...7372de )
by Torben
06:23
created

EventDemand   B

Complexity

Total Complexity 43

Size/Duplication

Total Lines 565
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 95.83%

Importance

Changes 0
Metric Value
wmc 43
lcom 1
cbo 1
dl 0
loc 565
ccs 69
cts 72
cp 0.9583
rs 8.96
c 0
b 0
f 0

42 Methods

Rating   Name   Duplication   Size   Complexity  
A setCurrentDateTime() 0 4 1
A getCurrentDateTime() 0 8 2
A setDisplayMode() 0 4 1
A getDisplayMode() 0 4 1
A setStoragePage() 0 4 1
A getStoragePage() 0 4 1
A setCategory() 0 4 1
A getCategory() 0 4 1
A getIncludeSubcategories() 0 4 1
A setIncludeSubcategories() 0 4 1
A getTopEventRestriction() 0 4 1
A setTopEventRestriction() 0 4 1
A getOrderDirection() 0 4 1
A setOrderDirection() 0 4 1
A getOrderField() 0 4 1
A setOrderField() 0 4 1
A getOrderFieldAllowed() 0 4 1
A setOrderFieldAllowed() 0 4 1
A getQueryLimit() 0 4 1
A setQueryLimit() 0 4 1
A getLocation() 0 4 1
A setLocation() 0 4 1
A getLocationCity() 0 4 1
A setLocationCity() 0 4 1
A getLocationCountry() 0 4 1
A setLocationCountry() 0 4 1
A getYear() 0 4 1
A setYear() 0 4 1
A getMonth() 0 4 1
A setMonth() 0 4 1
A getDay() 0 4 1
A setDay() 0 4 1
A getSearchDemand() 0 4 1
A setSearchDemand() 0 4 1
A getOrganisator() 0 4 1
A setOrganisator() 0 4 1
A getCategoryConjunction() 0 4 1
A setCategoryConjunction() 0 4 1
A getSpeaker() 0 4 1
A setSpeaker() 0 4 1
A getIgnoreEnableFields() 0 4 1
A setIgnoreEnableFields() 0 4 1

How to fix   Complexity   

Complex Class

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
2
3
/*
4
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.txt file that was distributed with this source code.
8
 */
9
10
namespace DERHANSEN\SfEventMgt\Domain\Model\Dto;
11
12
/**
13
 * Event demand
14
 *
15
 * @author Torben Hansen <[email protected]>
16
 */
17
class EventDemand extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
18
{
19
    /**
20
     * Display mode
21
     *
22
     * @var string
23
     */
24
    protected $displayMode = 'all';
25
26
    /**
27
     * Storage page
28
     *
29
     * @var string
30
     */
31
    protected $storagePage = '';
32
33
    /**
34
     * Current DateTime
35
     *
36
     * @var \DateTime
37
     */
38
    protected $currentDateTime;
39
40
    /**
41
     * Category
42
     *
43
     * @var string
44
     */
45
    protected $category;
46
47
    /**
48
     * Include subcategories
49
     *
50
     * @var bool
51
     */
52
    protected $includeSubcategories = false;
53
54
    /**
55
     * Category Conjunction
56
     *
57
     * @var string
58
     */
59
    protected $categoryConjunction = '';
60
61
    /**
62
     * Top event
63
     *
64
     * @var int
65
     */
66
    protected $topEventRestriction = 0;
67
68
    /**
69
     * Order field
70
     *
71
     * @var string
72
     */
73
    protected $orderField = '';
74
75
    /**
76
     * Allowed order fields
77
     *
78
     * @var string
79
     */
80
    protected $orderFieldAllowed = '';
81
82
    /**
83
     * Order direction
84
     *
85
     * @var string
86
     */
87
    protected $orderDirection = '';
88
89
    /**
90
     * Query limit
91
     *
92
     * @var int
93
     */
94
    protected $queryLimit;
95
96
    /**
97
     * Location
98
     *
99
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Location
100
     */
101
    protected $location;
102
103
    /**
104
     * Speaker
105
     *
106
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Speaker
107
     */
108
    protected $speaker;
109
110
    /**
111
     * City for location
112
     *
113
     * @var string
114
     */
115
    protected $locationCity = '';
116
117
    /**
118
     * Country for location
119
     *
120
     * @var string
121
     */
122
    protected $locationCountry = '';
123
124
    /**
125
     * Year
126
     *
127
     * @var int
128
     */
129
    protected $year;
130 13
131
    /**
132 13
     * Month
133 13
     *
134
     * @var int
135
     */
136
    protected $month;
137
138
    /**
139
     * Day
140 32
     *
141
     * @var int
142 32
     */
143
    protected $day;
144
145
    /**
146
     * Search Demand
147
     *
148
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Dto\SearchDemand
149
     */
150
    protected $searchDemand;
151
152 34
    /**
153
     * Organisator
154 34
     *
155 34
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator
156
     */
157
    protected $organisator;
158
159
    /**
160
     * @var bool
161
     */
162 34
    protected $ignoreEnableFields = false;
163
164 34
    /**
165
     * Sets the displayMode
166
     *
167
     * @param string $displayMode Displaymode
168
     */
169
    public function setDisplayMode($displayMode)
170
    {
171
        $this->displayMode = $displayMode;
172
    }
173
174 4
    /**
175
     * Returns the displayMode
176 4
     *
177 4
     * @return string
178
     */
179
    public function getDisplayMode()
180
    {
181
        return $this->displayMode;
182
    }
183
184 6
    /**
185
     * Sets the storage page
186 6
     *
187 4
     * @param string $storagePage Storagepage
188
     */
189 2
    public function setStoragePage($storagePage)
190
    {
191
        $this->storagePage = $storagePage;
192
    }
193
194
    /**
195
     * Returns the storage page
196
     *
197
     * @return string
198
     */
199 11
    public function getStoragePage()
200
    {
201 11
        return $this->storagePage;
202 11
    }
203
204
    /**
205
     * Sets the current DateTime
206
     *
207
     * @param \DateTime $currentDateTime CurrentDateTime
208
     */
209 34
    public function setCurrentDateTime(\DateTime $currentDateTime)
210
    {
211 34
        $this->currentDateTime = $currentDateTime;
212
    }
213
214
    /**
215
     * Returns the current datetime
216
     *
217
     * @return \DateTime
218
     */
219 7
    public function getCurrentDateTime()
220
    {
221 7
        if ($this->currentDateTime != null) {
222
            return $this->currentDateTime;
223
        }
224
225
        return new \DateTime();
226
    }
227
228
    /**
229
     * Sets the category (seperated by comma)
230 5
     *
231
     * @param string $category Category
232 5
     */
233 5
    public function setCategory($category)
234
    {
235
        $this->category = $category;
236
    }
237
238
    /**
239
     * Returns the category (seperated by comma)
240 34
     *
241
     * @return string
242 34
     */
243
    public function getCategory()
244
    {
245
        return $this->category;
246
    }
247
248
    /**
249
     * Returns includeSubcategories
250
     *
251
     * @return bool
252 5
     */
253
    public function getIncludeSubcategories()
254 5
    {
255 5
        return $this->includeSubcategories;
256
    }
257
258
    /**
259
     * Sets includeSubcategories
260
     *
261
     * @param bool $includeSubcategories
262 10
     */
263
    public function setIncludeSubcategories($includeSubcategories)
264 10
    {
265
        $this->includeSubcategories = $includeSubcategories;
266
    }
267
268
    /**
269
     * Returns topEventRestriction
270
     *
271
     * @return int
272
     */
273
    public function getTopEventRestriction()
274 9
    {
275
        return $this->topEventRestriction;
276 9
    }
277 9
278
    /**
279
     * Sets topEventRestriction
280
     *
281
     * @param int $topEventRestriction TopEventRestriction
282
     */
283
    public function setTopEventRestriction($topEventRestriction)
284 34
    {
285
        $this->topEventRestriction = $topEventRestriction;
286 34
    }
287
288
    /**
289
     * Returns the order direction
290
     *
291
     * @return string
292
     */
293
    public function getOrderDirection()
294
    {
295
        return $this->orderDirection;
296 9
    }
297
298 9
    /**
299 9
     * Sets the order direction
300
     *
301
     * @param string $orderDirection OrderDirection
302
     */
303
    public function setOrderDirection($orderDirection)
304
    {
305
        $this->orderDirection = $orderDirection;
306 30
    }
307
308 30
    /**
309
     * Returns the order field
310
     *
311
     * @return string
312
     */
313
    public function getOrderField()
314
    {
315
        return $this->orderField;
316
    }
317
318
    /**
319
     * Sets the order field
320
     *
321
     * @param string $orderField OrderField
322
     */
323
    public function setOrderField($orderField)
324
    {
325
        $this->orderField = $orderField;
326
    }
327 34
328
    /**
329 34
     * Returns orderFieldAllowed
330
     *
331
     * @return string
332
     */
333
    public function getOrderFieldAllowed()
334
    {
335
        return $this->orderFieldAllowed;
336
    }
337
338
    /**
339 3
     * Sets orderFieldAllowed
340
     *
341 3
     * @param string $orderFieldAllowed
342 3
     */
343
    public function setOrderFieldAllowed($orderFieldAllowed)
344
    {
345
        $this->orderFieldAllowed = $orderFieldAllowed;
346
    }
347
348
    /**
349 34
     * Returns the query limit
350
     *
351 34
     * @return int
352
     */
353
    public function getQueryLimit()
354
    {
355
        return $this->queryLimit;
356
    }
357
358
    /**
359
     * Sets the query limit
360
     *
361 5
     * @param int $queryLimit QueryLimit
362
     */
363 5
    public function setQueryLimit($queryLimit)
364 5
    {
365
        $this->queryLimit = $queryLimit;
366
    }
367
368
    /**
369
     * Returns the location
370
     *
371 34
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
372
     */
373 34
    public function getLocation()
374
    {
375
        return $this->location;
376
    }
377
378
    /**
379
     * Sets the location
380
     *
381
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
382
     */
383 4
    public function setLocation($location)
384
    {
385 4
        $this->location = $location;
386 4
    }
387
388
    /**
389
     * Returns locationCity
390
     *
391
     * @return string
392
     */
393 34
    public function getLocationCity()
394
    {
395 34
        return $this->locationCity;
396
    }
397
398
    /**
399
     * Sets locationCity
400
     *
401
     * @param string $locationCity LocationCity
402
     */
403
    public function setLocationCity($locationCity)
404
    {
405 4
        $this->locationCity = $locationCity;
406
    }
407 4
408 4
    /**
409
     * Returns locationCountry
410
     *
411
     * @return string
412
     */
413
    public function getLocationCountry()
414
    {
415 30
        return $this->locationCountry;
416
    }
417 30
418
    /**
419
     * Sets locationCountry
420
     *
421
     * @param string $locationCountry LocationCountry
422
     */
423
    public function setLocationCountry($locationCountry)
424
    {
425
        $this->locationCountry = $locationCountry;
426 5
    }
427
428 5
    /**
429 5
     * Returns year
430
     *
431
     * @return int
432
     */
433
    public function getYear()
434
    {
435
        return $this->year;
436
    }
437
438
    /**
439
     * Sets year
440
     *
441
     * @param int $year
442
     */
443
    public function setYear($year)
444
    {
445
        $this->year = $year;
446
    }
447
448
    /**
449
     * Returns month
450
     *
451
     * @return int
452
     */
453
    public function getMonth()
454
    {
455
        return $this->month;
456
    }
457
458
    /**
459
     * Sets month
460
     *
461
     * @param int $month
462
     */
463
    public function setMonth($month)
464
    {
465
        $this->month = $month;
466
    }
467
468
    /**
469
     * Returns day
470
     *
471
     * @return int
472
     */
473
    public function getDay()
474
    {
475
        return $this->day;
476
    }
477
478
    /**
479
     * @param int $day
480
     */
481
    public function setDay($day)
482
    {
483
        $this->day = $day;
484
    }
485
486
    /**
487
     * Returns the searchDemand
488
     *
489
     * @return SearchDemand
490
     */
491
    public function getSearchDemand()
492
    {
493
        return $this->searchDemand;
494
    }
495
496
    /**
497
     * Sets the searchDemand
498
     *
499
     * @param SearchDemand $searchDemand
500
     */
501
    public function setSearchDemand($searchDemand)
502
    {
503
        $this->searchDemand = $searchDemand;
504
    }
505
506
    /**
507
     * Returns organisator
508
     *
509
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Organisator
510
     */
511
    public function getOrganisator()
512
    {
513
        return $this->organisator;
514
    }
515
516
    /**
517
     * Sets organisator
518
     *
519
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Organisator $organisator
520
     */
521
    public function setOrganisator($organisator)
522
    {
523
        $this->organisator = $organisator;
524
    }
525
526
    /**
527
     * Returns categoryConjuction
528
     *
529
     * @return string
530
     */
531
    public function getCategoryConjunction()
532
    {
533
        return $this->categoryConjunction;
534
    }
535
536
    /**
537
     * Sets categoryConjuction
538
     *
539
     * @param string $categoryConjunction
540
     */
541
    public function setCategoryConjunction($categoryConjunction)
542
    {
543
        $this->categoryConjunction = $categoryConjunction;
544
    }
545
546
    /**
547
     * Returns speaker
548
     *
549
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Speaker
550
     */
551
    public function getSpeaker()
552
    {
553
        return $this->speaker;
554
    }
555
556
    /**
557
     * Sets speaker
558
     *
559
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
560
     */
561
    public function setSpeaker($speaker)
562
    {
563
        $this->speaker = $speaker;
564
    }
565
566
    /**
567
     * @return bool
568
     */
569
    public function getIgnoreEnableFields(): bool
570
    {
571
        return $this->ignoreEnableFields;
572
    }
573
574
    /**
575
     * @param bool $ignoreEnableFields
576
     */
577
    public function setIgnoreEnableFields(bool $ignoreEnableFields): void
578
    {
579
        $this->ignoreEnableFields = $ignoreEnableFields;
580
    }
581
}
582