@@ -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; |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @since 9.0.0 |
195 | 195 | */ |
196 | 196 | public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH) { |
197 | - if(!is_string($message)) { |
|
197 | + if (!is_string($message)) { |
|
198 | 198 | throw new \InvalidArgumentException('String expected.'); |
199 | 199 | } |
200 | 200 | $message = trim($message); |
201 | 201 | if ($maxLength && mb_strlen($message, 'UTF-8') > $maxLength) { |
202 | - throw new MessageTooLongException('Comment message must not exceed ' . $maxLength. ' characters'); |
|
202 | + throw new MessageTooLongException('Comment message must not exceed '.$maxLength.' characters'); |
|
203 | 203 | } |
204 | 204 | $this->data['message'] = $message; |
205 | 205 | return $this; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function getMentions() { |
229 | 229 | $ok = preg_match_all("/\B(?<![^a-z0-9_\-@\.\'\s])@(\"guest\/[a-f0-9]+\"|\"[a-z0-9_\-@\.\' ]+\"|[a-z0-9_\-@\.\']+)/i", $this->getMessage(), $mentions); |
230 | - if(!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { |
|
230 | + if (!$ok || !isset($mentions[0]) || !is_array($mentions[0])) { |
|
231 | 231 | return []; |
232 | 232 | } |
233 | 233 | $uids = array_unique($mentions[0]); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @since 9.0.0 |
262 | 262 | */ |
263 | 263 | public function setVerb($verb) { |
264 | - if(!is_string($verb) || !trim($verb)) { |
|
264 | + if (!is_string($verb) || !trim($verb)) { |
|
265 | 265 | throw new \InvalidArgumentException('Non-empty String expected.'); |
266 | 266 | } |
267 | 267 | $this->data['verb'] = trim($verb); |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @since 9.0.0 |
298 | 298 | */ |
299 | 299 | public function setActor($actorType, $actorId) { |
300 | - if( |
|
300 | + if ( |
|
301 | 301 | !is_string($actorType) || !trim($actorType) |
302 | - || !is_string($actorId) || !trim($actorId) |
|
302 | + || !is_string($actorId) || !trim($actorId) |
|
303 | 303 | ) { |
304 | 304 | throw new \InvalidArgumentException('String expected.'); |
305 | 305 | } |
@@ -383,9 +383,9 @@ discard block |
||
383 | 383 | * @since 9.0.0 |
384 | 384 | */ |
385 | 385 | public function setObject($objectType, $objectId) { |
386 | - if( |
|
386 | + if ( |
|
387 | 387 | !is_string($objectType) || !trim($objectType) |
388 | - || !is_string($objectId) || !trim($objectId) |
|
388 | + || !is_string($objectId) || !trim($objectId) |
|
389 | 389 | ) { |
390 | 390 | throw new \InvalidArgumentException('String expected.'); |
391 | 391 | } |
@@ -402,20 +402,20 @@ discard block |
||
402 | 402 | * @return IComment |
403 | 403 | */ |
404 | 404 | protected function fromArray($data) { |
405 | - foreach(array_keys($data) as $key) { |
|
405 | + foreach (array_keys($data) as $key) { |
|
406 | 406 | // translate DB keys to internal setter names |
407 | - $setter = 'set' . implode('', array_map('ucfirst', explode('_', $key))); |
|
407 | + $setter = 'set'.implode('', array_map('ucfirst', explode('_', $key))); |
|
408 | 408 | $setter = str_replace('Timestamp', 'DateTime', $setter); |
409 | 409 | |
410 | - if(method_exists($this, $setter)) { |
|
410 | + if (method_exists($this, $setter)) { |
|
411 | 411 | $this->$setter($data[$key]); |
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | - foreach(['actor', 'object'] as $role) { |
|
416 | - if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) { |
|
417 | - $setter = 'set' . ucfirst($role); |
|
418 | - $this->$setter($data[$role . '_type'], $data[$role . '_id']); |
|
415 | + foreach (['actor', 'object'] as $role) { |
|
416 | + if (isset($data[$role.'_type']) && isset($data[$role.'_id'])) { |
|
417 | + $setter = 'set'.ucfirst($role); |
|
418 | + $this->$setter($data[$role.'_type'], $data[$role.'_id']); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 |