Completed
Pull Request — master (#345)
by
unknown
25:32 queued 12:36
created

CreateEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 17

Duplication

Lines 20
Ratio 100 %

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace CultuurNet\UDB3\Event\Commands;
4
5
use CultuurNet\UDB3\Calendar;
6
use CultuurNet\UDB3\Event\EventType;
7
use CultuurNet\UDB3\Language;
8
use CultuurNet\UDB3\Location\Location;
9
use CultuurNet\UDB3\Offer\Commands\AbstractCreateCommand;
10
use CultuurNet\UDB3\Theme;
11
use CultuurNet\UDB3\Title;
12
use DateTimeImmutable;
13
14 View Code Duplication
class CreateEvent extends AbstractCreateCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
15
{
16
    /**
17
     * @var Language
18
     */
19
    private $mainLanguage;
20
21
    /**
22
     * @var Title
23
     */
24
    private $title;
25
26
    /**
27
     * @var EventType
28
     */
29
    private $eventType;
30
31
    /**
32
     * @var Theme
33
     */
34
    private $theme;
35
36
    /**
37
     * @var Location
38
     */
39
    private $location;
40
41
    /**
42
     * @var Calendar
43
     */
44
    private $calendar;
45
46
    /**
47
     * @var DateTimeImmutable|null
48
     */
49
    private $publicationDate;
50
51
    /**
52
     * @param string $eventId
53
     * @param Language $mainLanguage
54
     * @param Title $title
55
     * @param EventType $eventType
56
     * @param Location $location
57
     * @param Calendar $calendar
58
     * @param Theme|null $theme
59
     * @param DateTimeImmutable|null $publicationDate
60
     */
61
    public function __construct(
62
        $eventId,
63
        Language $mainLanguage,
64
        Title $title,
65
        EventType $eventType,
66
        Location $location,
67
        Calendar $calendar,
68
        Theme $theme = null,
69
        DateTimeImmutable $publicationDate = null
70
    ) {
71
        parent::__construct($eventId);
72
73
        $this->mainLanguage = $mainLanguage;
74
        $this->title = $title;
75
        $this->eventType = $eventType;
76
        $this->location = $location;
77
        $this->calendar = $calendar;
78
        $this->theme = $theme;
79
        $this->publicationDate = $publicationDate;
80
    }
81
82
    /**
83
     * @return Language
84
     */
85
    public function getMainLanguage()
86
    {
87
        return $this->mainLanguage;
88
    }
89
90
    /**
91
     * @return Title
92
     */
93
    public function getTitle()
94
    {
95
        return $this->title;
96
    }
97
98
    /**
99
     * @return EventType
100
     */
101
    public function getEventType()
102
    {
103
        return $this->eventType;
104
    }
105
106
    /**
107
     * @return Theme
108
     */
109
    public function getTheme()
110
    {
111
        return $this->theme;
112
    }
113
114
    /**
115
     * @return Calendar
116
     */
117
    public function getCalendar()
118
    {
119
        return $this->calendar;
120
    }
121
122
    /**
123
     * @return Location
124
     */
125
    public function getLocation()
126
    {
127
        return $this->location;
128
    }
129
130
    /**
131
     * @return DateTimeImmutable|null
132
     */
133
    public function getPublicationDate()
134
    {
135
        return $this->publicationDate;
136
    }
137
}
138