Completed
Push — v3 ( d12fea )
by Beñat
05:39
created

AnemicUser::getUpVoteCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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,
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 121 characters

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.

Loading history...
60
            array_key_exists('last_modified_date', $data) ? new \DateTimeImmutable('@' . $data['last_modified_date']) : null,
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

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.

Loading history...
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,
0 ignored issues
show
Bug introduced by
It seems like array_key_exists('timed_..._penalty_date']) : null can also be of type object<DateTimeImmutable>; however, BenatEspina\StackExchang...emicUser::__construct() does only seem to accept null|object<DateTime>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

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.

Loading history...
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,
0 ignored issues
show
Bug introduced by
It seems like $timedPenaltyDate defined by parameter $timedPenaltyDate on line 96 can also be of type object<DateTimeInterface>; however, BenatEspina\StackExchang...emicUser::__construct() does only seem to accept null|object<DateTime>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
426
    {
427
        return $this->websiteUrl;
428
    }
429
430
    public function setWebsiteUrl($websiteUrl)
431
    {
432
        $this->websiteUrl = $websiteUrl;
433
434
        return $this;
435
    }
436
}
437