@@ -285,7 +285,9 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | foreach ($headers as $key => $values) { |
| 288 | - if (isset($imap_headers[$key])) continue; |
|
| 288 | + if (isset($imap_headers[$key])) { |
|
| 289 | + continue; |
|
| 290 | + } |
|
| 289 | 291 | $value = null; |
| 290 | 292 | switch ($key) { |
| 291 | 293 | case 'from': |
@@ -506,7 +508,9 @@ discard block |
||
| 506 | 508 | * Try to extract the priority from a given raw header string |
| 507 | 509 | */ |
| 508 | 510 | private function findPriority() { |
| 509 | - if (($priority = $this->get("x_priority")) === null) return; |
|
| 511 | + if (($priority = $this->get("x_priority")) === null) { |
|
| 512 | + return; |
|
| 513 | + } |
|
| 510 | 514 | switch ((int)"$priority") { |
| 511 | 515 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 512 | 516 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -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 === "") { |
| 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 | |
@@ -326,7 +328,9 @@ discard block |
||
| 326 | 328 | * @throws RuntimeException |
| 327 | 329 | */ |
| 328 | 330 | public function write(string $data) { |
| 329 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
| 331 | + if ($this->debug) { |
|
| 332 | + echo ">> ".$data ."\n"; |
|
| 333 | + } |
|
| 330 | 334 | |
| 331 | 335 | if (fwrite($this->stream, $data . "\r\n") === false) { |
| 332 | 336 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -478,7 +482,9 @@ discard block |
||
| 478 | 482 | public function getCapabilities(): array { |
| 479 | 483 | $response = $this->requestAndResponse('CAPABILITY'); |
| 480 | 484 | |
| 481 | - if (!$response) return []; |
|
| 485 | + if (!$response) { |
|
| 486 | + return []; |
|
| 487 | + } |
|
| 482 | 488 | |
| 483 | 489 | $capabilities = []; |
| 484 | 490 | foreach ($response as $line) { |
@@ -638,13 +644,14 @@ discard block |
||
| 638 | 644 | // if we want only one message we can ignore everything else and just return |
| 639 | 645 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 640 | 646 | // we still need to read all lines |
| 641 | - while (!$this->readLine($tokens, $tag)) |
|
| 642 | - |
|
| 647 | + while (!$this->readLine($tokens, $tag)) { |
|
| 648 | + |
|
| 643 | 649 | return $data; |
| 650 | + } |
|
| 644 | 651 | } |
| 645 | 652 | if ($uid) { |
| 646 | 653 | $result[$tokens[2][$uidKey]] = $data; |
| 647 | - }else{ |
|
| 654 | + } else{ |
|
| 648 | 655 | $result[$tokens[0]] = $data; |
| 649 | 656 | } |
| 650 | 657 | } |