This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @copyright 2017 Vladimir Jimenez |
||
5 | * @license https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT |
||
6 | */ |
||
7 | |||
8 | namespace allejo\DaPulse; |
||
9 | |||
10 | use allejo\DaPulse\Objects\ApiObject; |
||
11 | |||
12 | /** |
||
13 | * The PulseUser class contains all of the functions related to accessing information about a user |
||
14 | * |
||
15 | * @api |
||
16 | * @package allejo\DaPulse |
||
17 | * @since 0.1.0 |
||
18 | */ |
||
19 | class PulseUser extends ApiObject |
||
20 | { |
||
21 | const API_PREFIX = "users"; |
||
22 | |||
23 | /** |
||
24 | * The resource's URL. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $url; |
||
29 | |||
30 | /** |
||
31 | * The user's name. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $name; |
||
36 | |||
37 | /** |
||
38 | * The user's email. |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $email; |
||
43 | |||
44 | /** |
||
45 | * The user's photo_url. |
||
46 | * |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $photo_url; |
||
50 | |||
51 | /** |
||
52 | * The user's title. |
||
53 | * |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $title; |
||
57 | |||
58 | /** |
||
59 | * The user's position. |
||
60 | * |
||
61 | * @var string |
||
62 | */ |
||
63 | protected $position; |
||
64 | |||
65 | /** |
||
66 | * The user's phone. |
||
67 | * |
||
68 | * @var string |
||
69 | */ |
||
70 | protected $phone; |
||
71 | |||
72 | /** |
||
73 | * The user's location. |
||
74 | * |
||
75 | * @var string |
||
76 | */ |
||
77 | protected $location; |
||
78 | |||
79 | /** |
||
80 | * The user's status. |
||
81 | * |
||
82 | * @var string |
||
83 | */ |
||
84 | protected $status; |
||
85 | |||
86 | /** |
||
87 | * The user's birthday. |
||
88 | * |
||
89 | * @var string |
||
90 | */ |
||
91 | protected $birthday; |
||
92 | |||
93 | /** |
||
94 | * True if the user is guest, false otherwise |
||
95 | * |
||
96 | * @var bool |
||
97 | */ |
||
98 | protected $is_guest; |
||
99 | |||
100 | /** |
||
101 | * The user's skills. |
||
102 | * |
||
103 | * @var string[] |
||
104 | */ |
||
105 | protected $skills; |
||
106 | |||
107 | /** |
||
108 | * Creation time. |
||
109 | * |
||
110 | * @var \DateTime |
||
111 | */ |
||
112 | protected $created_at; |
||
113 | |||
114 | /** |
||
115 | * Last update time. |
||
116 | * |
||
117 | * @var \DateTime |
||
118 | */ |
||
119 | protected $updated_at; |
||
120 | |||
121 | /** |
||
122 | * The URL pattern used for all calls |
||
123 | * |
||
124 | * @var string |
||
125 | */ |
||
126 | private $urlSyntax = "%s/%s/%s.json"; |
||
127 | |||
128 | // ================================================================================================================ |
||
129 | // Getter functions |
||
130 | // ================================================================================================================ |
||
131 | |||
132 | /** |
||
133 | * The resource's URL. |
||
134 | * |
||
135 | * @api |
||
136 | * |
||
137 | * @since 0.1.0 |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getUrl () |
||
142 | { |
||
143 | $this->lazyLoad(); |
||
144 | |||
145 | return $this->url; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * The user's unique identifier. |
||
150 | * |
||
151 | * @api |
||
152 | * |
||
153 | * @since 0.1.0 |
||
154 | * |
||
155 | * @return int |
||
156 | */ |
||
157 | 8 | public function getId () |
|
158 | { |
||
159 | 8 | return $this->id; |
|
160 | } |
||
161 | |||
162 | /** |
||
163 | * The user's name. |
||
164 | * |
||
165 | * @api |
||
166 | * |
||
167 | * @since 0.1.0 |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getName () |
||
172 | { |
||
173 | $this->lazyLoad(); |
||
174 | |||
175 | return $this->name; |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * The user's email. |
||
180 | * |
||
181 | * @api |
||
182 | * |
||
183 | * @since 0.1.0 |
||
184 | * |
||
185 | * @return string |
||
186 | */ |
||
187 | public function getEmail () |
||
188 | { |
||
189 | $this->lazyLoad(); |
||
190 | |||
191 | return $this->email; |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * The user's photo_url. |
||
196 | * |
||
197 | * @api |
||
198 | * |
||
199 | * @since 0.1.0 |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | public function getPhotoUrl () |
||
204 | { |
||
205 | $this->lazyLoad(); |
||
206 | |||
207 | return $this->photo_url; |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * The user's title. |
||
212 | * |
||
213 | * @api |
||
214 | * |
||
215 | * @since 0.1.0 |
||
216 | * |
||
217 | * @return string |
||
218 | */ |
||
219 | public function getTitle () |
||
220 | { |
||
221 | $this->lazyLoad(); |
||
222 | |||
223 | return $this->title; |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * The user's position. |
||
228 | * |
||
229 | * @api |
||
230 | * |
||
231 | * @since 0.1.0 |
||
232 | * |
||
233 | * @return string |
||
234 | */ |
||
235 | public function getPosition () |
||
236 | { |
||
237 | $this->lazyLoad(); |
||
238 | |||
239 | return $this->position; |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * The user's phone. |
||
244 | * |
||
245 | * @api |
||
246 | * |
||
247 | * @since 0.1.0 |
||
248 | * |
||
249 | * @return string |
||
250 | */ |
||
251 | public function getPhone () |
||
252 | { |
||
253 | $this->lazyLoad(); |
||
254 | |||
255 | return $this->phone; |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * The user's location. |
||
260 | * |
||
261 | * @api |
||
262 | * |
||
263 | * @since 0.1.0 |
||
264 | * |
||
265 | * @return string |
||
266 | */ |
||
267 | public function getLocation () |
||
268 | { |
||
269 | $this->lazyLoad(); |
||
270 | |||
271 | return $this->location; |
||
272 | } |
||
273 | |||
274 | /** |
||
275 | * The user's status. |
||
276 | * |
||
277 | * @api |
||
278 | * |
||
279 | * @since 0.1.0 |
||
280 | * |
||
281 | * @return string |
||
282 | */ |
||
283 | public function getStatus () |
||
284 | { |
||
285 | $this->lazyLoad(); |
||
286 | |||
287 | return $this->status; |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * The user's birthday. |
||
292 | * |
||
293 | * @api |
||
294 | * |
||
295 | * @since 0.1.0 |
||
296 | * |
||
297 | * @return string |
||
298 | */ |
||
299 | public function getBirthday () |
||
300 | { |
||
301 | $this->lazyLoad(); |
||
302 | |||
303 | return $this->birthday; |
||
304 | } |
||
305 | |||
306 | /** |
||
307 | * The user's skills. |
||
308 | * |
||
309 | * @api |
||
310 | * |
||
311 | * @since 0.1.0 |
||
312 | * |
||
313 | * @return string[] |
||
314 | */ |
||
315 | public function getSkills () |
||
316 | { |
||
317 | $this->lazyLoad(); |
||
318 | |||
319 | return $this->skills; |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * Creation time. |
||
324 | * |
||
325 | * @api |
||
326 | * |
||
327 | * @since 0.1.0 |
||
328 | * |
||
329 | * @return \DateTime |
||
330 | */ |
||
331 | public function getCreatedAt () |
||
332 | { |
||
333 | $this->lazyLoad(); |
||
334 | self::lazyCast($this->created_at, '\DateTime'); |
||
335 | |||
336 | return $this->created_at; |
||
337 | } |
||
338 | |||
339 | /** |
||
340 | * Last update time. |
||
341 | * |
||
342 | * @api |
||
343 | * |
||
344 | * @since 0.1.0 |
||
345 | * |
||
346 | * @return \DateTime |
||
347 | */ |
||
348 | public function getUpdatedAt () |
||
349 | { |
||
350 | $this->lazyLoad(); |
||
351 | self::lazyCast($this->updated_at, '\DateTime'); |
||
352 | |||
353 | return $this->updated_at; |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * True if the user is guest, false otherwise |
||
358 | * |
||
359 | * @api |
||
360 | * |
||
361 | * @since 0.3.0 |
||
362 | * |
||
363 | * @return bool |
||
364 | */ |
||
365 | public function isGuest () |
||
366 | { |
||
367 | $this->lazyLoad(); |
||
368 | |||
369 | return $this->is_guest; |
||
370 | } |
||
371 | |||
372 | /** |
||
373 | * Get the user's newsfeed |
||
374 | * |
||
375 | * @api |
||
376 | * |
||
377 | * @param array $params GET parameters that need to be passed in the URL |
||
378 | * |
||
379 | * @since 0.1.0 |
||
380 | * |
||
381 | * @return PulseUpdate[] An array of PulseUpdates that make up the user's newsfeed |
||
382 | */ |
||
383 | public function getNewsFeed ($params = []) |
||
384 | { |
||
385 | $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "newsfeed"); |
||
0 ignored issues
–
show
|
|||
386 | |||
387 | return parent::fetchAndCastToObjectArray($url, "PulseUpdate", $params); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
fetchAndCastToObjectArray() instead of getNewsFeed() ). Are you sure this is correct? If so, you might want to change this to $this->fetchAndCastToObjectArray() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
388 | } |
||
389 | |||
390 | /** |
||
391 | * Get the user's posts |
||
392 | * |
||
393 | * @api |
||
394 | * |
||
395 | * @param array $params GET parameters that need to be passed in the URL |
||
396 | * |
||
397 | * @since 0.1.0 |
||
398 | * |
||
399 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
400 | */ |
||
401 | public function getPosts ($params = []) |
||
402 | { |
||
403 | $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "posts"); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
apiEndpoint() instead of getPosts() ). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
404 | |||
405 | return parent::fetchAndCastToObjectArray($url, "PulseUpdate", $params); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
fetchAndCastToObjectArray() instead of getPosts() ). Are you sure this is correct? If so, you might want to change this to $this->fetchAndCastToObjectArray() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
406 | } |
||
407 | |||
408 | /** |
||
409 | * Get the user's unread posts |
||
410 | * |
||
411 | * @api |
||
412 | * |
||
413 | * @param array $params GET parameters that need to be passed in the URL |
||
414 | * |
||
415 | * @since 0.1.0 |
||
416 | * |
||
417 | * @return PulseUpdate[] An array of PulseUpdates for each of the posts |
||
418 | */ |
||
419 | public function getUnreadFeed ($params = []) |
||
420 | { |
||
421 | $url = sprintf($this->urlSyntax, parent::apiEndpoint(), $this->id, "unread_feed"); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
apiEndpoint() instead of getUnreadFeed() ). Are you sure this is correct? If so, you might want to change this to $this->apiEndpoint() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
422 | |||
423 | return parent::fetchAndCastToObjectArray($url, "PulseUpdate", $params); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
fetchAndCastToObjectArray() instead of getUnreadFeed() ). Are you sure this is correct? If so, you might want to change this to $this->fetchAndCastToObjectArray() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
424 | } |
||
425 | |||
426 | /** |
||
427 | * Get all of the users |
||
428 | * |
||
429 | * @api |
||
430 | * |
||
431 | * @param array $params GET parameters that need to be passed in the URL |
||
432 | * |
||
433 | * @since 0.1.0 |
||
434 | * |
||
435 | * @return PulseUser[] An array of PulseUsers for each of the users |
||
436 | */ |
||
437 | public static function getUsers ($params = []) |
||
438 | { |
||
439 | $url = sprintf("%s.json", parent::apiEndpoint()); |
||
440 | |||
441 | return parent::fetchAndCastToObjectArray($url, "PulseUser", $params); |
||
0 ignored issues
–
show
It seems like you call parent on a different method (
fetchAndCastToObjectArray() instead of getUsers() ). Are you sure this is correct? If so, you might want to change this to $this->fetchAndCastToObjectArray() .
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: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
442 | } |
||
443 | |||
444 | // ================================================================================================================= |
||
445 | // Convenience functions |
||
446 | // ================================================================================================================= |
||
447 | |||
448 | /** |
||
449 | * Check whether a given value can be casted or used to get a user ID |
||
450 | * |
||
451 | * @internal |
||
452 | * |
||
453 | * @param int|PulseUser $user |
||
454 | * |
||
455 | * @since 0.3.0 |
||
456 | * |
||
457 | * @throws \InvalidArgumentException if $user is not an integer, is not positive, or is not a PulseUser object |
||
458 | */ |
||
459 | 14 | public static function _isCastable ($user) |
|
460 | { |
||
461 | 14 | if ((!is_int($user) || (is_int($user) && $user < 1)) && !($user instanceof PulseUser)) |
|
462 | { |
||
463 | 6 | throw new \InvalidArgumentException('$user is expected to be a positive integer or a PulseUser object'); |
|
464 | } |
||
465 | 8 | } |
|
466 | |||
467 | /** |
||
468 | * @internal |
||
469 | * |
||
470 | * @param int|PulseUser $user |
||
471 | * |
||
472 | * @since 0.3.0 |
||
473 | * |
||
474 | * @throws \InvalidArgumentException |
||
475 | * |
||
476 | * @return int |
||
477 | */ |
||
478 | 14 | public static function _castToInt ($user) |
|
479 | { |
||
480 | 14 | self::_isCastable($user); |
|
481 | |||
482 | 8 | return ($user instanceof PulseUser) ? $user->getId() : $user; |
|
483 | } |
||
484 | } |
||
485 |
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.