Completed
Push — development ( 3f7d20...b27959 )
by Torben
02:46
created

EventDemand   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 575
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 41
lcom 1
cbo 1
dl 0
loc 575
ccs 67
cts 67
cp 1
rs 9.1199
c 0
b 0
f 0

40 Methods

Rating   Name   Duplication   Size   Complexity  
A setDisplayMode() 0 4 1
A getDisplayMode() 0 4 1
A setStoragePage() 0 4 1
A getStoragePage() 0 4 1
A setCurrentDateTime() 0 4 1
A getCurrentDateTime() 0 8 2
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

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
namespace DERHANSEN\SfEventMgt\Domain\Model\Dto;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
/**
12
 * Event demand
13
 *
14
 * @author Torben Hansen <[email protected]>
15
 */
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)
166
    {
167 3
        $this->displayMode = $displayMode;
168
    }
169 3
170 3
    /**
171
     * Returns the displayMode
172
     *
173
     * @return string
174
     */
175
    public function getDisplayMode()
176
    {
177 4
        return $this->displayMode;
178
    }
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)
188
    {
189
        $this->storagePage = $storagePage;
190
    }
191
192 8
    /**
193
     * Returns the storage page
194 8
     *
195 8
     * @return string
196
     */
197
    public function getStoragePage()
198
    {
199
        return $this->storagePage;
200
    }
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)
210
    {
211
        $this->currentDateTime = $currentDateTime;
212 6
    }
213
214 6
    /**
215
     * Returns the current datetime
216
     *
217
     * @return \DateTime
218
     */
219
    public function getCurrentDateTime()
220
    {
221
        if ($this->currentDateTime != null) {
222
            return $this->currentDateTime;
223 5
        }
224
225 5
        return new \DateTime();
226 5
    }
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)
236
    {
237
        $this->category = $category;
238
    }
239
240
    /**
241
     * Returns the category (seperated by comma)
242
     *
243
     * @return string
244
     */
245 4
    public function getCategory()
246
    {
247 4
        return $this->category;
248 4
    }
249
250
    /**
251
     * Returns includeSubcategories
252
     *
253
     * @return bool
254
     */
255 8
    public function getIncludeSubcategories()
256
    {
257 8
        return $this->includeSubcategories;
258
    }
259
260
    /**
261
     * Sets includeSubcategories
262
     *
263
     * @param bool $includeSubcategories
264
     * @return void
265
     */
266
    public function setIncludeSubcategories($includeSubcategories)
267 8
    {
268
        $this->includeSubcategories = $includeSubcategories;
269 8
    }
270 8
271
    /**
272
     * Returns topEventRestriction
273
     *
274
     * @return int
275
     */
276
    public function getTopEventRestriction()
277 32
    {
278
        return $this->topEventRestriction;
279 32
    }
280
281
    /**
282
     * Sets topEventRestriction
283
     *
284
     * @param int $topEventRestriction TopEventRestriction
285
     *
286
     * @return void
287
     */
288
    public function setTopEventRestriction($topEventRestriction)
289 8
    {
290
        $this->topEventRestriction = $topEventRestriction;
291 8
    }
292 8
293
    /**
294
     * Returns the order direction
295
     *
296
     * @return string
297
     */
298
    public function getOrderDirection()
299 32
    {
300
        return $this->orderDirection;
301 32
    }
302
303
    /**
304
     * Sets the order direction
305
     *
306
     * @param string $orderDirection OrderDirection
307
     *
308
     * @return void
309
     */
310
    public function setOrderDirection($orderDirection)
311 2
    {
312
        $this->orderDirection = $orderDirection;
313 2
    }
314 2
315
    /**
316
     * Returns the order field
317
     *
318
     * @return string
319
     */
320
    public function getOrderField()
321 32
    {
322
        return $this->orderField;
323 32
    }
324
325
    /**
326
     * Sets the order field
327
     *
328
     * @param string $orderField OrderField
329
     *
330
     * @return void
331
     */
332
    public function setOrderField($orderField)
333 4
    {
334
        $this->orderField = $orderField;
335 4
    }
336 4
337
    /**
338
     * Returns orderFieldAllowed
339
     *
340
     * @return string
341
     */
342
    public function getOrderFieldAllowed()
343 32
    {
344
        return $this->orderFieldAllowed;
345 32
    }
346
347
    /**
348
     * Sets orderFieldAllowed
349
     *
350
     * @param string $orderFieldAllowed
351
     * @return void
352
     */
353
    public function setOrderFieldAllowed($orderFieldAllowed)
354
    {
355 3
        $this->orderFieldAllowed = $orderFieldAllowed;
356
    }
