Completed
Branch master (7ef222)
by Tom
01:41
created

NoaaAlert::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 45
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 22
dl 0
loc 45
ccs 23
cts 23
cp 1
crap 1
rs 9.568
c 0
b 0
f 0

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 NoaaCapAlerts\Model;
4
5
class NoaaAlert
6
{
7
    protected $idString;
8
    protected $idKey;
9
    protected $updatedTime;
10
    protected $publishedTime;
11
    protected $authorName;
12
    protected $title;
13
    protected $link;
14
    protected $summary;
15
    protected $capEvent;
16
    protected $capEffectiveTime;
17
    protected $capExpiresTime;
18
    protected $capStatus;
19
    protected $capMsgType;
20
    protected $capCategory;
21
    protected $capUrgencyExpected;
22
    protected $capSeverity;
23
    protected $capCertainty;
24
    protected $capAreaDesc;
25
    protected $capPolygon;
26
    protected $capGeo;
27
    protected $capGeoString;
28
    protected $vtec;
29
30 3
    public function __construct(string $idString,
31
                                string $idKey,
32
                                \DateTime $updatedTime,
33
                                \DateTime $publishedTime,
34
                                string $authorName,
35
                                string $title,
36
                                string $link,
37
                                string $summary,
38
                                string $capEvent,
39
                                ? \DateTime $capEffectiveTime,
40
                                ? \DateTime $capExpiresTime,
41
                                string $capStatus,
42
                                string $capMsgType,
43
                                string $capCategory,
44
                                string $capUrgencyExpected,
45
                                string $capSeverity,
46
                                string $capCertainty,
47
                                string $capAreaDesc,
48
                                array $capPolygon,
49
                                array $capGeo,
50
                                string $capGeoString,
51
                                string $vtec)
52
    {
53 3
        $this->idString = $idString;
54 3
        $this->idKey = $idKey;
55 3
        $this->updatedTime = $updatedTime;
56 3
        $this->publishedTime = $publishedTime;
57 3
        $this->authorName = $authorName;
58 3
        $this->title = $title;
59 3
        $this->link = $link;
60 3
        $this->summary = $summary;
61 3
        $this->capEvent = $capEvent;
62 3
        $this->capEffectiveTime = $capEffectiveTime;
63 3
        $this->capExpiresTime = $capExpiresTime;
64 3
        $this->capStatus = $capStatus;
65 3
        $this->capMsgType = $capMsgType;
66 3
        $this->capCategory = $capCategory;
67 3
        $this->capUrgencyExpected = $capUrgencyExpected;
68 3
        $this->capSeverity = $capSeverity;
69 3
        $this->capCertainty = $capCertainty;
70 3
        $this->capAreaDesc = $capAreaDesc;
71 3
        $this->capPolygon = $capPolygon;
72 3
        $this->capGeo = $capGeo;
73 3
        $this->capGeoString = $capGeoString;
74 3
        $this->vtec = $vtec;
75 3
    }
76
77 1
    public function toArray(): array
78
    {
79
        return array(
80 1
            'idString' => $this->idString,
81 1
            'idKey' => $this->idKey,
82 1
            'updatedTime' => $this->updatedTime,
83 1
            'publishedTime' => $this->publishedTime,
84 1
            'authorName' => $this->authorName,
85 1
            'title' => $this->title,
86 1
            'link' => $this->link,
87 1
            'summary' => $this->summary,
88 1
            'capEvent' => $this->capEvent,
89 1
            'capEffectiveTime' => $this->capEffectiveTime,
90 1
            'capExpiresTime' => $this->capExpiresTime,
91 1
            'capStatus' => $this->capStatus,
92 1
            'capMsgType' => $this->capMsgType,
93 1
            'capCategory' => $this->capCategory,
94 1
            'capUrgencyExpected' => $this->capUrgencyExpected,
95 1
            'capSeverity' => $this->capSeverity,
96 1
            'capCertainty' => $this->capCertainty,
97 1
            'capAreaDesc' => $this->capAreaDesc,
98 1
            'capPolygon' => $this->capPolygon,
99 1
            'capGeo' => $this->capGeo,
100 1
            'capGeoString' => $this->capGeoString,
101 1
            'vtec' => $this->vtec,
102
        );
103
    }
104
105 1
    public function getIdString(): string
106
    {
107 1
        return $this->idString;
108
    }
109
110 1
    public function getIdKey(): string
111
    {
112 1
        return $this->idKey;
113
    }
114
115 1
    public function getUpdatedTime(): \DateTime
116
    {
117 1
        return $this->updatedTime;
118
    }
119
120 1
    public function getPublishedTime(): \DateTime
121
    {
122 1
        return $this->publishedTime;
123
    }
124
125 1
    public function getAuthorName(): string
126
    {
127 1
        return $this->authorName;
128
    }
129
130 1
    public function getTitle(): string
131
    {
132 1
        return $this->title;
133
    }
134
135 1
    public function getLink(): string
136
    {
137 1
        return $this->link;
138
    }
139
140 1
    public function getSummary(): string
141
    {
142 1
        return $this->summary;
143
    }
144
145 1
    public function getCapEvent(): string
146
    {
147 1
        return $this->capEvent;
148
    }
149
150 1
    public function getCapEffectiveTime(): ?\DateTime
151
    {
152 1
        return $this->capEffectiveTime;
153
    }
154
155 1
    public function getCapExpiresTime(): ?\DateTime
156
    {
157 1
        return $this->capExpiresTime;
158
    }
159
160 1
    public function getCapStatus(): string
161
    {
162 1
        return $this->capStatus;
163
    }
164
165 1
    public function getCapMsgType(): string
166
    {
167 1
        return $this->capMsgType;
168
    }
169
170 1
    public function getCapCategory(): string
171
    {
172 1
        return $this->capCategory;
173
    }
174
175 1
    public function getCapUrgencyExpected(): string
176
    {
177 1
        return $this->capUrgencyExpected;
178
    }
179
180 1
    public function getCapSeverity(): string
181
    {
182 1
        return $this->capSeverity;
183
    }
184
185 1
    public function getCapCertainty(): string
186
    {
187 1
        return $this->capCertainty;
188
    }
189
190 1
    public function getCapAreaDesc(): string
191
    {
192 1
        return $this->capAreaDesc;
193
    }
194
195 1
    public function getCapPolygon(): array
196
    {
197 1
        return $this->capPolygon;
198
    }
199
200 1
    public function getCapGeo(): array
201
    {
202 1
        return $this->capGeo;
203
    }
204
205 1
    public function getCapGeoString(): string
206
    {
207 1
        return $this->capGeoString;
208
    }
209
210 1
    public function getVtec(): string
211
    {
212 1
        return $this->vtec;
213
    }
214
}