1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stack Exchange Api Client library. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2014-2016 Beñat Espiña <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace BenatEspina\StackExchangeApiClient\Infrastructure\Domain\Model; |
13
|
|
|
|
14
|
|
|
use BenatEspina\StackExchangeApiClient\Domain\Model\ShallowUser; |
15
|
|
|
use BenatEspina\StackExchangeApiClient\Domain\Model\User; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* The anemic implementation of user domain class. |
19
|
|
|
* |
20
|
|
|
* @author Beñat Espiña <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class AnemicUser implements User |
23
|
|
|
{ |
24
|
|
|
private $shallowUser; |
25
|
|
|
private $aboutMe; |
26
|
|
|
private $accountId; |
27
|
|
|
private $age; |
28
|
|
|
private $answerCount; |
29
|
|
|
private $creationDate; |
30
|
|
|
private $displayName; |
31
|
|
|
private $downVoteCount; |
32
|
|
|
private $isEmployee; |
33
|
|
|
private $lastAccessDate; |
34
|
|
|
private $lastModifiedDate; |
35
|
|
|
private $location; |
36
|
|
|
private $questionCount; |
37
|
|
|
private $reputationChangeDay; |
38
|
|
|
private $reputationChangeMonth; |
39
|
|
|
private $reputationChangeQuarter; |
40
|
|
|
private $reputationChangeWeek; |
41
|
|
|
private $reputationChangeYear; |
42
|
|
|
private $timedPenaltyDate; |
43
|
|
|
private $upVoteCount; |
44
|
|
|
private $viewCount; |
45
|
|
|
private $websiteUrl; |
46
|
|
|
|
47
|
|
|
public static function fromJson($data) |
48
|
|
|
{ |
49
|
|
|
return new self( |
50
|
|
|
AnemicShallowUser::fromJson($data), |
51
|
|
|
array_key_exists('about_me', $data) ? $data['about_me'] : null, |
52
|
|
|
array_key_exists('account_id', $data) ? $data['account_id'] : null, |
53
|
|
|
array_key_exists('age', $data) ? $data['age'] : null, |
54
|
|
|
array_key_exists('answer_count', $data) ? $data['answer_count'] : null, |
55
|
|
|
array_key_exists('creation_date', $data) ? new \DateTimeImmutable('@' . $data['creation_date']) : null, |
56
|
|
|
array_key_exists('display_name', $data) ? $data['display_name'] : null, |
57
|
|
|
array_key_exists('down_vote_count', $data) ? $data['down_vote_count'] : null, |
58
|
|
|
array_key_exists('is_employee', $data) ? $data['is_employee'] : null, |
59
|
|
|
array_key_exists('last_access_date', $data) ? new \DateTimeImmutable('@' . $data['last_access_date']) : null, |
|
|
|
|
60
|
|
|
array_key_exists('last_modified_date', $data) ? new \DateTimeImmutable('@' . $data['last_modified_date']) : null, |
|
|
|
|
61
|
|
|
array_key_exists('location', $data) ? $data['location'] : null, |
62
|
|
|
array_key_exists('question_count', $data) ? $data['question_count'] : null, |
63
|
|
|
array_key_exists('reputation_change_day', $data) ? $data['reputation_change_day'] : null, |
64
|
|
|
array_key_exists('reputation_change_month', $data) ? $data['reputation_change_month'] : null, |
65
|
|
|
array_key_exists('reputation_change_quarter', $data) ? $data['reputation_change_quarter'] : null, |
66
|
|
|
array_key_exists('reputation_change_week', $data) ? $data['reputation_change_week'] : null, |
67
|
|
|
array_key_exists('reputation_change_year', $data) ? $data['reputation_change_year'] : null, |
68
|
|
|
array_key_exists('timed_penalty_date', $data) ? new \DateTimeImmutable('@' . $data['timed_penalty_date']) : null, |
|
|
|
|
69
|
|
|
array_key_exists('up_vote_count', $data) ? $data['up_vote_count'] : null, |
70
|
|
|
array_key_exists('view_count', $data) ? $data['view_count'] : null, |
71
|
|
|
array_key_exists('website_url', $data) ? $data['website_url'] : null |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public static function fromProperties( |
76
|
|
|
AnemicShallowUser $shallowUser, |
77
|
|
|
$accountId, |
78
|
|
|
$answerCount, |
79
|
|
|
\DateTimeInterface $creationDate, |
80
|
|
|
$displayName, |
81
|
|
|
$downVoteCount, |
82
|
|
|
$isEmployee, |
83
|
|
|
\DateTimeInterface $lastAccessDate, |
84
|
|
|
$questionCount, |
85
|
|
|
$reputationChangeDay, |
86
|
|
|
$reputationChangeMonth, |
87
|
|
|
$reputationChangeQuarter, |
88
|
|
|
$reputationChangeWeek, |
89
|
|
|
$reputationChangeYear, |
90
|
|
|
$upVoteCount, |
91
|
|
|
$viewCount, |
92
|
|
|
$aboutMe = null, |
93
|
|
|
$age = null, |
94
|
|
|
\DateTimeInterface $lastModifiedDate = null, |
95
|
|
|
$location = null, |
96
|
|
|
\DateTimeInterface $timedPenaltyDate = null, |
97
|
|
|
$websiteUrl = null |
98
|
|
|
) { |
99
|
|
|
return new self( |
100
|
|
|
$shallowUser, |
101
|
|
|
$aboutMe, |
102
|
|
|
$accountId, |
103
|
|
|
$age, |
104
|
|
|
$answerCount, |
105
|
|
|
$creationDate, |
106
|
|
|
$displayName, |
107
|
|
|
$downVoteCount, |
108
|
|
|
$isEmployee, |
109
|
|
|
$lastAccessDate, |
110
|
|
|
$lastModifiedDate, |
111
|
|
|
$location, |
112
|
|
|
$questionCount, |
113
|
|
|
$reputationChangeDay, |
114
|
|
|
$reputationChangeMonth, |
115
|
|
|
$reputationChangeQuarter, |
116
|
|
|
$reputationChangeWeek, |
117
|
|
|
$reputationChangeYear, |
118
|
|
|
$timedPenaltyDate, |
|
|
|
|
119
|
|
|
$upVoteCount, |
120
|
|
|
$viewCount, |
121
|
|
|
$websiteUrl |
122
|
|
|
); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
private function __construct( |
126
|
|
|
ShallowUser $shallowUser = null, |
127
|
|
|
$aboutMe = null, |
128
|
|
|
$accountId = null, |
129
|
|
|
$age = null, |
130
|
|
|
$answerCount = null, |
131
|
|
|
\DateTimeInterface $creationDate = null, |
132
|
|
|
$displayName = null, |
133
|
|
|
$downVoteCount = null, |
134
|
|
|
$isEmployee = null, |
135
|
|
|
\DateTimeInterface $lastAccessDate = null, |
136
|
|
|
\DateTimeInterface $lastModifiedDate = null, |
137
|
|
|
$location = null, |
138
|
|
|
$questionCount = null, |
139
|
|
|
$reputationChangeDay = null, |
140
|
|
|
$reputationChangeMonth = null, |
141
|
|
|
$reputationChangeQuarter = null, |
142
|
|
|
$reputationChangeWeek = null, |
143
|
|
|
$reputationChangeYear = null, |
144
|
|
|
\DateTime $timedPenaltyDate = null, |
145
|
|
|
$upVoteCount = null, |
146
|
|
|
$viewCount = null, |
147
|
|
|
$websiteUrl = null |
148
|
|
|
) { |
149
|
|
|
$this->shallowUser = $shallowUser; |
150
|
|
|
$this->aboutMe = $aboutMe; |
151
|
|
|
$this->accountId = $accountId; |
152
|
|
|
$this->age = $age; |
153
|
|
|
$this->answerCount = $answerCount; |
154
|
|
|
$this->creationDate = $creationDate; |
155
|
|
|
$this->displayName = $displayName; |
156
|
|
|
$this->downVoteCount = $downVoteCount; |
157
|
|
|
$this->isEmployee = $isEmployee; |
158
|
|
|
$this->lastAccessDate = $lastAccessDate; |
159
|
|
|
$this->lastModifiedDate = $lastModifiedDate; |
160
|
|
|
$this->location = $location; |
161
|
|
|
$this->questionCount = $questionCount; |
162
|
|
|
$this->reputationChangeDay = $reputationChangeDay; |
163
|
|
|
$this->reputationChangeMonth = $reputationChangeMonth; |
164
|
|
|
$this->reputationChangeQuarter = $reputationChangeQuarter; |
165
|
|
|
$this->reputationChangeWeek = $reputationChangeWeek; |
166
|
|
|
$this->reputationChangeYear = $reputationChangeYear; |
167
|
|
|
$this->timedPenaltyDate = $timedPenaltyDate; |
168
|
|
|
$this->upVoteCount = $upVoteCount; |
169
|
|
|
$this->viewCount = $viewCount; |
170
|
|
|
$this->websiteUrl = $websiteUrl; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
public function getShallowUser() |
174
|
|
|
{ |
175
|
|
|
return $this->shallowUser; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function setShallowUser(ShallowUser $shallowUser) |
179
|
|
|
{ |
180
|
|
|
$this->shallowUser = $shallowUser; |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
public function getAboutMe() |
|
|
|
|
186
|
|
|
{ |
187
|
|
|
return $this->aboutMe; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
public function setAboutMe($aboutMe) |
191
|
|
|
{ |
192
|
|
|
$this->aboutMe = $aboutMe; |
193
|
|
|
|
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
public function getAccountId() |
|
|
|
|
198
|
|
|
{ |
199
|
|
|
return $this->accountId; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function setAccountId($accountId) |
203
|
|
|
{ |
204
|
|
|
$this->accountId = $accountId; |
205
|
|
|
|
206
|
|
|
return $this; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function getAge() |
|
|
|
|
210
|
|
|
{ |
211
|
|
|
return $this->age; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public function setAge($age) |
215
|
|
|
{ |
216
|
|
|
$this->age = $age; |
217
|
|
|
|
218
|
|
|
return $this; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
public function getAnswerCount() |
|
|
|
|
222
|
|
|
{ |
223
|
|
|
return $this->answerCount; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
public function setAnswerCount($answerCount) |
227
|
|
|
{ |
228
|
|
|
$this->answerCount = $answerCount; |
229
|
|
|
|
230
|
|
|
return $this; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
public function getCreationDate() |
234
|
|
|
{ |
235
|
|
|
return $this->creationDate; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function setCreationDate(\DateTimeInterface $creationDate) |
239
|
|
|
{ |
240
|
|
|
$this->creationDate = $creationDate; |
241
|
|
|
|
242
|
|
|
return $this; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
public function getDisplayName() |
|
|
|
|
246
|
|
|
{ |
247
|
|
|
return $this->displayName; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
public function setDisplayName($displayName) |
251
|
|
|
{ |
252
|
|
|
$this->displayName = $displayName; |
253
|
|
|
|
254
|
|
|
return $this; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
public function getDownVoteCount() |
|
|
|
|
258
|
|
|
{ |
259
|
|
|
return $this->downVoteCount; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function setDownVoteCount($downVoteCount) |
263
|
|
|
{ |
264
|
|
|
$this->downVoteCount = $downVoteCount; |
265
|
|
|
|
266
|
|
|
return $this; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function getIsEmployee() |
|
|
|
|
270
|
|
|
{ |
271
|
|
|
return $this->isEmployee; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
public function setIsEmployee($isEmployee) |
275
|
|
|
{ |
276
|
|
|
$this->isEmployee = $isEmployee; |
277
|
|
|
|
278
|
|
|
return $this; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
public function getLastAccessDate() |
282
|
|
|
{ |
283
|
|
|
return $this->lastAccessDate; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
public function setLastAccessDate(\DateTimeInterface $lastAccessDate) |
287
|
|
|
{ |
288
|
|
|
$this->lastAccessDate = $lastAccessDate; |
289
|
|
|
|
290
|
|
|
return $this; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
public function getLastModifiedDate() |
294
|
|
|
{ |
295
|
|
|
return $this->lastModifiedDate; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
public function setLastModifiedDate(\DateTimeInterface $lastModifiedDate) |
299
|
|
|
{ |
300
|
|
|
$this->lastModifiedDate = $lastModifiedDate; |
301
|
|
|
|
302
|
|
|
return $this; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
public function getLocation() |
|
|
|
|
306
|
|
|
{ |
307
|
|
|
return $this->location; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
public function setLocation($location) |
311
|
|
|
{ |
312
|
|
|
$this->location = $location; |
313
|
|
|
|
314
|
|
|
return $this; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public function getQuestionCount() |
|
|
|
|
318
|
|
|
{ |
319
|
|
|
return $this->questionCount; |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
public function setQuestionCount($questionCount) |
323
|
|
|
{ |
324
|
|
|
$this->questionCount = $questionCount; |
325
|
|
|
|
326
|
|
|
return $this; |
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
public function getReputationChangeDay() |
|
|
|
|
330
|
|
|
{ |
331
|
|
|
return $this->reputationChangeDay; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
public function setReputationChangeDay($reputationChangeDay) |
335
|
|
|
{ |
336
|
|
|
$this->reputationChangeDay = $reputationChangeDay; |
337
|
|
|
|
338
|
|
|
return $this; |
339
|
|
|
} |
340
|
|
|
|
341
|
|
|
public function getReputationChangeMonth() |
|
|
|
|
342
|
|
|
{ |
343
|
|
|
return $this->reputationChangeMonth; |
344
|
|
|
} |
345
|
|
|
|
346
|
|
|
public function setReputationChangeMonth($reputationChangeMonth) |
347
|
|
|
{ |
348
|
|
|
$this->reputationChangeMonth = $reputationChangeMonth; |
349
|
|
|
|
350
|
|
|
return $this; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
public function getReputationChangeQuarter() |
|
|
|
|
354
|
|
|
{ |
355
|
|
|
return $this->reputationChangeQuarter; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
public function setReputationChangeQuarter($reputationChangeQuarter) |
359
|
|
|
{ |
360
|
|
|
$this->reputationChangeQuarter = $reputationChangeQuarter; |
361
|
|
|
|
362
|
|
|
return $this; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
public function getReputationChangeWeek() |
|
|
|
|
366
|
|
|
{ |
367
|
|
|
return $this->reputationChangeWeek; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
public function setReputationChangeWeek($reputationChangeWeek) |
371
|
|
|
{ |
372
|
|
|
$this->reputationChangeWeek = $reputationChangeWeek; |
373
|
|
|
|
374
|
|
|
return $this; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
public function getReputationChangeYear() |
|
|
|
|
378
|
|
|
{ |
379
|
|
|
return $this->reputationChangeYear; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
public function setReputationChangeYear($reputationChangeYear) |
383
|
|
|
{ |
384
|
|
|
$this->reputationChangeYear = $reputationChangeYear; |
385
|
|
|
|
386
|
|
|
return $this; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
public function getTimedPenaltyDate() |
390
|
|
|
{ |
391
|
|
|
return $this->timedPenaltyDate; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
public function setTimedPenaltyDate(\DateTimeInterface $timedPenaltyDate) |
395
|
|
|
{ |
396
|
|
|
$this->timedPenaltyDate = $timedPenaltyDate; |
397
|
|
|
|
398
|
|
|
return $this; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
public function getUpVoteCount() |
|
|
|
|
402
|
|
|
{ |
403
|
|
|
return $this->upVoteCount; |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
public function setUpVoteCount($upVoteCount) |
407
|
|
|
{ |
408
|
|
|
$this->upVoteCount = $upVoteCount; |
409
|
|
|
|
410
|
|
|
return $this; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
public function getViewCount() |
|
|
|
|
414
|
|
|
{ |
415
|
|
|
return $this->viewCount; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
public function setViewCount($viewCount) |
419
|
|
|
{ |
420
|
|
|
$this->viewCount = $viewCount; |
421
|
|
|
|
422
|
|
|
return $this; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
public function getWebsiteUrl() |
|
|
|
|
426
|
|
|
{ |
427
|
|
|
return $this->websiteUrl; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
public function setWebsiteUrl($websiteUrl) |
431
|
|
|
{ |
432
|
|
|
$this->websiteUrl = $websiteUrl; |
433
|
|
|
|
434
|
|
|
return $this; |
435
|
|
|
} |
436
|
|
|
} |
437
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.