Completed
Push — master ( bdd854...9b3a32 )
by Mark
01:44
created

List_::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 1
eloc 25
nc 1
nop 12

1 Method

Rating   Name   Duplication   Size   Complexity  
A List_::updateFromResponse() 0 15 1

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 Mrkj\Laposta\Models;
4
5
class List_
6
{
7
    private $accountId;
8
    private $listId;
9
    private $created;
10
    private $modified;
11
    private $state;
12
    private $name;
13
    private $remarks;
14
    private $subscribeNotificationEmail;
15
    private $unsubsribeNotificationEmail;
16
    private $numberOfActiveMembers;
17
    private $numberOfUnsubscribedMembers;
18
    private $numberOfCleanedMembers;
19
20
    public static function createFromResponse($response)
21
    {
22
        $self = new self;
23
24
        $self->updateFromResponse($response);
25
26
        return $self;
27
    }
28
29
    public function updateFromResponse($response)
30
    {
31
        $this->setAccountId($response['account_id']);
32
        $this->setListId($response['list_id']);
33
        $this->setCreated($response['created']);
34
        $this->setModified($response['modified']);
35
        $this->setState($response['state']);
36
        $this->setName($response['name']);
37
        $this->setRemarks($response['remarks']);
38
        $this->setSubscribeNotificationEmail($response['subscribe_notification_email']);
39
        $this->setUnsubsribeNotificationEmail($response['unsubscribe_notification_email']);
40
        $this->setNumberOfActiveMembers($response['members']['active']);
41
        $this->setNumberOfUnsubscribedMembers($response['members']['unsubscribed']);
42
        $this->setNumberOfCleanedMembers($response['members']['cleaned']);
43
    }
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getAccountId()
49
    {
50
        return $this->accountId;
51
    }
52
53
    /**
54
     * @param mixed $accountId
55
     */
56
    public function setAccountId($accountId)
57
    {
58
        $this->accountId = $accountId;
59
    }
60
61
    /**
62
     * @return mixed
63
     */
64
    public function getListId()
65
    {
66
        return $this->listId;
67
    }
68
69
    /**
70
     * @param mixed $listId
71
     */
72
    public function setListId($listId)
73
    {
74
        $this->listId = $listId;
75
    }
76
77
    /**
78
     * @return mixed
79
     */
80
    public function getCreated()
81
    {
82
        return $this->created;
83
    }
84
85
    /**
86
     * @param mixed $created
87
     */
88
    public function setCreated($created)
89
    {
90
        $this->created = $created;
91
    }
92
93
    /**
94
     * @return mixed
95
     */
96
    public function getModified()
97
    {
98
        return $this->modified;
99
    }
100
101
    /**
102
     * @param mixed $modified
103
     */
104
    public function setModified($modified)
105
    {
106
        $this->modified = $modified;
107
    }
108
109
    /**
110
     * @return mixed
111
     */
112
    public function getState()
113
    {
114
        return $this->state;
115
    }
116
117
    /**
118
     * @param mixed $state
119
     */
120
    public function setState($state)
121
    {
122
        $this->state = $state;
123
    }
124
125
    /**
126
     * @return mixed
127
     */
128
    public function getName()
129
    {
130
        return $this->name;
131
    }
132
133
    /**
134
     * @param mixed $name
135
     */
136
    public function setName($name)
137
    {
138
        $this->name = $name;
139
    }
140
141
    /**
142
     * @return mixed
143
     */
144
    public function getRemarks()
145
    {
146
        return $this->remarks;
147
    }
148
149
    /**
150
     * @param mixed $remarks
151
     */
152
    public function setRemarks($remarks)
153
    {
154
        $this->remarks = $remarks;
155
    }
156
157
    /**
158
     * @return mixed
159
     */
160
    public function getSubscribeNotificationEmail()
161
    {
162
        return $this->subscribeNotificationEmail;
163
    }
164
165
    /**
166
     * @param mixed $subscribeNotificationEmail
167
     */
168
    public function setSubscribeNotificationEmail($subscribeNotificationEmail)
169
    {
170
        $this->subscribeNotificationEmail = $subscribeNotificationEmail;
171
    }
172
173
    /**
174
     * @return mixed
175
     */
176
    public function getUnsubsribeNotificationEmail()
177
    {
178
        return $this->unsubsribeNotificationEmail;
179
    }
180
181
    /**
182
     * @param mixed $unsubsribeNotificationEmail
183
     */
184
    public function setUnsubsribeNotificationEmail($unsubsribeNotificationEmail)
185
    {
186
        $this->unsubsribeNotificationEmail = $unsubsribeNotificationEmail;
187
    }
188
189
    /**
190
     * @return mixed
191
     */
192
    public function getNumberOfActiveMembers()
193
    {
194
        return $this->numberOfActiveMembers;
195
    }
196
197
    /**
198
     * @param mixed $numberOfActiveMembers
199
     */
200
    public function setNumberOfActiveMembers($numberOfActiveMembers)
201
    {
202
        $this->numberOfActiveMembers = $numberOfActiveMembers;
203
    }
204
205
    /**
206
     * @return mixed
207
     */
208
    public function getNumberOfUnsubscribedMembers()
209
    {
210
        return $this->numberOfUnsubscribedMembers;
211
    }
212
213
    /**
214
     * @param mixed $numberOfUnsubscribedMembers
215
     */
216
    public function setNumberOfUnsubscribedMembers($numberOfUnsubscribedMembers)
217
    {
218
        $this->numberOfUnsubscribedMembers = $numberOfUnsubscribedMembers;
219
    }
220
221
    /**
222
     * @return mixed
223
     */
224
    public function getNumberOfCleanedMembers()
225
    {
226
        return $this->numberOfCleanedMembers;
227
    }
228
229
    /**
230
     * @param mixed $numberOfCleanedMembers
231
     */
232
    public function setNumberOfCleanedMembers($numberOfCleanedMembers)
233
    {
234
        $this->numberOfCleanedMembers = $numberOfCleanedMembers;
235
    }
236
}