357 3
358 3
    /**
359
     * Returns the query limit
360
     *
361
     * @return int
362
     */
363
    public function getQueryLimit()
364
    {
365 32
        return $this->queryLimit;
366
    }
367 32
368
    /**
369
     * Sets the query limit
370
     *
371
     * @param int $queryLimit QueryLimit
372
     *
373
     * @return void
374
     */
375
    public function setQueryLimit($queryLimit)
376
    {
377 3
        $this->queryLimit = $queryLimit;
378
    }
379 3
380 3
    /**
381
     * Returns the location
382
     *
383
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
384
     */
385
    public function getLocation()
386
    {
387 30
        return $this->location;
388
    }
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)
398 4
    {
399
        $this->location = $location;
400 4
    }
401 4
402
    /**
403
     * Returns locationCity
404
     *
405
     * @return string
406
     */
407
    public function getLocationCity()
408
    {
409
        return $this->locationCity;
410
    }
411
412
    /**
413
     * Sets locationCity
414
     *
415
     * @param string $locationCity LocationCity
416
     *
417
     * @return void
418
     */
419
    public function setLocationCity($locationCity)
420
    {
421
        $this->locationCity = $locationCity;
422
    }
423
424
    /**
425
     * Returns locationCountry
426
     *
427
     * @return string
428
     */
429
    public function getLocationCountry()
430
    {
431
        return $this->locationCountry;
432
    }
433
434
    /**
435
     * Sets locationCountry
436
     *
437
     * @param string $locationCountry LocationCountry
438
     *
439
     * @return void
440
     */
441
    public function setLocationCountry($locationCountry)
442
    {
443
        $this->locationCountry = $locationCountry;
444
    }
445
446
    /**
447
     * Returns year
448
     *
449
     * @return int
450
     */
451
    public function getYear()
452
    {
453
        return $this->year;
454
    }
455
456
    /**
457
     * Sets year
458
     *
459
     * @param int $year
460
     * @return void
461
     */
462
    public function setYear($year)
463
    {
464
        $this->year = $year;
465
    }
466
467
    /**
468
     * Returns month
469
     *
470
     * @return int
471
     */
472
    public function getMonth()
473
    {
474
        return $this->month;
475
    }
476
477
    /**
478
     * Sets month
479
     *
480
     * @param int $month
481
     * @return void
482
     */
483
    public function setMonth($month)
484
    {
485
        $this->month = $month;
486
    }
487
488
    /**
489
     * Returns day
490
     *
491
     * @return int
492
     */
493
    public function getDay()
494
    {
495
        return $this->day;
496
    }
497
498
    /**
499
     * @param int $day
500
     * @return void
501
     */
502
    public function setDay($day)
503
    {
504
        $this->day = $day;
505
    }
506
507
    /**
508
     * Returns the searchDemand
509
     *
510
     * @return SearchDemand
511
     */
512
    public function getSearchDemand()
513
    {
514
        return $this->searchDemand;
515
    }
516
517
    /**
518
     * Sets the searchDemand
519
     *
520
     * @param SearchDemand $searchDemand
521
     * @return void
522
     */
523
    public function setSearchDemand($searchDemand)
524
    {
525
        $this->searchDemand = $searchDemand;
526
    }
527
528
    /**
529
     * Returns organisator
530
     *
531
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Organisator
532
     */
533
    public function getOrganisator()
534
    {
535
        return $this->organisator;
536
    }
537
538
    /**
539
     * Sets organisator
540
     *
541
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Organisator $organisator
542
     * @return void
543
     */
544
    public function setOrganisator($organisator)
545
    {
546
        $this->organisator = $organisator;
547
    }
548
549
    /**
550
     * Returns categoryConjuction
551
     *
552
     * @return string
553
     */
554
    public function getCategoryConjunction()
555
    {
556
        return $this->categoryConjunction;
557
    }
558
559
    /**
560
     * Sets categoryConjuction
561
     *
562
     * @param string $categoryConjunction
563
     * @return void
564
     */
565
    public function setCategoryConjunction($categoryConjunction)
566
    {
567
        $this->categoryConjunction = $categoryConjunction;
568
    }
569
570
    /**
571
     * Returns speaker
572
     *
573
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Speaker
574
     */
575
    public function getSpeaker()
576
    {
577
        return $this->speaker;
578
    }
579
580
    /**
581
     * Sets speaker
582
     *
583
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
584
     * @return void
585
     */
586
    public function setSpeaker($speaker)
587
    {
588
        $this->speaker = $speaker;
589
    }
590
}
591