1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stack Exchange Api Client library. |
5
|
|
|
* |
6
|
|
|
* (c) 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
|
|
|
declare(strict_types=1); |
13
|
|
|
/* |
14
|
|
|
* This file is part of the Stack Exchange Api Client library. |
15
|
|
|
* |
16
|
|
|
* (c) Beñat Espiña <[email protected]> |
17
|
|
|
* |
18
|
|
|
* For the full copyright and license information, please view the LICENSE |
19
|
|
|
* file that was distributed with this source code. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace BenatEspina\StackExchangeApiClient\Model; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class info model class. |
26
|
|
|
* |
27
|
|
|
* @author Beñat Espiña <[email protected]> |
28
|
|
|
*/ |
29
|
|
|
class Info implements Model |
30
|
|
|
{ |
31
|
|
|
protected $totalAccepted; |
32
|
|
|
protected $totalAnswers; |
33
|
|
|
protected $totalBadges; |
34
|
|
|
protected $totalComments; |
35
|
|
|
protected $totalQuestions; |
36
|
|
|
protected $totalUnanswered; |
37
|
|
|
protected $totalUsers; |
38
|
|
|
protected $totalVotes; |
39
|
|
|
protected $answersPerMinute; |
40
|
|
|
protected $apiRevision; |
41
|
|
|
protected $badgesPerMinute; |
42
|
|
|
protected $newActiveUsers; |
43
|
|
|
protected $questionsPerMinute; |
44
|
|
|
protected $site; |
45
|
|
|
|
46
|
|
|
public static function fromJson(array $data) |
47
|
|
|
{ |
48
|
|
|
$instance = new self(); |
49
|
|
|
$instance |
50
|
|
|
->setTotalAccepted(array_key_exists('total_accepted', $data) ? $data['total_accepted'] : null) |
51
|
|
|
->setTotalAnswers(array_key_exists('total_answers', $data) ? $data['total_answers'] : null) |
52
|
|
|
->setTotalBadges(array_key_exists('total_badges', $data) ? $data['total_badges'] : null) |
53
|
|
|
->setTotalComments(array_key_exists('total_comments', $data) ? $data['total_comments'] : null) |
54
|
|
|
->setTotalQuestions(array_key_exists('total_questions', $data) ? $data['total_questions'] : null) |
55
|
|
|
->setTotalUnanswered(array_key_exists('total_unanswered', $data) ? $data['total_unanswered'] : null) |
56
|
|
|
->setTotalUsers(array_key_exists('total_users', $data) ? $data['total_users'] : null) |
57
|
|
|
->setTotalVotes(array_key_exists('total_votes', $data) ? $data['total_votes'] : null) |
58
|
|
|
->setAnswersPerMinute( |
59
|
|
|
array_key_exists('answers_per_minute', $data) |
60
|
|
|
? $data['answers_per_minute'] |
61
|
|
|
: null |
62
|
|
|
) |
63
|
|
|
->setApiRevision(array_key_exists('api_revision', $data) ? $data['api_revision'] : null) |
64
|
|
|
->setBadgesPerMinute( |
65
|
|
|
array_key_exists('badges_per_minute', $data) |
66
|
|
|
? $data['badges_per_minute'] |
67
|
|
|
: null |
68
|
|
|
) |
69
|
|
|
->setNewActiveUsers( |
70
|
|
|
array_key_exists('new_active_users', $data) |
71
|
|
|
? $data['new_active_users'] |
72
|
|
|
: null |
73
|
|
|
) |
74
|
|
|
->setQuestionsPerMinute( |
75
|
|
|
array_key_exists('questions_per_minute', $data) |
76
|
|
|
? $data['questions_per_minute'] |
77
|
|
|
: null |
78
|
|
|
) |
79
|
|
|
->setSite(array_key_exists('site', $data) ? Site::fromJson($data['site']) : null); |
|
|
|
|
80
|
|
|
|
81
|
|
|
return $instance; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public static function fromProperties( |
85
|
|
|
$totalAccepted, |
86
|
|
|
$totalAnswers, |
87
|
|
|
$totalBadges, |
88
|
|
|
$totalComments, |
89
|
|
|
$totalQuestions, |
90
|
|
|
$totalUnanswered, |
91
|
|
|
$totalUsers, |
92
|
|
|
$totalVotes, |
93
|
|
|
$answersPerMinute, |
94
|
|
|
$apiRevision, |
95
|
|
|
$badgesPerMinute, |
96
|
|
|
$newActiveUsers, |
97
|
|
|
$questionsPerMinute, |
98
|
|
|
Site $site = null |
99
|
|
|
) { |
100
|
|
|
$instance = new self(); |
101
|
|
|
$instance |
102
|
|
|
->setTotalAccepted($totalAccepted) |
103
|
|
|
->setTotalAnswers($totalAnswers) |
104
|
|
|
->setTotalBadges($totalBadges) |
105
|
|
|
->setTotalComments($totalComments) |
106
|
|
|
->setTotalQuestions($totalQuestions) |
107
|
|
|
->setTotalUnanswered($totalUnanswered) |
108
|
|
|
->setTotalUsers($totalUsers) |
109
|
|
|
->setTotalVotes($totalVotes) |
110
|
|
|
->setAnswersPerMinute($answersPerMinute) |
111
|
|
|
->setApiRevision($apiRevision) |
112
|
|
|
->setBadgesPerMinute($badgesPerMinute) |
113
|
|
|
->setNewActiveUsers($newActiveUsers) |
114
|
|
|
->setQuestionsPerMinute($questionsPerMinute) |
115
|
|
|
->setSite($site); |
116
|
|
|
|
117
|
|
|
return $instance; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function setTotalAccepted($totalAccepted) |
121
|
|
|
{ |
122
|
|
|
$this->totalAccepted = $totalAccepted; |
123
|
|
|
|
124
|
|
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function getTotalAccepted() |
|
|
|
|
128
|
|
|
{ |
129
|
|
|
return $this->totalAccepted; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function setTotalAnswers($totalAnswers) |
133
|
|
|
{ |
134
|
|
|
$this->totalAnswers = $totalAnswers; |
135
|
|
|
|
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getTotalAnswers() |
|
|
|
|
140
|
|
|
{ |
141
|
|
|
return $this->totalAnswers; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function setTotalBadges($totalBadges) |
145
|
|
|
{ |
146
|
|
|
$this->totalBadges = $totalBadges; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function getTotalBadges() |
|
|
|
|
152
|
|
|
{ |
153
|
|
|
return $this->totalBadges; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function setTotalComments($totalComments) |
157
|
|
|
{ |
158
|
|
|
$this->totalComments = $totalComments; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function getTotalComments() |
|
|
|
|
164
|
|
|
{ |
165
|
|
|
return $this->totalComments; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function setTotalQuestions($totalQuestions) |
169
|
|
|
{ |
170
|
|
|
$this->totalQuestions = $totalQuestions; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function getTotalQuestions() |
|
|
|
|
176
|
|
|
{ |
177
|
|
|
return $this->totalQuestions; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function setTotalUnanswered($totalUnanswered) |
181
|
|
|
{ |
182
|
|
|
$this->totalUnanswered = $totalUnanswered; |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function getTotalUnanswered() |
|
|
|
|
188
|
|
|
{ |
189
|
|
|
return $this->totalUnanswered; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function setTotalUsers($totalUsers) |
193
|
|
|
{ |
194
|
|
|
$this->totalUsers = $totalUsers; |
195
|
|
|
|
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
public function getTotalUsers() |
|
|
|
|
200
|
|
|
{ |
201
|
|
|
return $this->totalUsers; |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
public function setTotalVotes($totalVotes) |
205
|
|
|
{ |
206
|
|
|
$this->totalVotes = $totalVotes; |
207
|
|
|
|
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
public function getTotalVotes() |
|
|
|
|
212
|
|
|
{ |
213
|
|
|
return $this->totalVotes; |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
public function setAnswersPerMinute($answersPerMinute) |
217
|
|
|
{ |
218
|
|
|
$this->answersPerMinute = $answersPerMinute; |
219
|
|
|
|
220
|
|
|
return $this; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function getAnswersPerMinute() |
|
|
|
|
224
|
|
|
{ |
225
|
|
|
return $this->answersPerMinute; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function setApiRevision($apiRevision) |
229
|
|
|
{ |
230
|
|
|
$this->apiRevision = $apiRevision; |
231
|
|
|
|
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
public function getApiRevision() |
|
|
|
|
236
|
|
|
{ |
237
|
|
|
return $this->apiRevision; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
public function setBadgesPerMinute($badgesPerMinute) |
241
|
|
|
{ |
242
|
|
|
$this->badgesPerMinute = $badgesPerMinute; |
243
|
|
|
|
244
|
|
|
return $this; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
public function getBadgesPerMinute() |
|
|
|
|
248
|
|
|
{ |
249
|
|
|
return $this->badgesPerMinute; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
public function setNewActiveUsers($newActiveUsers) |
253
|
|
|
{ |
254
|
|
|
$this->newActiveUsers = $newActiveUsers; |
255
|
|
|
|
256
|
|
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
public function getNewActiveUsers() |
|
|
|
|
260
|
|
|
{ |
261
|
|
|
return $this->newActiveUsers; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
public function setQuestionsPerMinute($questionsPerMinute) |
265
|
|
|
{ |
266
|
|
|
$this->questionsPerMinute = $questionsPerMinute; |
267
|
|
|
|
268
|
|
|
return $this; |
269
|
|
|
} |
270
|
|
|
|
271
|
|
|
public function getQuestionsPerMinute() |
|
|
|
|
272
|
|
|
{ |
273
|
|
|
return $this->questionsPerMinute; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
public function setSite(Site $site = null) |
277
|
|
|
{ |
278
|
|
|
$this->site = $site; |
279
|
|
|
|
280
|
|
|
return $this; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
public function getSite() |
284
|
|
|
{ |
285
|
|
|
return $this->site; |
286
|
|
|
} |
287
|
|
|
} |
288
|
|
|
|
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:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.