@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | if($value === null) { |
81 | 81 | if(isset(self::$config[$part])) { |
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | if(isset($value[$part])) { |
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -230,15 +230,21 @@ discard block |
||
230 | 230 | |
231 | 231 | // From https://stackoverflow.com/a/173479 |
232 | 232 | $isAssoc = function(array $arr) { |
233 | - if (array() === $arr) return false; |
|
233 | + if (array() === $arr) { |
|
234 | + return false; |
|
235 | + } |
|
234 | 236 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 237 | }; |
236 | 238 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
239 | + if(!is_array($base)) { |
|
240 | + $base = empty($base) ? array() : array($base); |
|
241 | + } |
|
238 | 242 | |
239 | 243 | foreach($arrays as $append) { |
240 | 244 | |
241 | - if(!is_array($append)) $append = array($append); |
|
245 | + if(!is_array($append)) { |
|
246 | + $append = array($append); |
|
247 | + } |
|
242 | 248 | |
243 | 249 | foreach($append as $key => $value) { |
244 | 250 | |
@@ -262,7 +268,9 @@ discard block |
||
262 | 268 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 269 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | 270 | } else if(is_numeric($key)) { |
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
271 | + if(!in_array($value, $base)) { |
|
272 | + $base[] = $value; |
|
273 | + } |
|
266 | 274 | } else { |
267 | 275 | $base[$key] = $value; |
268 | 276 | } |
@@ -78,7 +78,9 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function toDate(): Carbon { |
80 | 80 | $date = $this->first(); |
81 | - if ($date instanceof Carbon) return $date; |
|
81 | + if ($date instanceof Carbon) { |
|
82 | + return $date; |
|
83 | + } |
|
82 | 84 | |
83 | 85 | return Carbon::parse($date); |
84 | 86 | } |
@@ -141,7 +143,7 @@ discard block |
||
141 | 143 | public function add($value, bool $strict = false): Attribute { |
142 | 144 | if (is_array($value)) { |
143 | 145 | return $this->merge($value, $strict); |
144 | - }elseif ($value !== null) { |
|
146 | + } elseif ($value !== null) { |
|
145 | 147 | $this->attach($value, $strict); |
146 | 148 | } |
147 | 149 | |
@@ -188,7 +190,7 @@ discard block |
||
188 | 190 | if ($this->contains($value) === false) { |
189 | 191 | $this->values[] = $value; |
190 | 192 | } |
191 | - }else{ |
|
193 | + } else{ |
|
192 | 194 | $this->values[] = $value; |
193 | 195 | } |
194 | 196 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + } else{ |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
@@ -173,7 +173,9 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function orWhere(Closure $closure = null): WhereQuery { |
175 | 175 | $this->query->push(['OR']); |
176 | - if ($closure !== null) $closure($this); |
|
176 | + if ($closure !== null) { |
|
177 | + $closure($this); |
|
178 | + } |
|
177 | 179 | |
178 | 180 | return $this; |
179 | 181 | } |
@@ -185,7 +187,9 @@ discard block |
||
185 | 187 | */ |
186 | 188 | public function andWhere(Closure $closure = null): WhereQuery { |
187 | 189 | $this->query->push(['AND']); |
188 | - if ($closure !== null) $closure($this); |
|
190 | + if ($closure !== null) { |
|
191 | + $closure($this); |
|
192 | + } |
|
189 | 193 | |
190 | 194 | return $this; |
191 | 195 | } |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | $this->setClient($client); |
92 | 92 | |
93 | 93 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
94 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
94 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
95 | + $this->leaveUnread(); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 99 | $this->fetch_order = 'desc'; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | * @throws MessageSearchValidationException |
138 | 140 | */ |
139 | 141 | protected function parse_date($date): Carbon { |
140 | - if ($date instanceof Carbon) return $date; |
|
142 | + if ($date instanceof Carbon) { |
|
143 | + return $date; |
|
144 | + } |
|
141 | 145 | |
142 | 146 | try { |
143 | 147 | $date = Carbon::parse($date); |
@@ -644,7 +648,9 @@ discard block |
||
644 | 648 | * @return $this |
645 | 649 | */ |
646 | 650 | public function limit(int $limit, int $page = 1): Query { |
647 | - if ($page >= 1) $this->page = $page; |
|
651 | + if ($page >= 1) { |
|
652 | + $this->page = $page; |
|
653 | + } |
|
648 | 654 | $this->limit = $limit; |
649 | 655 | |
650 | 656 | return $this; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | if(strtolower(substr($method, 0, 3)) === 'get') { |
300 | 300 | $name = Str::snake(substr($method, 3)); |
301 | 301 | return $this->get($name); |
302 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
302 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
303 | 303 | $name = Str::snake(substr($method, 3)); |
304 | 304 | |
305 | 305 | if(in_array($name, array_keys($this->attributes))) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | if ($this->getFlags()->get("seen") == null) { |
506 | 506 | $this->unsetFlag("Seen"); |
507 | 507 | } |
508 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
508 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
509 | 509 | $this->setFlag("Seen"); |
510 | 510 | } |
511 | 511 | } |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | private function fetchPart(Part $part) { |
550 | 550 | if ($part->isAttachment()) { |
551 | 551 | $this->fetchAttachment($part); |
552 | - }else{ |
|
552 | + } else{ |
|
553 | 553 | $encoding = $this->getEncoding($part); |
554 | 554 | |
555 | 555 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | |
575 | 575 | if (isset($this->bodies[$subtype])) { |
576 | 576 | $this->bodies[$subtype] .= "\n".$content; |
577 | - }else{ |
|
577 | + } else{ |
|
578 | 578 | $this->bodies[$subtype] = $content; |
579 | 579 | } |
580 | 580 | } |
@@ -745,9 +745,9 @@ discard block |
||
745 | 745 | return EncodingAliases::get($parameter->value, "ISO-8859-2"); |
746 | 746 | } |
747 | 747 | } |
748 | - }elseif (property_exists($structure, 'charset')){ |
|
748 | + } elseif (property_exists($structure, 'charset')){ |
|
749 | 749 | return EncodingAliases::get($structure->charset, "ISO-8859-2"); |
750 | - }elseif (is_string($structure) === true){ |
|
750 | + } elseif (is_string($structure) === true){ |
|
751 | 751 | return mb_detect_encoding($structure); |
752 | 752 | } |
753 | 753 | |
@@ -936,13 +936,15 @@ discard block |
||
936 | 936 | * @throws MessageHeaderFetchingException |
937 | 937 | */ |
938 | 938 | protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message { |
939 | - if($expunge) $this->client->expunge(); |
|
939 | + if($expunge) { |
|
940 | + $this->client->expunge(); |
|
941 | + } |
|
940 | 942 | |
941 | 943 | $this->client->openFolder($folder->path); |
942 | 944 | |
943 | 945 | if ($this->sequence === IMAP::ST_UID) { |
944 | 946 | $sequence_id = $next_uid; |
945 | - }else{ |
|
947 | + } else{ |
|
946 | 948 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
947 | 949 | } |
948 | 950 | |
@@ -976,7 +978,9 @@ discard block |
||
976 | 978 | $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path; |
977 | 979 | $status = $this->move($trash_path); |
978 | 980 | } |
979 | - if($expunge) $this->client->expunge(); |
|
981 | + if($expunge) { |
|
982 | + $this->client->expunge(); |
|
983 | + } |
|
980 | 984 | |
981 | 985 | $event = $this->getEvent("message", "deleted"); |
982 | 986 | $event::dispatch($this); |
@@ -996,7 +1000,9 @@ discard block |
||
996 | 1000 | */ |
997 | 1001 | public function restore(bool $expunge = true): bool { |
998 | 1002 | $status = $this->unsetFlag("Deleted"); |
999 | - if($expunge) $this->client->expunge(); |
|
1003 | + if($expunge) { |
|
1004 | + $this->client->expunge(); |
|
1005 | + } |
|
1000 | 1006 | |
1001 | 1007 | $event = $this->getEvent("message", "restored"); |
1002 | 1008 | $event::dispatch($this); |
@@ -1424,7 +1430,7 @@ discard block |
||
1424 | 1430 | if ($this->getSequence() === IMAP::ST_UID) { |
1425 | 1431 | $this->setUid($uid); |
1426 | 1432 | $this->setMsglist($msglist); |
1427 | - }else{ |
|
1433 | + } else{ |
|
1428 | 1434 | $this->setMsgn($uid, $msglist); |
1429 | 1435 | } |
1430 | 1436 | } |
@@ -240,7 +240,9 @@ discard block |
||
240 | 240 | public function move(string $new_name, bool $expunge = true): bool { |
241 | 241 | $this->client->checkConnection(); |
242 | 242 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
243 | - if($expunge) $this->client->expunge(); |
|
243 | + if($expunge) { |
|
244 | + $this->client->expunge(); |
|
245 | + } |
|
244 | 246 | |
245 | 247 | $folder = $this->client->getFolder($new_name); |
246 | 248 | $event = $this->getEvent("folder", "moved"); |
@@ -316,7 +318,9 @@ discard block |
||
316 | 318 | */ |
317 | 319 | public function delete(bool $expunge = true): bool { |
318 | 320 | $status = $this->client->getConnection()->deleteFolder($this->path); |
319 | - if($expunge) $this->client->expunge(); |
|
321 | + if($expunge) { |
|
322 | + $this->client->expunge(); |
|
323 | + } |
|
320 | 324 | |
321 | 325 | $event = $this->getEvent("folder", "deleted"); |
322 | 326 | $event::dispatch($this); |
@@ -395,7 +399,7 @@ discard block |
||
395 | 399 | $connection->done(); |
396 | 400 | $connection->idle(); |
397 | 401 | } |
398 | - }catch (Exceptions\RuntimeException $e) { |
|
402 | + } catch (Exceptions\RuntimeException $e) { |
|
399 | 403 | if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) { |
400 | 404 | $connection->done(); |
401 | 405 | $connection->idle(); |
@@ -111,7 +111,9 @@ discard block |
||
111 | 111 | if ($line === "" && $next_char === false) { |
112 | 112 | throw new RuntimeException('empty response'); |
113 | 113 | } |
114 | - if ($this->debug) echo "<< ".$line."\n"; |
|
114 | + if ($this->debug) { |
|
115 | + echo "<< ".$line."\n"; |
|
116 | + } |
|
115 | 117 | return $line . "\n"; |
116 | 118 | } |
117 | 119 | |
@@ -325,7 +327,9 @@ discard block |
||
325 | 327 | * @throws RuntimeException |
326 | 328 | */ |
327 | 329 | public function write(string $data) { |
328 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
330 | + if ($this->debug) { |
|
331 | + echo ">> ".$data ."\n"; |
|
332 | + } |
|
329 | 333 | |
330 | 334 | if (fwrite($this->stream, $data . "\r\n") === false) { |
331 | 335 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -477,7 +481,9 @@ discard block |
||
477 | 481 | public function getCapabilities(): array { |
478 | 482 | $response = $this->requestAndResponse('CAPABILITY'); |
479 | 483 | |
480 | - if (!$response) return []; |
|
484 | + if (!$response) { |
|
485 | + return []; |
|
486 | + } |
|
481 | 487 | |
482 | 488 | $capabilities = []; |
483 | 489 | foreach ($response as $line) { |
@@ -644,13 +650,14 @@ discard block |
||
644 | 650 | // if we want only one message we can ignore everything else and just return |
645 | 651 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
646 | 652 | // we still need to read all lines |
647 | - while (!$this->readLine($tokens, $tag)) |
|
648 | - |
|
653 | + while (!$this->readLine($tokens, $tag)) { |
|
654 | + |
|
649 | 655 | return $data; |
656 | + } |
|
650 | 657 | } |
651 | 658 | if ($uid) { |
652 | 659 | $result[$tokens[2][$uidKey]] = $data; |
653 | - }else{ |
|
660 | + } else{ |
|
654 | 661 | $result[$tokens[0]] = $data; |
655 | 662 | } |
656 | 663 | } |
@@ -1080,7 +1087,9 @@ discard block |
||
1080 | 1087 | public function search(array $params, $uid = IMAP::ST_UID): array { |
1081 | 1088 | $command = $this->buildUIDCommand("SEARCH", $uid); |
1082 | 1089 | $response = $this->requestAndResponse($command, $params); |
1083 | - if (!$response) return []; |
|
1090 | + if (!$response) { |
|
1091 | + return []; |
|
1092 | + } |
|
1084 | 1093 | |
1085 | 1094 | foreach ($response as $ids) { |
1086 | 1095 | if ($ids[0] == 'SEARCH') { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $value = $this->default_account_config[$key]; |
215 | 215 | if(isset($config[$key])) { |
216 | 216 | $value = $config[$key]; |
217 | - }elseif(isset($default_config[$key])) { |
|
217 | + } elseif(isset($default_config[$key])) { |
|
218 | 218 | $value = $default_config[$key]; |
219 | 219 | } |
220 | 220 | $this->$key = $value; |
@@ -246,39 +246,39 @@ discard block |
||
246 | 246 | if(isset($config['masks']['message'])) { |
247 | 247 | if(class_exists($config['masks']['message'])) { |
248 | 248 | $this->default_message_mask = $config['masks']['message']; |
249 | - }else{ |
|
249 | + } else{ |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
251 | 251 | } |
252 | - }else{ |
|
252 | + } else{ |
|
253 | 253 | if(class_exists($default_config['message'])) { |
254 | 254 | $this->default_message_mask = $default_config['message']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | if(isset($config['masks']['attachment'])) { |
260 | 260 | if(class_exists($config['masks']['attachment'])) { |
261 | 261 | $this->default_attachment_mask = $config['masks']['attachment']; |
262 | - }else{ |
|
262 | + } else{ |
|
263 | 263 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['attachment'])) { |
267 | 267 | $this->default_attachment_mask = $default_config['attachment']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
270 | 270 | } |
271 | 271 | } |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | if(class_exists($default_config['message'])) { |
274 | 274 | $this->default_message_mask = $default_config['message']; |
275 | - }else{ |
|
275 | + } else{ |
|
276 | 276 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
277 | 277 | } |
278 | 278 | |
279 | 279 | if(class_exists($default_config['attachment'])) { |
280 | 280 | $this->default_attachment_mask = $default_config['attachment']; |
281 | - }else{ |
|
281 | + } else{ |
|
282 | 282 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
283 | 283 | } |
284 | 284 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
343 | 343 | $this->connection->setConnectionTimeout($this->timeout); |
344 | 344 | $this->connection->setProxy($this->proxy); |
345 | - }else{ |
|
345 | + } else{ |
|
346 | 346 | if (extension_loaded('imap') === false) { |
347 | 347 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
348 | 348 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | return $folders; |
493 | - }else{ |
|
493 | + } else{ |
|
494 | 494 | throw new FolderFetchingException("failed to fetch any folders"); |
495 | 495 | } |
496 | 496 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | return $folders; |
533 | - }else{ |
|
533 | + } else{ |
|
534 | 534 | throw new FolderFetchingException("failed to fetch any folders"); |
535 | 535 | } |
536 | 536 | } |
@@ -568,7 +568,9 @@ discard block |
||
568 | 568 | $this->checkConnection(); |
569 | 569 | $status = $this->connection->createFolder($folder); |
570 | 570 | |
571 | - if($expunge) $this->expunge(); |
|
571 | + if($expunge) { |
|
572 | + $this->expunge(); |
|
573 | + } |
|
572 | 574 | |
573 | 575 | $folder = $this->getFolder($folder); |
574 | 576 | if($status && $folder) { |