Completed
Push — v2 ( e6c7b3...40717e )
by Beñat
06:35
created

User::getShallowUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
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\Model;
13
14
/**
15
 * The user model class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class User implements Model
20
{
21
    protected $shallowUser;
22
    protected $aboutMe;
23
    protected $accountId;
24
    protected $age;
25
    protected $answerCount;
26
    protected $creationDate;
27
    protected $displayName;
28
    protected $downVoteCount;
29
    protected $isEmployee;
30
    protected $lastAccessDate;
31
    protected $lastModifiedDate;
32
    protected $location;
33
    protected $questionCount;
34
    protected $reputationChangeDay;
35
    protected $reputationChangeMonth;
36
    protected $reputationChangeQuarter;
37
    protected $reputationChangeWeek;
38
    protected $reputationChangeYear;
39
    protected $timedPenaltyDate;
40
    protected $upVoteCount;
41
    protected $viewCount;
42
    protected $websiteUrl;
43
44
    public static function fromJson(array $data)
45
    {
46
        $instance = new self();
47
        $instance
48
            ->setShallowUser(ShallowUser::fromJson($data))
0 ignored issues
show
Documentation introduced by
\BenatEspina\StackExchan...owUser::fromJson($data) is of type object<BenatEspina\Stack...eApiClient\Model\Model>, but the function expects a null|object<BenatEspina\...ient\Model\ShallowUser>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
49
            ->setAboutMe(array_key_exists('about_me', $data) ? $data['about_me'] : null)
50
            ->setAccountId(array_key_exists('account_id', $data) ? $data['account_id'] : null)
51
            ->setAge(array_key_exists('age', $data) ? $data['age'] : null)
52
            ->setAnswerCount(array_key_exists('answer_count', $data) ? $data['answer_count'] : null)
53
            ->setCreationDate(
54
                array_key_exists('creation_date', $data)
55
                    ? new \DateTime('@' . $data['creation_date'])
56
                    : null
57
            )
58
            ->setDisplayName(array_key_exists('display_name', $data) ? $data['display_name'] : null)
59
            ->setDownVoteCount(array_key_exists('down_vote_count', $data) ? $data['down_vote_count'] : null)
60
            ->setIsEmployee(array_key_exists('is_employee', $data) ? $data['is_employee'] : null)
61
            ->setLastAccessDate(
62
                array_key_exists('last_access_date', $data)
63
                    ? new \DateTimeImmutable('@' . $data['last_access_date'])
64
                    : null
65
            )
66
            ->setLastModifiedDate(
67
                array_key_exists('last_modified_date', $data)
68
                    ? new \DateTimeImmutable('@' . $data['last_modified_date'])
69
                    : null
70
            )
71
            ->setLocation(array_key_exists('location', $data) ? $data['location'] : null)
72
            ->setQuestionCount(array_key_exists('question_count', $data) ? $data['question_count'] : null)
73
            ->setReputationChangeDay(
74
                array_key_exists('reputation_change_day', $data)
75
                    ? $data['reputation_change_day']
76
                    : null
77
            )
78
            ->setReputationChangeMonth(
79
                array_key_exists('reputation_change_month', $data)
80
                    ? $data['reputation_change_month']
81
                    : null
82
            )
83
            ->setReputationChangeQuarter(
84
                array_key_exists('reputation_change_quarter', $data)
85
                    ? $data['reputation_change_quarter']
86
                    : null
87
            )
88
            ->setReputationChangeWeek(
89
                array_key_exists('reputation_change_week', $data)
90
                    ? $data['reputation_change_week']
91
                    : null
92
            )
93
            ->setReputationChangeYear(
94
                array_key_exists('reputation_change_year', $data)
95
                    ? $data['reputation_change_year']
96
                    : null
97
            )
98
            ->setTimedPenaltyDate(
99
                array_key_exists('timed_penalty_date', $data)
100
                    ? new \DateTimeImmutable('@' . $data['timed_penalty_date'])
101
                    : null
102
            )
103
            ->setUpVoteCount(array_key_exists('up_vote_count', $data) ? $data['up_vote_count'] : null)
104
            ->setViewCount(array_key_exists('view_count', $data) ? $data['view_count'] : null)
105
            ->setWebsiteUrl(array_key_exists('website_url', $data) ? $data['website_url'] : null);
106
107
        return $instance;
108
    }
109
110
    public static function fromProperties(
111
        ShallowUser $shallowUser,
112
        $accountId,
113
        $answerCount,
114
        \DateTimeInterface $creationDate,
115
        $displayName,
116
        $downVoteCount,
117
        $isEmployee,
118
        \DateTimeInterface $lastAccessDate,
119
        $questionCount,
120
        $reputationChangeDay,
121
        $reputationChangeMonth,
122
        $reputationChangeQuarter,
123
        $reputationChangeWeek,
124
        $reputationChangeYear,
125
        $upVoteCount,
126
        $viewCount,
127
        $aboutMe = null,
128
        $age = null,
129
        \DateTimeInterface $lastModifiedDate = null,
130
        $location = null,
131
        \DateTimeInterface $timedPenaltyDate = null,
132
        $websiteUrl = null
133
    ) {
134
        $instance = new self();
135
        $instance
136
            ->setShallowUser($shallowUser)
137
            ->setAboutMe($aboutMe)
138
            ->setAccountId($accountId)
139
            ->setAge($age)
140
            ->setAnswerCount($answerCount)
141
            ->setCreationDate($creationDate)
142
            ->setDisplayName($displayName)
143
            ->setDownVoteCount($downVoteCount)
144
            ->setIsEmployee($isEmployee)
145
            ->setLastAccessDate($lastAccessDate)
146
            ->setLastModifiedDate($lastModifiedDate)
147
            ->setLocation($location)
148
            ->setQuestionCount($questionCount)
149
            ->setReputationChangeDay($reputationChangeDay)
150
            ->setReputationChangeMonth($reputationChangeMonth)
151
            ->setReputationChangeQuarter($reputationChangeQuarter)
152
            ->setReputationChangeWeek($reputationChangeWeek)
153
            ->setReputationChangeYear($reputationChangeYear)
154
            ->setTimedPenaltyDate($timedPenaltyDate)
155
            ->setUpVoteCount($upVoteCount)
156
            ->setViewCount($viewCount)
157
            ->setWebsiteUrl($websiteUrl);
158
159
        return $instance;
160
    }
161
162
    public function getShallowUser()
163
    {
164
        return $this->shallowUser;
165
    }
166
167
    public function setShallowUser(ShallowUser $shallowUser = null)
168
    {
169
        $this->shallowUser = $shallowUser;
170
171
        return $this;
172
    }
173
174
    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...
175
    {
176
        return $this->aboutMe;
177
    }
178
179
    public function setAboutMe($aboutMe)
180
    {
181
        $this->aboutMe = $aboutMe;
182
183
        return $this;
184
    }
185
186
    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...
187
    {
188
        return $this->accountId;
189
    }
190
191
    public function setAccountId($accountId)
192
    {
193
        $this->accountId = $accountId;
194
195
        return $this;
196
    }
197
198
    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...
199
    {
200
        return $this->age;
201
    }
202
203
    public function setAge($age)
204
    {
205
        $this->age = $age;
206
207
        return $this;
208
    }
209
210
    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...
211
    {
212
        return $this->answerCount;
213
    }
214
215
    public function setAnswerCount($answerCount)
216
    {
217
        $this->answerCount = $answerCount;
218
219
        return $this;
220
    }
221
222
    public function getCreationDate()
223
    {
224
        return $this->creationDate;
225
    }
226
227
    public function setCreationDate(\DateTimeInterface $creationDate = null)
228
    {
229
        $this->creationDate = $creationDate;
230
231
        return $this;
232
    }
233
234
    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...
235
    {
236
        return $this->displayName;
237
    }
238
239
    public function setDisplayName($displayName)
240
    {
241
        $this->displayName = $displayName;
242
243
        return $this;
244
    }
245
246
    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...
247
    {
248
        return $this->downVoteCount;
249
    }
250
251
    public function setDownVoteCount($downVoteCount)
252
    {
253
        $this->downVoteCount = $downVoteCount;
254
255
        return $this;
256
    }
257
258
    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...
259
    {
260
        return $this->isEmployee;
261
    }
262
263
    public function setIsEmployee($isEmployee)
264
    {
265
        $this->isEmployee = $isEmployee;
266
267
        return $this;
268
    }
269
270
    public function getLastAccessDate()
271
    {
272
        return $this->lastAccessDate;
273
    }
274
275
    public function setLastAccessDate(\DateTimeInterface $lastAccessDate = null)
276
    {
277
        $this->lastAccessDate = $lastAccessDate;
278
279
        return $this;
280
    }
281
282
    public function getLastModifiedDate()
283
    {
284
        return $this->lastModifiedDate;
285
    }
286
287
    public function setLastModifiedDate(\DateTimeInterface $lastModifiedDate = null)
288
    {
289
        $this->lastModifiedDate = $lastModifiedDate;
290
291
        return $this;
292
    }
293
294
    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...
295
    {
296
        return $this->location;
297
    }
298
299
    public function setLocation($location)
300
    {
301
        $this->location = $location;
302
303
        return $this;
304
    }
305
306
    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...
307
    {
308
        return $this->questionCount;
309
    }
310
311
    public function setQuestionCount($questionCount)
312
    {
313
        $this->questionCount = $questionCount;
314
315
        return $this;
316
    }
317
318
    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...
319
    {
320
        return $this->reputationChangeDay;
321
    }
322
323
    public function setReputationChangeDay($reputationChangeDay)
324
    {
325
        $this->reputationChangeDay = $reputationChangeDay;
326
327
        return $this;
328
    }
329
330
    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...
331
    {
332
        return $this->reputationChangeMonth;
333
    }
334
335
    public function setReputationChangeMonth($reputationChangeMonth)
336
    {
337
        $this->reputationChangeMonth = $reputationChangeMonth;
338
339
        return $this;
340
    }
341
342
    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...
343
    {
344
        return $this->reputationChangeQuarter;
345
    }
346
347
    public function setReputationChangeQuarter($reputationChangeQuarter)
348
    {
349
        $this->reputationChangeQuarter = $reputationChangeQuarter;
350
351
        return $this;
352
    }
353
354
    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...
355
    {
356
        return $this->reputationChangeWeek;
357
    }
358
359
    public function setReputationChangeWeek($reputationChangeWeek)
360
    {
361
        $this->reputationChangeWeek = $reputationChangeWeek;
362
363
        return $this;
364
    }
365
366
    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...
367
    {
368
        return $this->reputationChangeYear;
369
    }
370
371
    public function setReputationChangeYear($reputationChangeYear)
372
    {
373
        $this->reputationChangeYear = $reputationChangeYear;
374
375
        return $this;
376
    }
377
378
    public function getTimedPenaltyDate()
379
    {
380
        return $this->timedPenaltyDate;
381
    }
382
383
    public function setTimedPenaltyDate(\DateTimeInterface $timedPenaltyDate = null)
384
    {
385
        $this->timedPenaltyDate = $timedPenaltyDate;
386
387
        return $this;
388
    }
389
390
    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...
391
    {
392
        return $this->upVoteCount;
393
    }
394
395
    public function setUpVoteCount($upVoteCount)
396
    {
397
        $this->upVoteCount = $upVoteCount;
398
399
        return $this;
400
    }
401
402
    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...
403
    {
404
        return $this->viewCount;
405
    }
406
407
    public function setViewCount($viewCount)
408
    {
409
        $this->viewCount = $viewCount;
410
411
        return $this;
412
    }
413
414
    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...
415
    {
416
        return $this->websiteUrl;
417
    }
418
419
    public function setWebsiteUrl($websiteUrl)
420
    {
421
        $this->websiteUrl = $websiteUrl;
422
423
        return $this;
424
    }
425
}
426