@@ -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])@(\"[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]); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @since 9.0.0 |
257 | 257 | */ |
258 | 258 | public function setVerb($verb) { |
259 | - if(!is_string($verb) || !trim($verb)) { |
|
259 | + if (!is_string($verb) || !trim($verb)) { |
|
260 | 260 | throw new \InvalidArgumentException('Non-empty String expected.'); |
261 | 261 | } |
262 | 262 | $this->data['verb'] = trim($verb); |
@@ -292,9 +292,9 @@ discard block |
||
292 | 292 | * @since 9.0.0 |
293 | 293 | */ |
294 | 294 | public function setActor($actorType, $actorId) { |
295 | - if( |
|
295 | + if ( |
|
296 | 296 | !is_string($actorType) || !trim($actorType) |
297 | - || !is_string($actorId) || !trim($actorId) |
|
297 | + || !is_string($actorId) || !trim($actorId) |
|
298 | 298 | ) { |
299 | 299 | throw new \InvalidArgumentException('String expected.'); |
300 | 300 | } |
@@ -378,9 +378,9 @@ discard block |
||
378 | 378 | * @since 9.0.0 |
379 | 379 | */ |
380 | 380 | public function setObject($objectType, $objectId) { |
381 | - if( |
|
381 | + if ( |
|
382 | 382 | !is_string($objectType) || !trim($objectType) |
383 | - || !is_string($objectId) || !trim($objectId) |
|
383 | + || !is_string($objectId) || !trim($objectId) |
|
384 | 384 | ) { |
385 | 385 | throw new \InvalidArgumentException('String expected.'); |
386 | 386 | } |
@@ -397,20 +397,20 @@ discard block |
||
397 | 397 | * @return IComment |
398 | 398 | */ |
399 | 399 | protected function fromArray($data) { |
400 | - foreach(array_keys($data) as $key) { |
|
400 | + foreach (array_keys($data) as $key) { |
|
401 | 401 | // translate DB keys to internal setter names |
402 | - $setter = 'set' . implode('', array_map('ucfirst', explode('_', $key))); |
|
402 | + $setter = 'set'.implode('', array_map('ucfirst', explode('_', $key))); |
|
403 | 403 | $setter = str_replace('Timestamp', 'DateTime', $setter); |
404 | 404 | |
405 | - if(method_exists($this, $setter)) { |
|
405 | + if (method_exists($this, $setter)) { |
|
406 | 406 | $this->$setter($data[$key]); |
407 | 407 | } |
408 | 408 | } |
409 | 409 | |
410 | - foreach(['actor', 'object'] as $role) { |
|
411 | - if(isset($data[$role . '_type']) && isset($data[$role . '_id'])) { |
|
412 | - $setter = 'set' . ucfirst($role); |
|
413 | - $this->$setter($data[$role . '_type'], $data[$role . '_id']); |
|
410 | + foreach (['actor', 'object'] as $role) { |
|
411 | + if (isset($data[$role.'_type']) && isset($data[$role.'_id'])) { |
|
412 | + $setter = 'set'.ucfirst($role); |
|
413 | + $this->$setter($data[$role.'_type'], $data[$role.'_id']); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 |