1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Stack Exchange Api Client library. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2014-2015 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 tag model class. |
16
|
|
|
* |
17
|
|
|
* @author Beñat Espiña <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class Tag |
20
|
|
|
{ |
21
|
|
|
private $count; |
22
|
|
|
private $hasSynonyms; |
23
|
|
|
private $isModeratorOnly; |
24
|
|
|
private $isRequired; |
25
|
|
|
private $lastActivityDate; |
26
|
|
|
private $name; |
27
|
|
|
private $synonyms; |
28
|
|
|
private $userId; |
29
|
|
|
|
30
|
|
|
public static function fromJson(array $data) |
31
|
|
|
{ |
32
|
|
|
return new self( |
33
|
|
|
array_key_exists('count', $data) ? $data['count'] : null, |
34
|
|
|
array_key_exists('has_synonyms', $data) ? $data['has_synonyms'] : null, |
35
|
|
|
array_key_exists('is_moderator_only', $data) ? $data['is_moderator_only'] : null, |
36
|
|
|
array_key_exists('is_required', $data) ? $data['is_required'] : null, |
37
|
|
|
array_key_exists('last_activity_date', $data) ? new \DateTime('@' . $data['last_activity_date']) : null, |
38
|
|
|
array_key_exists('name', $data) ? $data['name'] : null, |
39
|
|
|
array_key_exists('synonyms', $data) ? $data['synonyms'] : null, |
40
|
|
|
array_key_exists('user_id', $data) ? $data['user_id'] : null |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function fromProperties( |
45
|
|
|
$count, |
46
|
|
|
$hasSynonyms, |
47
|
|
|
$isModeratorOnly, |
48
|
|
|
$isRequired, |
49
|
|
|
$name, |
50
|
|
|
$synonyms, |
51
|
|
|
\DateTime $lastActivityDate = null, |
52
|
|
|
$userId = null |
53
|
|
|
) { |
54
|
|
|
return new self( |
55
|
|
|
$count, |
56
|
|
|
$hasSynonyms, |
57
|
|
|
$isModeratorOnly, |
58
|
|
|
$isRequired, |
59
|
|
|
$lastActivityDate, |
60
|
|
|
$name, |
61
|
|
|
$synonyms, |
62
|
|
|
$userId |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
private function __construct( |
67
|
|
|
$count = null, |
68
|
|
|
$hasSynonyms = null, |
69
|
|
|
$isModeratorOnly = null, |
70
|
|
|
$isRequired = null, |
71
|
|
|
\DateTime $lastActivityDate = null, |
72
|
|
|
$name = null, |
73
|
|
|
$synonyms = null, |
74
|
|
|
$userId = null |
75
|
|
|
) { |
76
|
|
|
$this->count = $count; |
77
|
|
|
$this->hasSynonyms = $hasSynonyms; |
78
|
|
|
$this->isModeratorOnly = $isModeratorOnly; |
79
|
|
|
$this->isRequired = $isRequired; |
80
|
|
|
$this->lastActivityDate = $lastActivityDate; |
81
|
|
|
$this->name = $name; |
82
|
|
|
$this->synonyms = $synonyms; |
83
|
|
|
$this->userId = $userId; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getCount() |
|
|
|
|
87
|
|
|
{ |
88
|
|
|
return $this->count; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function setCount($count) |
92
|
|
|
{ |
93
|
|
|
$this->count = $count; |
94
|
|
|
|
95
|
|
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function getHasSynonyms() |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
return $this->hasSynonyms; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function setHasSynonyms($hasSynonyms) |
104
|
|
|
{ |
105
|
|
|
$this->hasSynonyms = $hasSynonyms; |
106
|
|
|
|
107
|
|
|
return $this; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function getIsModeratorOnly() |
|
|
|
|
111
|
|
|
{ |
112
|
|
|
return $this->isModeratorOnly; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function setIsModeratorOnly($isModeratorOnly) |
116
|
|
|
{ |
117
|
|
|
$this->isModeratorOnly = $isModeratorOnly; |
118
|
|
|
|
119
|
|
|
return $this; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getIsRequired() |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
return $this->isRequired; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function setIsRequired($isRequired) |
128
|
|
|
{ |
129
|
|
|
$this->isRequired = $isRequired; |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getLastActivityDate() |
135
|
|
|
{ |
136
|
|
|
return $this->lastActivityDate; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function setLastActivityDate(\DateTime $lastActivityDate) |
140
|
|
|
{ |
141
|
|
|
$this->lastActivityDate = $lastActivityDate; |
142
|
|
|
|
143
|
|
|
return $this; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function getName() |
|
|
|
|
147
|
|
|
{ |
148
|
|
|
return $this->name; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function setName($name) |
152
|
|
|
{ |
153
|
|
|
$this->name = $name; |
154
|
|
|
|
155
|
|
|
return $this; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getSynonyms() |
|
|
|
|
159
|
|
|
{ |
160
|
|
|
return $this->synonyms; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function setSynonyms($synonyms) |
164
|
|
|
{ |
165
|
|
|
$this->synonyms = $synonyms; |
166
|
|
|
|
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function getUserId() |
|
|
|
|
171
|
|
|
{ |
172
|
|
|
return $this->userId; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function setUserId($userId) |
176
|
|
|
{ |
177
|
|
|
$this->userId = $userId; |
178
|
|
|
|
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|
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.