@@ -238,7 +238,9 @@ discard block |
||
| 238 | 238 | } else { |
| 239 | 239 | $tokens = $line; |
| 240 | 240 | } |
| 241 | - if ($this->debug) echo "<< ".$line."\n"; |
|
| 241 | + if ($this->debug) { |
|
| 242 | + echo "<< ".$line."\n"; |
|
| 243 | + } |
|
| 242 | 244 | |
| 243 | 245 | // if tag is wanted tag we might be at the end of a multiline response |
| 244 | 246 | return $tag == $wantedTag; |
@@ -304,7 +306,9 @@ discard block |
||
| 304 | 306 | $line .= ' ' . $token; |
| 305 | 307 | } |
| 306 | 308 | } |
| 307 | - if ($this->debug) echo ">> ".$line."\n"; |
|
| 309 | + if ($this->debug) { |
|
| 310 | + echo ">> ".$line."\n"; |
|
| 311 | + } |
|
| 308 | 312 | |
| 309 | 313 | if (fwrite($this->stream, $line . "\r\n") === false) { |
| 310 | 314 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -456,7 +460,9 @@ discard block |
||
| 456 | 460 | public function getCapabilities(): array { |
| 457 | 461 | $response = $this->requestAndResponse('CAPABILITY'); |
| 458 | 462 | |
| 459 | - if (!$response) return []; |
|
| 463 | + if (!$response) { |
|
| 464 | + return []; |
|
| 465 | + } |
|
| 460 | 466 | |
| 461 | 467 | $capabilities = []; |
| 462 | 468 | foreach ($response as $line) { |
@@ -616,13 +622,14 @@ discard block |
||
| 616 | 622 | // if we want only one message we can ignore everything else and just return |
| 617 | 623 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 618 | 624 | // we still need to read all lines |
| 619 | - while (!$this->readLine($tokens, $tag)) |
|
| 620 | - |
|
| 625 | + while (!$this->readLine($tokens, $tag)) { |
|
| 626 | + |
|
| 621 | 627 | return $data; |
| 628 | + } |
|
| 622 | 629 | } |
| 623 | 630 | if ($uid) { |
| 624 | 631 | $result[$tokens[2][$uidKey]] = $data; |
| 625 | - }else{ |
|
| 632 | + } else{ |
|
| 626 | 633 | $result[$tokens[0]] = $data; |
| 627 | 634 | } |
| 628 | 635 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @throws ConnectionFailedException |
| 90 | 90 | * @throws RuntimeException |
| 91 | 91 | */ |
| 92 | - protected function enableStartTls(){ |
|
| 92 | + protected function enableStartTls() { |
|
| 93 | 93 | $response = $this->requestAndResponse('STARTTLS'); |
| 94 | 94 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
| 95 | 95 | if (!$result) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $stack = []; |
| 152 | 152 | |
| 153 | 153 | // replace any trailing <NL> including spaces with a single space |
| 154 | - $line = rtrim($line) . ' '; |
|
| 154 | + $line = rtrim($line).' '; |
|
| 155 | 155 | while (($pos = strpos($line, ' ')) !== false) { |
| 156 | 156 | $token = substr($line, 0, $pos); |
| 157 | 157 | if (!strlen($token)) { |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | if (strlen($token) > $chars) { |
| 182 | 182 | $line = substr($token, $chars); |
| 183 | 183 | $token = substr($token, 0, $chars); |
| 184 | - } else { |
|
| 184 | + }else { |
|
| 185 | 185 | $line .= $this->nextLine(); |
| 186 | 186 | } |
| 187 | 187 | $tokens[] = $token; |
| 188 | - $line = trim($line) . ' '; |
|
| 188 | + $line = trim($line).' '; |
|
| 189 | 189 | continue; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | $line = $this->nextTaggedLine($tag); // get next tag |
| 236 | 236 | if (!$dontParse) { |
| 237 | 237 | $tokens = $this->decodeLine($line); |
| 238 | - } else { |
|
| 238 | + }else { |
|
| 239 | 239 | $tokens = $line; |
| 240 | 240 | } |
| 241 | 241 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -286,27 +286,27 @@ discard block |
||
| 286 | 286 | public function sendRequest(string $command, array $tokens = [], string &$tag = null) { |
| 287 | 287 | if (!$tag) { |
| 288 | 288 | $this->noun++; |
| 289 | - $tag = 'TAG' . $this->noun; |
|
| 289 | + $tag = 'TAG'.$this->noun; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $line = $tag . ' ' . $command; |
|
| 292 | + $line = $tag.' '.$command; |
|
| 293 | 293 | |
| 294 | 294 | foreach ($tokens as $token) { |
| 295 | 295 | if (is_array($token)) { |
| 296 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
| 296 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
| 297 | 297 | throw new RuntimeException('failed to write - connection closed?'); |
| 298 | 298 | } |
| 299 | 299 | if (!$this->assumedNextLine('+ ')) { |
| 300 | 300 | throw new RuntimeException('failed to send literal string'); |
| 301 | 301 | } |
| 302 | 302 | $line = $token[1]; |
| 303 | - } else { |
|
| 304 | - $line .= ' ' . $token; |
|
| 303 | + }else { |
|
| 304 | + $line .= ' '.$token; |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | if ($this->debug) echo ">> ".$line."\n"; |
| 308 | 308 | |
| 309 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
| 309 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
| 310 | 310 | throw new RuntimeException('failed to write - connection closed?'); |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -336,9 +336,9 @@ discard block |
||
| 336 | 336 | public function escapeString($string) { |
| 337 | 337 | if (func_num_args() < 2) { |
| 338 | 338 | if (strpos($string, "\n") !== false) { |
| 339 | - return ['{' . strlen($string) . '}', $string]; |
|
| 340 | - } else { |
|
| 341 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
| 339 | + return ['{'.strlen($string).'}', $string]; |
|
| 340 | + }else { |
|
| 341 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
| 342 | 342 | } |
| 343 | 343 | } |
| 344 | 344 | $result = []; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | $result[] = $this->escapeList($v); |
| 365 | 365 | } |
| 366 | - return '(' . implode(' ', $result) . ')'; |
|
| 366 | + return '('.implode(' ', $result).')'; |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | error_log("got an extra server challenge: $response"); |
| 405 | 405 | // respond with an empty response. |
| 406 | 406 | $this->sendRequest(''); |
| 407 | - } else { |
|
| 407 | + }else { |
|
| 408 | 408 | if (preg_match('/^NO /i', $response) || |
| 409 | 409 | preg_match('/^BAD /i', $response)) { |
| 410 | 410 | error_log("got failure response: $response"); |
| 411 | 411 | return false; |
| 412 | - } else if (preg_match("/^OK /i", $response)) { |
|
| 412 | + }else if (preg_match("/^OK /i", $response)) { |
|
| 413 | 413 | return true; |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -490,10 +490,10 @@ discard block |
||
| 490 | 490 | $result[strtolower($tokens[1])] = $tokens[0]; |
| 491 | 491 | break; |
| 492 | 492 | case '[UIDVALIDITY': |
| 493 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
| 493 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
| 494 | 494 | break; |
| 495 | 495 | case '[UIDNEXT': |
| 496 | - $result['uidnext'] = (int)$tokens[2]; |
|
| 496 | + $result['uidnext'] = (int) $tokens[2]; |
|
| 497 | 497 | break; |
| 498 | 498 | default: |
| 499 | 499 | // ignore |
@@ -550,14 +550,14 @@ discard block |
||
| 550 | 550 | if (is_array($from)) { |
| 551 | 551 | $set = implode(',', $from); |
| 552 | 552 | } elseif ($to === null) { |
| 553 | - $set = (int)$from; |
|
| 553 | + $set = (int) $from; |
|
| 554 | 554 | } elseif ($to === INF) { |
| 555 | - $set = (int)$from . ':*'; |
|
| 556 | - } else { |
|
| 557 | - $set = (int)$from . ':' . (int)$to; |
|
| 555 | + $set = (int) $from.':*'; |
|
| 556 | + }else { |
|
| 557 | + $set = (int) $from.':'.(int) $to; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $items = (array)$items; |
|
| 560 | + $items = (array) $items; |
|
| 561 | 561 | $itemList = $this->escapeList($items); |
| 562 | 562 | |
| 563 | 563 | $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag); |
@@ -574,9 +574,9 @@ discard block |
||
| 574 | 574 | $count = count($tokens[2]); |
| 575 | 575 | if ($tokens[2][$count - 2] == 'UID') { |
| 576 | 576 | $uidKey = $count - 1; |
| 577 | - } else if ($tokens[2][0] == 'UID') { |
|
| 577 | + }else if ($tokens[2][0] == 'UID') { |
|
| 578 | 578 | $uidKey = 1; |
| 579 | - } else { |
|
| 579 | + }else { |
|
| 580 | 580 | $uidKey = array_search('UID', $tokens[2]) + 1; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | $data = $tokens[2][1]; |
| 593 | 593 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
| 594 | 594 | $data = $tokens[2][3]; |
| 595 | - } else { |
|
| 595 | + }else { |
|
| 596 | 596 | $expectedResponse = 0; |
| 597 | 597 | // maybe the server send an other field we didn't wanted |
| 598 | 598 | $count = count($tokens[2]); |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | continue; |
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | - } else { |
|
| 612 | + }else { |
|
| 613 | 613 | $data = []; |
| 614 | 614 | while (key($tokens[2]) !== null) { |
| 615 | 615 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | } |
| 627 | 627 | if ($uid) { |
| 628 | 628 | $result[$tokens[2][$uidKey]] = $data; |
| 629 | - }else{ |
|
| 629 | + }else { |
|
| 630 | 630 | $result[$tokens[0]] = $data; |
| 631 | 631 | } |
| 632 | 632 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | |
| 692 | 692 | if ($this->enable_uid_cache && $this->uid_cache) { |
| 693 | 693 | $uids = $this->uid_cache; |
| 694 | - } else { |
|
| 694 | + }else { |
|
| 695 | 695 | try { |
| 696 | 696 | $uids = $this->fetch('UID', 1, INF); |
| 697 | 697 | $this->setUidCache($uids); // set cache for this folder |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
| 786 | 786 | |
| 787 | 787 | if ($silent) { |
| 788 | - return (bool)$response; |
|
| 788 | + return (bool) $response; |
|
| 789 | 789 | } |
| 790 | 790 | |
| 791 | 791 | $result = []; |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | $ids = []; |
| 1087 | 1087 | foreach ($uids as $msgn => $v) { |
| 1088 | 1088 | $id = $uid ? $v : $msgn; |
| 1089 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
| 1089 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
| 1090 | 1090 | $ids[] = $id; |
| 1091 | 1091 | } |
| 1092 | 1092 | } |
@@ -1100,14 +1100,14 @@ discard block |
||
| 1100 | 1100 | /** |
| 1101 | 1101 | * Enable the debug mode |
| 1102 | 1102 | */ |
| 1103 | - public function enableDebug(){ |
|
| 1103 | + public function enableDebug() { |
|
| 1104 | 1104 | $this->debug = true; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | /** |
| 1108 | 1108 | * Disable the debug mode |
| 1109 | 1109 | */ |
| 1110 | - public function disableDebug(){ |
|
| 1110 | + public function disableDebug() { |
|
| 1111 | 1111 | $this->debug = false; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1119,9 +1119,9 @@ discard block |
||
| 1119 | 1119 | * @return int|string |
| 1120 | 1120 | */ |
| 1121 | 1121 | public function buildSet($from, $to = null) { |
| 1122 | - $set = (int)$from; |
|
| 1122 | + $set = (int) $from; |
|
| 1123 | 1123 | if ($to !== null) { |
| 1124 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
| 1124 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | return $set; |
| 1127 | 1127 | } |
@@ -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 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | $this->boot(); |
| 192 | 192 | |
| 193 | 193 | $default_mask = $client->getDefaultMessageMask(); |
| 194 | - if($default_mask != null) { |
|
| 194 | + if ($default_mask != null) { |
|
| 195 | 195 | $this->mask = $default_mask; |
| 196 | 196 | } |
| 197 | 197 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $instance->boot(); |
| 253 | 253 | |
| 254 | 254 | $default_mask = $client->getDefaultMessageMask(); |
| 255 | - if($default_mask != null) { |
|
| 255 | + if ($default_mask != null) { |
|
| 256 | 256 | $instance->setMask($default_mask); |
| 257 | 257 | } |
| 258 | 258 | $instance->setEvents([ |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | /** |
| 278 | 278 | * Boot a new instance |
| 279 | 279 | */ |
| 280 | - public function boot(){ |
|
| 280 | + public function boot() { |
|
| 281 | 281 | $this->attributes = []; |
| 282 | 282 | |
| 283 | 283 | $this->config = ClientManager::get('options'); |
@@ -296,13 +296,13 @@ discard block |
||
| 296 | 296 | * @throws MethodNotFoundException |
| 297 | 297 | */ |
| 298 | 298 | public function __call(string $method, array $arguments) { |
| 299 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 299 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 300 | 300 | $name = Str::snake(substr($method, 3)); |
| 301 | 301 | return $this->get($name); |
| 302 | 302 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 303 | 303 | $name = Str::snake(substr($method, 3)); |
| 304 | 304 | |
| 305 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 305 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 306 | 306 | return $this->__set($name, array_pop($arguments)); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | * @return Attribute|mixed|null |
| 342 | 342 | */ |
| 343 | 343 | public function get($name) { |
| 344 | - if(isset($this->attributes[$name])) { |
|
| 344 | + if (isset($this->attributes[$name])) { |
|
| 345 | 345 | return $this->attributes[$name]; |
| 346 | 346 | } |
| 347 | 347 | |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | * |
| 416 | 416 | * @throws InvalidMessageDateException |
| 417 | 417 | */ |
| 418 | - public function parseRawHeader(string $raw_header){ |
|
| 418 | + public function parseRawHeader(string $raw_header) { |
|
| 419 | 419 | $this->header = new Header($raw_header); |
| 420 | 420 | } |
| 421 | 421 | |
@@ -426,8 +426,8 @@ discard block |
||
| 426 | 426 | public function parseRawFlags(array $raw_flags) { |
| 427 | 427 | $this->flags = FlagCollection::make([]); |
| 428 | 428 | |
| 429 | - foreach($raw_flags as $flag) { |
|
| 430 | - if (strpos($flag, "\\") === 0){ |
|
| 429 | + foreach ($raw_flags as $flag) { |
|
| 430 | + if (strpos($flag, "\\") === 0) { |
|
| 431 | 431 | $flag = substr($flag, 1); |
| 432 | 432 | } |
| 433 | 433 | $flag_key = strtolower($flag); |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * @throws MessageFlagException |
| 501 | 501 | * @throws Exceptions\RuntimeException |
| 502 | 502 | */ |
| 503 | - public function peek(){ |
|
| 503 | + public function peek() { |
|
| 504 | 504 | if ($this->fetch_options == IMAP::FT_PEEK) { |
| 505 | 505 | if ($this->getFlags()->get("seen") == null) { |
| 506 | 506 | $this->unsetFlag("Seen"); |
@@ -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 | } |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
| 591 | 591 | if ($oAttachment->getId() !== null) { |
| 592 | 592 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
| 593 | - } else { |
|
| 593 | + }else { |
|
| 594 | 594 | $this->attachments->push($oAttachment); |
| 595 | 595 | } |
| 596 | 596 | } |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 726 | 726 | return @iconv($from, $to.'//IGNORE', $str); |
| 727 | - } else { |
|
| 727 | + }else { |
|
| 728 | 728 | if (!$from) { |
| 729 | 729 | return mb_convert_encoding($str, $to); |
| 730 | 730 | } |
@@ -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 | |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | * @throws Exceptions\FolderFetchingException |
| 763 | 763 | * @throws Exceptions\RuntimeException |
| 764 | 764 | */ |
| 765 | - public function getFolder(){ |
|
| 765 | + public function getFolder() { |
|
| 766 | 766 | return $this->client->getFolderByPath($this->folder_path); |
| 767 | 767 | } |
| 768 | 768 | |
@@ -778,13 +778,13 @@ discard block |
||
| 778 | 778 | * @throws Exceptions\GetMessagesFailedException |
| 779 | 779 | * @throws Exceptions\RuntimeException |
| 780 | 780 | */ |
| 781 | - public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection { |
|
| 781 | + public function thread(Folder $sent_folder = null, MessageCollection & $thread = null, Folder $folder = null): MessageCollection { |
|
| 782 | 782 | $thread = $thread ?: MessageCollection::make([]); |
| 783 | - $folder = $folder ?: $this->getFolder(); |
|
| 783 | + $folder = $folder ?: $this->getFolder(); |
|
| 784 | 784 | $sent_folder = $sent_folder ?: $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
| 785 | 785 | |
| 786 | 786 | /** @var Message $message */ |
| 787 | - foreach($thread as $message) { |
|
| 787 | + foreach ($thread as $message) { |
|
| 788 | 788 | if ($message->message_id->first() == $this->message_id->first()) { |
| 789 | 789 | return $thread; |
| 790 | 790 | } |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
| 796 | 796 | |
| 797 | 797 | if (is_array($this->in_reply_to)) { |
| 798 | - foreach($this->in_reply_to as $in_reply_to) { |
|
| 798 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
| 799 | 799 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
| 800 | 800 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
| 801 | 801 | } |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | * @throws Exceptions\RuntimeException |
| 818 | 818 | * @throws Exceptions\FolderFetchingException |
| 819 | 819 | */ |
| 820 | - protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){ |
|
| 820 | + protected function fetchThreadByInReplyTo(MessageCollection & $thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) { |
|
| 821 | 821 | $primary_folder->query()->inReplyTo($in_reply_to) |
| 822 | 822 | ->setFetchBody($this->getFetchBodyOption()) |
| 823 | 823 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -839,7 +839,7 @@ discard block |
||
| 839 | 839 | * @throws Exceptions\RuntimeException |
| 840 | 840 | * @throws Exceptions\FolderFetchingException |
| 841 | 841 | */ |
| 842 | - protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){ |
|
| 842 | + protected function fetchThreadByMessageId(MessageCollection & $thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) { |
|
| 843 | 843 | $primary_folder->query()->messageId($message_id) |
| 844 | 844 | ->setFetchBody($this->getFetchBodyOption()) |
| 845 | 845 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -936,13 +936,13 @@ 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) $this->client->expunge(); |
|
| 940 | 940 | |
| 941 | 941 | $this->client->openFolder($folder->path); |
| 942 | 942 | |
| 943 | 943 | if ($this->sequence === IMAP::ST_UID) { |
| 944 | 944 | $sequence_id = $next_uid; |
| 945 | - }else{ |
|
| 945 | + }else { |
|
| 946 | 946 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
| 947 | 947 | } |
| 948 | 948 | |
@@ -972,11 +972,11 @@ discard block |
||
| 972 | 972 | */ |
| 973 | 973 | public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false) { |
| 974 | 974 | $status = $this->setFlag("Deleted"); |
| 975 | - if($force_move) { |
|
| 976 | - $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path; |
|
| 975 | + if ($force_move) { |
|
| 976 | + $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"] : $trash_path; |
|
| 977 | 977 | $status = $this->move($trash_path); |
| 978 | 978 | } |
| 979 | - if($expunge) $this->client->expunge(); |
|
| 979 | + if ($expunge) $this->client->expunge(); |
|
| 980 | 980 | |
| 981 | 981 | $event = $this->getEvent("message", "deleted"); |
| 982 | 982 | $event::dispatch($this); |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | */ |
| 997 | 997 | public function restore(bool $expunge = true): bool { |
| 998 | 998 | $status = $this->unsetFlag("Deleted"); |
| 999 | - if($expunge) $this->client->expunge(); |
|
| 999 | + if ($expunge) $this->client->expunge(); |
|
| 1000 | 1000 | |
| 1001 | 1001 | $event = $this->getEvent("message", "restored"); |
| 1002 | 1002 | $event::dispatch($this); |
@@ -1208,7 +1208,7 @@ discard block |
||
| 1208 | 1208 | * |
| 1209 | 1209 | * @return Structure|null |
| 1210 | 1210 | */ |
| 1211 | - public function getStructure(){ |
|
| 1211 | + public function getStructure() { |
|
| 1212 | 1212 | return $this->structure; |
| 1213 | 1213 | } |
| 1214 | 1214 | |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | * @return $this |
| 1246 | 1246 | */ |
| 1247 | 1247 | public function setMask($mask): Message { |
| 1248 | - if(class_exists($mask)){ |
|
| 1248 | + if (class_exists($mask)) { |
|
| 1249 | 1249 | $this->mask = $mask; |
| 1250 | 1250 | } |
| 1251 | 1251 | |
@@ -1268,9 +1268,9 @@ discard block |
||
| 1268 | 1268 | * @return mixed |
| 1269 | 1269 | * @throws MaskNotFoundException |
| 1270 | 1270 | */ |
| 1271 | - public function mask($mask = null){ |
|
| 1271 | + public function mask($mask = null) { |
|
| 1272 | 1272 | $mask = $mask !== null ? $mask : $this->mask; |
| 1273 | - if(class_exists($mask)){ |
|
| 1273 | + if (class_exists($mask)) { |
|
| 1274 | 1274 | return new $mask($this); |
| 1275 | 1275 | } |
| 1276 | 1276 | |
@@ -1420,11 +1420,11 @@ discard block |
||
| 1420 | 1420 | * @throws Exceptions\ConnectionFailedException |
| 1421 | 1421 | * @throws Exceptions\MessageNotFoundException |
| 1422 | 1422 | */ |
| 1423 | - public function setSequenceId($uid, int $msglist = null){ |
|
| 1423 | + public function setSequenceId($uid, int $msglist = null) { |
|
| 1424 | 1424 | if ($this->getSequence() === IMAP::ST_UID) { |
| 1425 | 1425 | $this->setUid($uid); |
| 1426 | 1426 | $this->setMsglist($msglist); |
| 1427 | - }else{ |
|
| 1427 | + }else { |
|
| 1428 | 1428 | $this->setMsgn($uid, $msglist); |
| 1429 | 1429 | } |
| 1430 | 1430 | } |