@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * the comments database scheme |
53 | 53 | */ |
54 | 54 | public function __construct(array $data = null) { |
55 | - if(is_array($data)) { |
|
55 | + if (is_array($data)) { |
|
56 | 56 | $this->fromArray($data); |
57 | 57 | } |
58 | 58 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @since 9.0.0 |
86 | 86 | */ |
87 | 87 | public function setId($id) { |
88 | - if(!is_string($id)) { |
|
88 | + if (!is_string($id)) { |
|
89 | 89 | throw new \InvalidArgumentException('String expected.'); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $id = trim($id); |
93 | - if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) { |
|
93 | + if ($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) { |
|
94 | 94 | $this->data['id'] = $id; |
95 | 95 | return $this; |
96 | 96 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @since 9.0.0 |
117 | 117 | */ |
118 | 118 | public function setParentId($parentId) { |
119 | - if(!is_string($parentId)) { |
|
119 | + if (!is_string($parentId)) { |
|
120 | 120 | throw new \InvalidArgumentException('String expected.'); |
121 | 121 | } |
122 | 122 | $this->data['parentId'] = trim($parentId); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @since 9.0.0 |
143 | 143 | */ |
144 | 144 | public function setTopmostParentId($id) { |
145 | - if(!is_string($id)) { |
|
145 | + if (!is_string($id)) { |
|
146 | 146 | throw new \InvalidArgumentException('String expected.'); |
147 | 147 | } |
148 | 148 | $this->data['topmostParentId'] = trim($id); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @since 9.0.0 |
168 | 168 | */ |
169 | 169 | public function setChildrenCount($count) { |
170 | - if(!is_int($count)) { |
|
170 | + if (!is_int($count)) { |
|
171 | 171 | throw new \InvalidArgumentException('Integer expected.'); |
172 | 172 | } |
173 | 173 | $this->data['childrenCount'] = $count; |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @since 9.0.0 |
194 | 194 | */ |
195 | 195 | public function setMessage($message) { |
196 | - if(!is_string($message)) { |
|
196 | + if (!is_string($message)) { |
|
197 | 197 | throw new \InvalidArgumentException('String expected.'); |
198 | 198 | } |
199 | 199 | $message = trim($message); |
200 | - if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) { |
|
201 | - throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters'); |
|
200 | + if (mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) { |
|
201 | + throw new MessageTooLongException('Comment message must not exceed '.IComment::MAX_MESSAGE_LENGTH.' characters'); |
|
202 | 202 | } |
203 | 203 | $this->data['message'] = $message; |
204 | 204 | return $this; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function getMentions() { |
228 | 228 | $ok = preg_match_all('/\B@[a-z0-9_\-@\.\']+/i', $this->getMessage(), $mentions); |
229 | - if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { |
|
229 | + if (!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { |
|
230 | 230 | return []; |
231 | 231 | } |
232 | 232 | $uids = array_unique($mentions[0]); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @since 9.0.0 |
256 | 256 | */ |
257 | 257 | public function setVerb($verb) { |
258 | - if(!is_string($verb) || !trim($verb)) { |
|
258 | + if (!is_string($verb) || !trim($verb)) { |
|
259 | 259 | throw new \InvalidArgumentException('Non-empty String expected.'); |
260 | 260 | } |
261 | 261 | $this->data['verb'] = trim($verb); |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | * @since 9.0.0 |
292 | 292 | */ |
293 | 293 | public function setActor($actorType, $actorId) { |
294 | - if( |
|
294 | + if ( |
|
295 | 295 | !is_string($actorType) || !trim($actorType) |
296 | - || !is_string($actorId) || !trim($actorId) |
|
296 | + || !is_string($actorId) || !trim($actorId) |
|
297 | 297 | ) { |
298 | 298 | throw new \InvalidArgumentException('String expected.'); |
299 | 299 | } |
@@ -377,9 +377,9 @@ discard block |
||
377 | 377 | * @since 9.0.0 |
378 | 378 | */ |
379 | 379 | public function setObject($objectType, $objectId) { |
380 | - if( |
|
380 | + if ( |
|
381 | 381 | !is_string($objectType) || !trim($objectType) |
382 | - || !is_string($objectId) || !trim($objectId) |
|
382 | + || !is_string($objectId) || !trim($objectId) |
|
383 | 383 | ) { |
384 | 384 | throw new \InvalidArgumentException('String expected.'); |
385 | 385 | } |
@@ -396,20 +396,20 @@ discard block |
||
396 | 396 | * @return IComment |
397 | 397 | */ |
398 | 398 | protected function fromArray($data) { |
399 | - foreach(array_keys($data) as $key) { |
|
399 | + foreach (array_keys($data) as $key) { |
|
400 | 400 | // translate DB keys to internal setter names |
401 | - $setter = 'set' . implode('', array_map('ucfirst', explode('_', $key))); |
|
401 | + $setter = 'set'.implode('', array_map('ucfirst', explode('_', $key))); |
|
402 | 402 | $setter = str_replace('Timestamp', 'DateTime', $setter); |
403 | 403 | |
404 | - if(method_exists($this, $setter)) { |
|
404 | + if (method_exists($this, $setter)) { |
|
405 | 405 | $this->$setter($data[$key]); |
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - foreach(['actor', 'object'] as $role) { |
|
410 | - if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) { |
|
411 | - $setter = 'set' . ucfirst($role); |
|
412 | - $this->$setter($data[$role . '_type'], $data[$role . '_id']); |
|
409 | + foreach (['actor', 'object'] as $role) { |
|
410 | + if (isset($data[$role.'_type']) && isset($data[$role.'_id'])) { |
|
411 | + $setter = 'set'.ucfirst($role); |
|
412 | + $this->$setter($data[$role.'_type'], $data[$role.'_id']); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 |
@@ -151,7 +151,7 @@ |
||
151 | 151 | |
152 | 152 | public function takeOutCurrentUser(array &$users) { |
153 | 153 | $currentUser = $this->userSession->getUser(); |
154 | - if(!is_null($currentUser)) { |
|
154 | + if (!is_null($currentUser)) { |
|
155 | 155 | if (isset($users[$currentUser->getUID()])) { |
156 | 156 | unset($users[$currentUser->getUID()]); |
157 | 157 | } |