1 | <?php |
||
18 | class PulseUser extends ApiObject |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | const API_PREFIX = "users"; |
||
24 | |||
25 | /** |
||
26 | * The resource's URL. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $url; |
||
31 | |||
32 | /** |
||
33 | * The user's name. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $name; |
||
38 | |||
39 | /** |
||
40 | * The user's email. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $email; |
||
45 | |||
46 | /** |
||
47 | * The user's photo_url. |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $photo_url; |
||
52 | |||
53 | /** |
||
54 | * The user's title. |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $title; |
||
59 | |||
60 | /** |
||
61 | * The user's position. |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | protected $position; |
||
66 | |||
67 | /** |
||
68 | * The user's phone. |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $phone; |
||
73 | |||
74 | /** |
||
75 | * The user's location. |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | protected $location; |
||
80 | |||
81 | /** |
||
82 | * The user's status. |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | protected $status; |
||
87 | |||
88 | /** |
||
89 | * The user's birthday. |
||
90 | * |
||
91 | * @var string |
||
92 | */ |
||
93 | protected $birthday; |
||
94 | |||
95 | /** |
||
96 | * True if the user is guest, false otherwise |
||
97 | * |
||
98 | * @var bool |
||
99 | */ |
||
100 | protected $is_guest; |
||
101 | |||
102 | /** |
||
103 | * The user's skills. |
||
104 | * |
||
105 | * @var string[] |
||
106 | */ |
||
107 | protected $skills; |
||
108 | |||
109 | /** |
||
110 | * Creation time. |
||
111 | * |
||
112 | * @var \DateTime |
||
113 | */ |
||
114 | protected $created_at; |
||
115 | |||
116 | /** |
||
117 | * Last update time. |
||
118 | * |
||
119 | * @var \DateTime |
||
120 | */ |
||
121 | protected $updated_at; |
||
122 | |||
123 | /** |
||
124 | * The membership type of this user with respect to a specific Pulse or PulseBoard. This value will not be set if |
||
125 | * a PulseUser object is created standalone and not by another object which supports subscribers or membership. |
||
126 | * |
||
127 | * @var mixed |
||
128 | */ |
||
129 | protected $membership; |
||
130 | |||
131 | /** |
||
132 | * The URL pattern used for all calls |
||
133 | * |
||
134 | * @var string |
||
135 | */ |
||
136 | private $urlSyntax = "%s/%s/%s.json"; |
||
137 | |||
138 | // ================================================================================================================ |
||
139 | // Getter functions |
||
140 | // ================================================================================================================ |
||
141 | |||
142 | /** |
||
143 | * The resource's URL. |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | public function getUrl () |
||
148 | { |
||
149 | $this->lazyLoad(); |
||
150 | |||
151 | return $this->url; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * The user's unique identifier. |
||
156 | * |
||
157 | * @return int |
||
158 | */ |
||
159 | public function getId () |
||
160 | { |
||
161 | return $this->id; |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * The user's name. |
||
166 | 3 | * |
|
167 | * @return string |
||
168 | 3 | */ |
|
169 | public function getName () |
||
170 | { |
||
171 | $this->lazyLoad(); |
||
172 | |||
173 | return $this->name; |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * The user's email. |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | public function getEmail () |
||
182 | { |
||
183 | $this->lazyLoad(); |
||
184 | |||
185 | return $this->email; |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * The user's photo_url. |
||
190 | * |
||
191 | * @return string |
||
192 | */ |
||
193 | public function getPhotoUrl () |
||
194 | { |
||
195 | $this->lazyLoad(); |
||
196 | |||
197 | return $this->photo_url; |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * The user's title. |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function getTitle () |
||
206 | { |
||
207 | $this->lazyLoad(); |
||
208 | |||
209 | return $this->title; |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * The user's position. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | public function getPosition () |
||
218 | { |
||
219 | $this->lazyLoad(); |
||
220 | |||
221 | return $this->position; |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * The user's phone. |
||
226 | * |
||
227 | * @return string |
||
228 | */ |
||
229 | public function getPhone () |
||
230 | { |
||
231 | $this->lazyLoad(); |
||
232 | |||
233 | return $this->phone; |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * The user's location. |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | public function getLocation () |
||
242 | { |
||
243 | $this->lazyLoad(); |
||
244 | |||
245 | return $this->location; |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * The user's status. |
||
250 | * |
||
251 | * @return string |
||
252 | */ |
||
253 | public function getStatus () |
||
254 | { |
||
255 | $this->lazyLoad(); |
||
256 | |||
257 | return $this->status; |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * The user's birthday. |
||
262 | * |
||
263 | * @return string |
||
264 | */ |
||
265 | public function getBirthday () |
||
266 | { |
||
267 | $this->lazyLoad(); |
||
268 | |||
269 | return $this->birthday; |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * True if the user is guest, false otherwise |
||
274 | * |
||
275 | * @return bool |
||
276 | */ |
||
277 | public function getIsGuest () |
||
278 | { |
||
279 | $this->lazyLoad(); |
||
280 | |||
281 | return $this->is_guest; |
||
282 | } |
||
283 | |||
284 | /** |
||
285 | * The user's skills. |
||
286 | * |
||
287 | * @return string[] |
||
288 | */ |
||
289 | public function getSkills () |
||
290 | { |
||
291 | $this->lazyLoad(); |
||
292 | |||
293 | return $this->skills; |
||
294 | } |
||
295 | |||
296 | /** |
||
297 | * Creation time. |
||
298 | * |
||
299 | * @return \DateTime |
||
300 | */ |
||
301 | public function getCreatedAt () |
||
302 | { |
||
303 | $this->lazyLoad(); |
||
304 | self::lazyCast($this->created_at, '\DateTime'); |
||
305 | |||
306 | return $this->created_at; |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * Last update time. |
||
311 | * |
||
312 | * @return \DateTime |
||
313 | */ |
||
314 | public function getUpdatedAt () |
||
315 | { |
||
316 | $this->lazyLoad(); |
||
317 | self::lazyCast($this->updated_at, '\DateTime'); |
||
318 | |||
319 | return $this->updated_at; |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * Get the user's newsfeed |
||
324 | * |
||
325 | * @param array $params GET parameters that need to be passed in the URL |
||
326 | * |
||
327 | * @since 0.1.0 |
||
328 | * |
||
329 | * @return PulseUpdate[] An array of PulseUpdates that make up the user's newsfeed |
||
330 | */ |
||
331 | public function getNewsFeed ($params = array()) |
||
337 | |||
338 | /** |
||
339 | * Get the user's posts |
||
340 | * |
||
341 | * @param array $params GET parameters that need to be passed in the URL |
||
342 | * |
||
343 | * @since 0.1.0 |
||
344 | * |
||
345 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
346 | */ |
||
347 | public function getPosts ($params = array()) |
||
353 | |||
354 | /** |
||
355 | * Get the user's unread posts |
||
356 | * |
||
357 | * @param array $params GET parameters that need to be passed in the URL |
||
358 | * |
||
359 | * @since 0.1.0 |
||
360 | * |
||
361 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
362 | */ |
||
363 | public function getUnreadFeed ($params = array()) |
||
369 | |||
370 | /** |
||
371 | * Get all of the users |
||
372 | * |
||
373 | * @param array $params GET parameters that need to be passed in the URL |
||
374 | * |
||
375 | * @since 0.1.0 |
||
376 | * |
||
377 | * @return PulseUser[] An array of PulseUsers for each of the users |
||
378 | */ |
||
379 | public static function getUsers ($params = array()) |
||
385 | |||
386 | // ================================================================================================================= |
||
387 | // Convenience functions |
||
388 | // ================================================================================================================= |
||
389 | |||
390 | /** |
||
391 | * Check whether a given value can be casted or used to get a user ID |
||
392 | * |
||
393 | * @internal |
||
394 | * |
||
395 | * @param int|PulseUser $user |
||
396 | * |
||
397 | * @since 0.3.0 |
||
398 | * |
||
399 | * @throws \InvalidArgumentException if $user is not an integer, is not positive, or is not a PulseUser object |
||
400 | */ |
||
401 | 10 | public static function _isCastable ($user) |
|
408 | |||
409 | /** |
||
410 | * @internal |
||
411 | * |
||
412 | * @param int|PulseUser $user |
||
413 | * |
||
414 | * @since 0.3.0 |
||
415 | * |
||
416 | * @return int |
||
417 | */ |
||
418 | public static function _castToInt ($user) |
||
419 | { |
||
420 | self::_isCastable($user); |
||
421 | |||
422 | return ($user instanceof PulseUser) ? $user->getId() : $user; |
||
423 | } |
||
424 | } |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.