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 | namespace GorkaLaucirica\HipchatAPIv2Client\Model; |
||
4 | |||
5 | class Room |
||
6 | { |
||
7 | protected $id; |
||
8 | |||
9 | protected $xmppJid; |
||
10 | |||
11 | //protected $statistics; |
||
12 | |||
13 | protected $name; |
||
14 | |||
15 | protected $links; |
||
16 | |||
17 | protected $created; |
||
18 | |||
19 | protected $archived; |
||
20 | |||
21 | protected $privacy; |
||
22 | |||
23 | protected $guestAccessible; |
||
24 | |||
25 | protected $topic; |
||
26 | |||
27 | protected $participants; |
||
28 | |||
29 | protected $owner; |
||
30 | |||
31 | protected $guestAccessUrl; |
||
32 | |||
33 | /** |
||
34 | * Builds a room object from server response if json given, otherwise creates an empty object |
||
35 | * |
||
36 | * @param array $json json_decoded response in json given by the server |
||
37 | * |
||
38 | * @return self |
||
0 ignored issues
–
show
|
|||
39 | */ |
||
40 | public function __construct($json = null) |
||
41 | { |
||
42 | if ($json) { |
||
43 | $this->parseJson($json); |
||
44 | } else { |
||
45 | $this->guestAccessible = false; |
||
46 | $this->privacy = 'public'; |
||
47 | } |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Parses response given by the API and maps the fields to Room object |
||
52 | * |
||
53 | * @param array $json json_decoded response in json given by the server |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | public function parseJson($json) |
||
58 | { |
||
59 | $this->id = $json['id']; |
||
60 | $this->name = $json['name']; |
||
61 | $this->links = $json['links']; |
||
62 | |||
63 | if (isset($json['xmpp_jid'])) { |
||
64 | $this->xmppJid = $json['xmpp_jid']; |
||
65 | //Statistics need to be implemented |
||
66 | $this->created = new \DateTime($json['created']); |
||
67 | $this->archived = $json['is_archived']; |
||
68 | $this->privacy = $json['privacy']; |
||
69 | $this->guestAccessible = $json['is_guest_accessible']; |
||
70 | $this->topic = $json['topic']; |
||
71 | $this->participants = array(); |
||
72 | foreach ($json['participants'] as $participant) { |
||
73 | $this->participants[] = new User($participant); |
||
74 | } |
||
75 | $this->owner = new User($json['owner']); |
||
76 | $this->guestAccessUrl = $json['guest_access_url']; |
||
77 | } |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * Serializes Room object |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | public function toJson() |
||
86 | { |
||
87 | $json = array(); |
||
88 | |||
89 | $json['name'] = $this->getName(); |
||
90 | $json['privacy'] = $this->getPrivacy(); |
||
91 | //Parameters for PUT call (Room already exists) |
||
92 | if ($this->getId()) { |
||
93 | $json['is_archived'] = $this->isArchived(); |
||
94 | $json['is_guest_accessible'] = $this->isGuestAccessible(); |
||
95 | $json['topic'] = $this->getTopic(); |
||
96 | $json['owner'] = array('id' => $this->getOwner()->getId()); |
||
97 | } else { //Paramters for POST call |
||
98 | $json['guest_access'] = $this->isGuestAccessible(); |
||
99 | if ($this->getOwner()) { |
||
100 | $json['owner_user_id'] = $this->getOwner()->getId(); |
||
101 | } |
||
102 | } |
||
103 | return $json; |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * Sets id |
||
108 | * |
||
109 | * @param integer $id The id to be set |
||
110 | * |
||
111 | * @return self |
||
112 | */ |
||
113 | public function setId($id) |
||
114 | { |
||
115 | $this->id = $id; |
||
116 | return $this; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Returns id |
||
121 | * |
||
122 | * @return integer |
||
123 | */ |
||
124 | public function getId() |
||
125 | { |
||
126 | return $this->id; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Sets XMPP/Jabber ID of the room |
||
131 | * |
||
132 | * @param string $xmppJid XMPP/Jabber ID of the room |
||
133 | * |
||
134 | * @return self |
||
135 | */ |
||
136 | public function setXmppJid($xmppJid) |
||
137 | { |
||
138 | $this->xmppJid = $xmppJid; |
||
139 | return $this; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * Returns XMPP/Jabber ID of the room |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | public function getXmppJid() |
||
148 | { |
||
149 | return $this->xmppJid; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Sets name of the room |
||
154 | * |
||
155 | * @param mixed $name Name of the room. |
||
156 | * |
||
157 | * @return self |
||
158 | */ |
||
159 | public function setName($name) |
||
160 | { |
||
161 | $this->name = $name; |
||
162 | return $this; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * Returns Name of the room |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function getName() |
||
171 | { |
||
172 | return $this->name; |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * Sets URLs to retrieve room information |
||
177 | * |
||
178 | * @param array $links URLs to retrieve room information |
||
179 | * |
||
180 | * @return self |
||
181 | */ |
||
182 | public function setLinks($links) |
||
183 | { |
||
184 | $this->links = $links; |
||
185 | return $this; |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Returns URLs to retrieve room information |
||
190 | * |
||
191 | * @return array |
||
192 | */ |
||
193 | public function getLinks() |
||
194 | { |
||
195 | return $this->links; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * Sets time the room was created in UTC |
||
200 | * |
||
201 | * @param \Datetime $created Time the room was created in UTC |
||
202 | * |
||
203 | * @return self |
||
204 | */ |
||
205 | public function setCreated($created) |
||
206 | { |
||
207 | $this->created = $created; |
||
208 | return $this; |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * Returns time the room was created in UTC |
||
213 | * |
||
214 | * @return \Datetime |
||
215 | */ |
||
216 | public function getCreated() |
||
217 | { |
||
218 | return $this->created; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * Sets whether or not this room is archived |
||
223 | * |
||
224 | * @param boolean $archived Whether or not this room is archived |
||
225 | * |
||
226 | * @return self |
||
227 | */ |
||
228 | public function setArchived($archived) |
||
229 | { |
||
230 | $this->archived = $archived; |
||
231 | return $this; |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Returns if is archived or not |
||
236 | * |
||
237 | * @return mixed |
||
238 | */ |
||
239 | public function isArchived() |
||
240 | { |
||
241 | return $this->archived; |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * Sets Privacy setting |
||
246 | * |
||
247 | * @param string $privacy Privacy setting. Valid values: public | private |
||
248 | * |
||
249 | * @return self |
||
250 | */ |
||
251 | public function setPrivacy($privacy) |
||
252 | { |
||
253 | $this->privacy = $privacy; |
||
254 | return $this; |
||
255 | } |
||
256 | |||
257 | /** |
||
258 | * Returns privacy setting |
||
259 | * |
||
260 | * @return string public | private |
||
261 | */ |
||
262 | public function getPrivacy() |
||
263 | { |
||
264 | return $this->privacy; |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Sets whether or not guests can access this room |
||
269 | * |
||
270 | * @param boolean $guestAccessible Whether or not guests can access this room |
||
271 | * |
||
272 | * @return self |
||
273 | */ |
||
274 | public function setGuestAccessible($guestAccessible) |
||
275 | { |
||
276 | $this->guestAccessible = $guestAccessible; |
||
277 | return $this; |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * Returns whether or not guests can access this room |
||
282 | * |
||
283 | * @return boolean |
||
284 | */ |
||
285 | public function isGuestAccessible() |
||
286 | { |
||
287 | return $this->guestAccessible; |
||
288 | } |
||
289 | |||
290 | /** |
||
291 | * Sets current topic |
||
292 | * |
||
293 | * @param string $topic Current topic |
||
294 | * |
||
295 | * @return self |
||
296 | */ |
||
297 | public function setTopic($topic) |
||
298 | { |
||
299 | $this->topic = $topic; |
||
300 | return $this; |
||
301 | } |
||
302 | |||
303 | /** |
||
304 | * Returns current topic |
||
305 | * |
||
306 | * @return string |
||
307 | */ |
||
308 | public function getTopic() |
||
309 | { |
||
310 | return $this->topic; |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * Sets list of current room participants |
||
315 | * |
||
316 | * @param array $participants List of current room participants |
||
317 | * |
||
318 | * @return self |
||
319 | */ |
||
320 | public function setParticipants($participants) |
||
321 | { |
||
322 | $this->participants = $participants; |
||
323 | return $this; |
||
324 | } |
||
325 | |||
326 | /** |
||
327 | * Returns list of current room participants |
||
328 | * |
||
329 | * @return array of User |
||
330 | */ |
||
331 | public function getParticipants() |
||
332 | { |
||
333 | return $this->participants; |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * Sets the room owner |
||
338 | * |
||
339 | * @param User $owner The room owner |
||
340 | * |
||
341 | * @return self |
||
342 | */ |
||
343 | public function setOwner($owner) |
||
344 | { |
||
345 | $this->owner = $owner; |
||
346 | return $this; |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * Returns the room owner |
||
351 | * |
||
352 | * @return User |
||
353 | */ |
||
354 | public function getOwner() |
||
355 | { |
||
356 | return $this->owner; |
||
357 | } |
||
358 | |||
359 | /** |
||
360 | * Sets URL for guest access |
||
361 | * |
||
362 | * @param string $guestAccessUrl URL for guest access |
||
363 | * |
||
364 | * @return self |
||
365 | */ |
||
366 | public function setGuestAccessUrl($guestAccessUrl) |
||
367 | { |
||
368 | $this->guestAccessUrl = $guestAccessUrl; |
||
369 | return $this; |
||
370 | } |
||
371 | |||
372 | /** |
||
373 | * Returns URL for guest access, if enabled |
||
374 | * |
||
375 | * @return string | null |
||
376 | */ |
||
377 | public function getGuestAccessUrl() |
||
378 | { |
||
379 | return $this->guestAccessUrl; |
||
380 | } |
||
381 | } |
||
382 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.