1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Audiens\DoubleclickClient\entity; |
4
|
|
|
|
5
|
|
|
use Audiens\DoubleclickClient\exceptions\ClientException; |
6
|
|
|
|
7
|
|
|
class Segment |
8
|
|
|
{ |
9
|
|
|
/** @var int */ |
10
|
|
|
protected $segmentId; |
11
|
|
|
|
12
|
|
|
/** @var string */ |
13
|
|
|
protected $segmentName; |
14
|
|
|
|
15
|
|
|
/** @var string */ |
16
|
|
|
protected $segmentStatus; |
17
|
|
|
|
18
|
|
|
/** @var null|string */ |
19
|
|
|
protected $description; |
20
|
|
|
|
21
|
|
|
/** @var null|string */ |
22
|
|
|
protected $integrationCode; |
23
|
|
|
|
24
|
|
|
/** @var null|string */ |
25
|
|
|
protected $accountUserListStatus; |
26
|
|
|
|
27
|
|
|
/** @var null */ |
28
|
|
|
protected $accessReason; |
29
|
|
|
|
30
|
|
|
/** @var null */ |
31
|
|
|
protected $isEligibleForSearch; |
32
|
|
|
|
33
|
|
|
/** @var null */ |
34
|
|
|
protected $membershipLifeSpan; |
35
|
|
|
|
36
|
|
|
/** @var string */ |
37
|
|
|
protected $listType; |
38
|
|
|
|
39
|
|
|
/** @var string */ |
40
|
|
|
protected $size; |
41
|
|
|
|
42
|
|
|
public function __construct($segmentId, $segmentName, $segmentStatus, $description = null, $integrationCode = null, $accountUserListStatus = null, $accessReason = null, $isEligibleForSearch = null, $membershipLifeSpan = null) |
43
|
|
|
{ |
44
|
|
|
$this->segmentId = $segmentId; |
45
|
|
|
$this->segmentName = $segmentName; |
46
|
|
|
$this->segmentStatus = $segmentStatus; |
47
|
|
|
$this->description = $description; |
48
|
|
|
$this->integrationCode = $integrationCode; |
49
|
|
|
$this->accountUserListStatus = $accountUserListStatus; |
50
|
|
|
$this->accessReason = $accessReason; |
51
|
|
|
$this->isEligibleForSearch = $isEligibleForSearch; |
52
|
|
|
$this->membershipLifeSpan = $membershipLifeSpan; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return int |
57
|
|
|
*/ |
58
|
|
|
public function getSegmentId() |
59
|
|
|
{ |
60
|
|
|
return $this->segmentId; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getSegmentName() |
67
|
|
|
{ |
68
|
|
|
return $this->segmentName; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param $name |
73
|
|
|
*/ |
74
|
|
|
public function setSegmentName($name) |
75
|
|
|
{ |
76
|
|
|
$this->segmentName = $name; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
public function getSegmentStatus() |
83
|
|
|
{ |
84
|
|
|
return $this->segmentStatus; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getDescription() |
91
|
|
|
{ |
92
|
|
|
return $this->description; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $description |
97
|
|
|
*/ |
98
|
|
|
public function setDescription($description) |
99
|
|
|
{ |
100
|
|
|
$this->description = $description; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function getIntegrationCode() |
107
|
|
|
{ |
108
|
|
|
return $this->integrationCode; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param string $integrationCode |
113
|
|
|
*/ |
114
|
|
|
public function setIntegrationCode($integrationCode) |
115
|
|
|
{ |
116
|
|
|
$this->integrationCode = $integrationCode; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return string |
121
|
|
|
*/ |
122
|
|
|
public function getAccountUserListStatus() |
123
|
|
|
{ |
124
|
|
|
return $this->accountUserListStatus; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @param string $accountUserListStatus |
129
|
|
|
*/ |
130
|
|
|
public function setAccountUserListStatus($accountUserListStatus) |
131
|
|
|
{ |
132
|
|
|
$this->accountUserListStatus = $accountUserListStatus; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @return mixed |
137
|
|
|
*/ |
138
|
|
|
public function getAccessReason() |
139
|
|
|
{ |
140
|
|
|
return $this->accessReason; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @param mixed $accessReason |
145
|
|
|
*/ |
146
|
|
|
public function setAccessReason($accessReason) |
147
|
|
|
{ |
148
|
|
|
$this->accessReason = $accessReason; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return mixed |
153
|
|
|
*/ |
154
|
|
|
public function getisEligibleForSearch() |
155
|
|
|
{ |
156
|
|
|
return $this->isEligibleForSearch; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param mixed $isEligibleForSearch |
161
|
|
|
*/ |
162
|
|
|
public function setIsEligibleForSearch($isEligibleForSearch) |
163
|
|
|
{ |
164
|
|
|
$this->isEligibleForSearch = $isEligibleForSearch; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @return mixed |
169
|
|
|
*/ |
170
|
|
|
public function getMembershipLifeSpan() |
171
|
|
|
{ |
172
|
|
|
return $this->membershipLifeSpan; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* @param mixed $membershipLifeSpan |
177
|
|
|
*/ |
178
|
|
|
public function setMembershipLifeSpan($membershipLifeSpan) |
179
|
|
|
{ |
180
|
|
|
$this->membershipLifeSpan = $membershipLifeSpan; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* @return mixed |
185
|
|
|
*/ |
186
|
|
|
public function getListType() |
187
|
|
|
{ |
188
|
|
|
return $this->listType; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param $listType |
193
|
|
|
*/ |
194
|
|
|
public function setListType($listType) |
195
|
|
|
{ |
196
|
|
|
$this->listType = $listType; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @return mixed |
201
|
|
|
*/ |
202
|
|
|
public function getSize() |
203
|
|
|
{ |
204
|
|
|
return $this->size; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @param mixed $size |
209
|
|
|
*/ |
210
|
|
|
public function setSize($size) |
211
|
|
|
{ |
212
|
|
|
$this->size = $size; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
public static function fromArray(array $array) |
216
|
|
|
{ |
217
|
|
|
if (!isset($array['id'])) { |
218
|
|
|
throw ClientException::validation('hydration: id'); |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
if (!isset($array['name'])) { |
222
|
|
|
throw ClientException::validation('hydration: name'); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
if (!isset($array['status'])) { |
226
|
|
|
throw ClientException::validation('hydration: status'); |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
$segment = new self( |
230
|
|
|
$array['id'], |
231
|
|
|
$array['name'], |
232
|
|
|
$array['status'] |
233
|
|
|
); |
234
|
|
|
|
235
|
|
View Code Duplication |
if (isset($array['description']) && !is_array($array['description'])) { |
|
|
|
|
236
|
|
|
$segment->setDescription($array['description']); |
237
|
|
|
} |
238
|
|
|
|
239
|
|
View Code Duplication |
if (isset($array['accountuserliststatus']) && !is_array($array['accountuserliststatus'])) { |
|
|
|
|
240
|
|
|
$segment->setAccountUserListStatus($array['accountuserliststatus']); |
241
|
|
|
} |
242
|
|
View Code Duplication |
if (isset($array['accessreason']) && !is_array($array['accessreason'])) { |
|
|
|
|
243
|
|
|
$segment->setAccessReason($array['accessreason']); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
View Code Duplication |
if (isset($array['iseligibleforsearch']) && !is_array($array['iseligibleforsearch'])) { |
|
|
|
|
247
|
|
|
$segment->setIsEligibleForSearch($array['iseligibleforsearch']); |
248
|
|
|
} |
249
|
|
View Code Duplication |
if (isset($array['membershiplifespan']) && !is_array($array['membershiplifespan'])) { |
|
|
|
|
250
|
|
|
$segment->setMembershipLifeSpan($array['membershiplifespan']); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
View Code Duplication |
if (isset($array['listtype']) && !is_array($array['listtype'])) { |
|
|
|
|
254
|
|
|
$segment->setListType($array['listtype']); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
View Code Duplication |
if (isset($array['size']) && !is_array($array['size'])) { |
|
|
|
|
258
|
|
|
$segment->setSize($array['size']); |
259
|
|
|
} |
260
|
|
|
|
261
|
|
View Code Duplication |
if (isset($array['integrationcode']) && !is_array($array['integrationcode'])) { |
|
|
|
|
262
|
|
|
$segment->setIntegrationCode($array['integrationcode']); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
return $segment; |
266
|
|
|
} |
267
|
|
|
} |
268
|
|
|
|
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.