@@ -233,7 +233,7 @@ |
||
| 233 | 233 | return "UID"; |
| 234 | 234 | } |
| 235 | 235 | if (strlen($uid) > 0 && !is_numeric($uid)) { |
| 236 | - return (string)$uid; |
|
| 236 | + return (string) $uid; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return ""; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @throws ConnectionFailedException |
| 90 | 90 | * @throws RuntimeException |
| 91 | 91 | */ |
| 92 | - protected function enableTls(){ |
|
| 92 | + protected function enableTls() { |
|
| 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($command, $tokens = [], &$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 | /** |
@@ -403,12 +403,12 @@ discard block |
||
| 403 | 403 | error_log("got an extra server challenge: $response"); |
| 404 | 404 | // respond with an empty response. |
| 405 | 405 | $this->sendRequest(''); |
| 406 | - } else { |
|
| 406 | + }else { |
|
| 407 | 407 | if (preg_match('/^NO /i', $response) || |
| 408 | 408 | preg_match('/^BAD /i', $response)) { |
| 409 | 409 | error_log("got failure response: $response"); |
| 410 | 410 | return false; |
| 411 | - } else if (preg_match("/^OK /i", $response)) { |
|
| 411 | + }else if (preg_match("/^OK /i", $response)) { |
|
| 412 | 412 | return true; |
| 413 | 413 | } |
| 414 | 414 | } |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | * |
| 442 | 442 | * @return bool |
| 443 | 443 | */ |
| 444 | - public function connected(){ |
|
| 444 | + public function connected() { |
|
| 445 | 445 | return (boolean) $this->stream; |
| 446 | 446 | } |
| 447 | 447 | |
@@ -488,10 +488,10 @@ discard block |
||
| 488 | 488 | $result[strtolower($tokens[1])] = $tokens[0]; |
| 489 | 489 | break; |
| 490 | 490 | case '[UIDVALIDITY': |
| 491 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
| 491 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
| 492 | 492 | break; |
| 493 | 493 | case '[UIDNEXT': |
| 494 | - $result['uidnext'] = (int)$tokens[2]; |
|
| 494 | + $result['uidnext'] = (int) $tokens[2]; |
|
| 495 | 495 | break; |
| 496 | 496 | default: |
| 497 | 497 | // ignore |
@@ -546,17 +546,17 @@ discard block |
||
| 546 | 546 | if (is_array($from)) { |
| 547 | 547 | $set = implode(',', $from); |
| 548 | 548 | } elseif ($to === null) { |
| 549 | - $set = (int)$from; |
|
| 549 | + $set = (int) $from; |
|
| 550 | 550 | } elseif ($to === INF) { |
| 551 | - $set = (int)$from . ':*'; |
|
| 552 | - } else { |
|
| 553 | - $set = (int)$from . ':' . (int)$to; |
|
| 551 | + $set = (int) $from.':*'; |
|
| 552 | + }else { |
|
| 553 | + $set = (int) $from.':'.(int) $to; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | - $items = (array)$items; |
|
| 556 | + $items = (array) $items; |
|
| 557 | 557 | $itemList = $this->escapeList($items); |
| 558 | 558 | |
| 559 | - $this->sendRequest(trim($this->getUIDKey($uid) . ' FETCH'), [$set, $itemList], $tag); |
|
| 559 | + $this->sendRequest(trim($this->getUIDKey($uid).' FETCH'), [$set, $itemList], $tag); |
|
| 560 | 560 | $result = []; |
| 561 | 561 | $tokens = null; // define $tokens variable before first use |
| 562 | 562 | while (!$this->readLine($tokens, $tag)) { |
@@ -570,9 +570,9 @@ discard block |
||
| 570 | 570 | $count = count($tokens[2]); |
| 571 | 571 | if ($tokens[2][$count - 2] == 'UID') { |
| 572 | 572 | $uidKey = $count - 1; |
| 573 | - } else if ($tokens[2][0] == 'UID') { |
|
| 573 | + }else if ($tokens[2][0] == 'UID') { |
|
| 574 | 574 | $uidKey = 1; |
| 575 | - } else { |
|
| 575 | + }else { |
|
| 576 | 576 | $uidKey = array_search('UID', $tokens[2]) + 1; |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | $data = $tokens[2][1]; |
| 589 | 589 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
| 590 | 590 | $data = $tokens[2][3]; |
| 591 | - } else { |
|
| 591 | + }else { |
|
| 592 | 592 | // maybe the server send an other field we didn't wanted |
| 593 | 593 | $count = count($tokens[2]); |
| 594 | 594 | // we start with 2, because 0 was already checked |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | break; |
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | - } else { |
|
| 603 | + }else { |
|
| 604 | 604 | $data = []; |
| 605 | 605 | while (key($tokens[2]) !== null) { |
| 606 | 606 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | } |
| 618 | 618 | if ($uid) { |
| 619 | 619 | $result[$tokens[2][$uidKey]] = $data; |
| 620 | - }else{ |
|
| 620 | + }else { |
|
| 621 | 621 | $result[$tokens[0]] = $data; |
| 622 | 622 | } |
| 623 | 623 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | * @return array |
| 654 | 654 | * @throws RuntimeException |
| 655 | 655 | */ |
| 656 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
| 656 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
| 657 | 657 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
| 658 | 658 | } |
| 659 | 659 | |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | * @return array |
| 667 | 667 | * @throws RuntimeException |
| 668 | 668 | */ |
| 669 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
| 669 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
| 670 | 670 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
| 671 | 671 | } |
| 672 | 672 | |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | $item = 'FLAGS'; |
| 758 | 758 | } |
| 759 | 759 | if ($mode == '+' || $mode == '-') { |
| 760 | - $item = $mode . $item; |
|
| 760 | + $item = $mode.$item; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | if ($silent) { |
@@ -765,16 +765,16 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | $flags = $this->escapeList($flags); |
| 768 | - $set = (int)$from; |
|
| 768 | + $set = (int) $from; |
|
| 769 | 769 | if ($to !== null) { |
| 770 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
| 770 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | $command = ($uid ? "UID " : "")."STORE"; |
| 774 | 774 | $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
| 775 | 775 | |
| 776 | 776 | if ($silent) { |
| 777 | - return (bool)$result; |
|
| 777 | + return (bool) $result; |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | $tokens = $result; |
@@ -826,9 +826,9 @@ discard block |
||
| 826 | 826 | * @throws RuntimeException |
| 827 | 827 | */ |
| 828 | 828 | public function copyMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) { |
| 829 | - $set = (int)$from; |
|
| 829 | + $set = (int) $from; |
|
| 830 | 830 | if ($to !== null) { |
| 831 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
| 831 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
| 832 | 832 | } |
| 833 | 833 | $command = trim($this->getUIDKey($uid)." COPY"); |
| 834 | 834 | return $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
@@ -867,9 +867,9 @@ discard block |
||
| 867 | 867 | * @throws RuntimeException |
| 868 | 868 | */ |
| 869 | 869 | public function moveMessage($folder, $from, $to = null, $uid = IMAP::ST_UID) { |
| 870 | - $set = (int)$from; |
|
| 870 | + $set = (int) $from; |
|
| 871 | 871 | if ($to !== null) { |
| 872 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
| 872 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
| 873 | 873 | } |
| 874 | 874 | $command = trim($this->getUIDKey($uid)." MOVE"); |
| 875 | 875 | |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | $ids = []; |
| 1083 | 1083 | foreach ($uids as $msgn => $v) { |
| 1084 | 1084 | $id = $uid ? $v : $msgn; |
| 1085 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
| 1085 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
| 1086 | 1086 | $ids[] = $id; |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
@@ -1096,14 +1096,14 @@ discard block |
||
| 1096 | 1096 | /** |
| 1097 | 1097 | * Enable the debug mode |
| 1098 | 1098 | */ |
| 1099 | - public function enableDebug(){ |
|
| 1099 | + public function enableDebug() { |
|
| 1100 | 1100 | $this->debug = true; |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | 1104 | * Disable the debug mode |
| 1105 | 1105 | */ |
| 1106 | - public function disableDebug(){ |
|
| 1106 | + public function disableDebug() { |
|
| 1107 | 1107 | $this->debug = false; |
| 1108 | 1108 | } |
| 1109 | 1109 | } |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | throw new AuthFailedException($message); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(!$this->stream) { |
|
| 92 | + if (!$this->stream) { |
|
| 93 | 93 | $errors = \imap_errors(); |
| 94 | 94 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
| 95 | 95 | throw new AuthFailedException($message); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $errors = \imap_errors(); |
| 99 | - if(is_array($errors)) { |
|
| 99 | + if (is_array($errors)) { |
|
| 100 | 100 | $status = $this->examineFolder(); |
| 101 | - if($status['exists'] !== 0) { |
|
| 101 | + if ($status['exists'] !== 0) { |
|
| 102 | 102 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
| 103 | 103 | throw new RuntimeException($message); |
| 104 | 104 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | if (!$this->cert_validation) { |
| 130 | 130 | $address .= '/novalidate-cert'; |
| 131 | 131 | } |
| 132 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
| 132 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
| 133 | 133 | $address .= '/'.$this->encryption; |
| 134 | 134 | } elseif ($this->encryption === "starttls") { |
| 135 | 135 | $address .= '/tls'; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function connected(){ |
|
| 162 | + public function connected() { |
|
| 163 | 163 | return boolval($this->stream); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return array |
| 233 | 233 | */ |
| 234 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
| 234 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
| 235 | 235 | $result = []; |
| 236 | 236 | $uids = is_array($uids) ? $uids : [$uids]; |
| 237 | 237 | foreach ($uids as $id) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
| 250 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
| 251 | 251 | $result = []; |
| 252 | 252 | $uids = is_array($uids) ? $uids : [$uids]; |
| 253 | 253 | foreach ($uids as $id) { |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | $flags = []; |
| 256 | 256 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
| 257 | 257 | $raw_flags = (array) $raw_flags[0]; |
| 258 | - foreach($raw_flags as $flag => $value) { |
|
| 259 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
| 258 | + foreach ($raw_flags as $flag => $value) { |
|
| 259 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
| 260 | 260 | $flags[] = "\\".ucfirst($flag); |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | if ($id === null) { |
| 278 | 278 | $overview = $this->overview("1:*"); |
| 279 | 279 | $uids = []; |
| 280 | - foreach($overview as $set){ |
|
| 280 | + foreach ($overview as $set) { |
|
| 281 | 281 | $uids[$set->msgno] = $set->uid; |
| 282 | 282 | } |
| 283 | 283 | return $uids; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @return array |
| 304 | 304 | */ |
| 305 | 305 | public function overview($sequence, $uid = IMAP::ST_UID) { |
| 306 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
| 306 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | $result = []; |
| 319 | 319 | |
| 320 | 320 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
| 321 | - if(is_array($items)){ |
|
| 321 | + if (is_array($items)) { |
|
| 322 | 322 | foreach ($items as $item) { |
| 323 | 323 | $name = $this->decodeFolderName($item->name); |
| 324 | 324 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 325 | 325 | } |
| 326 | - }else{ |
|
| 326 | + }else { |
|
| 327 | 327 | throw new RuntimeException(\imap_last_error()); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID) { |
| 346 | 346 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
| 347 | 347 | |
| 348 | - if ($mode == "+"){ |
|
| 348 | + if ($mode == "+") { |
|
| 349 | 349 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 350 | - }else{ |
|
| 350 | + }else { |
|
| 351 | 351 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
| 371 | 371 | if ($date != null) { |
| 372 | - if ($date instanceof \Carbon\Carbon){ |
|
| 372 | + if ($date instanceof \Carbon\Carbon) { |
|
| 373 | 373 | $date = $date->format('d-M-Y H:i:s O'); |
| 374 | 374 | } |
| 375 | 375 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return array|bool Tokens if operation successful, false if an error occurred |
| 402 | 402 | */ |
| 403 | 403 | public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
| 404 | - foreach($messages as $msg) { |
|
| 404 | + foreach ($messages as $msg) { |
|
| 405 | 405 | if ($this->copyMessage($folder, $msg, null, $uid) == false) { |
| 406 | 406 | return false; |
| 407 | 407 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @return array|bool Tokens if operation successful, false if an error occurred |
| 434 | 434 | */ |
| 435 | 435 | public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
| 436 | - foreach($messages as $msg) { |
|
| 436 | + foreach ($messages as $msg) { |
|
| 437 | 437 | if ($this->moveMessage($folder, $msg, null, $uid) == false) { |
| 438 | 438 | return false; |
| 439 | 439 | } |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | /** |
| 557 | 557 | * Enable the debug mode |
| 558 | 558 | */ |
| 559 | - public function enableDebug(){ |
|
| 559 | + public function enableDebug() { |
|
| 560 | 560 | $this->debug = true; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | 564 | * Disable the debug mode |
| 565 | 565 | */ |
| 566 | - public function disableDebug(){ |
|
| 566 | + public function disableDebug() { |
|
| 567 | 567 | $this->debug = false; |
| 568 | 568 | } |
| 569 | 569 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $name = $this->decodeFolderName($item->name); |
| 324 | 324 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 325 | 325 | } |
| 326 | - }else{ |
|
| 326 | + } else{ |
|
| 327 | 327 | throw new RuntimeException(\imap_last_error()); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | |
| 348 | 348 | if ($mode == "+"){ |
| 349 | 349 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 350 | - }else{ |
|
| 350 | + } else{ |
|
| 351 | 351 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 97 | 97 | $this->fetch_order = 'desc'; |
| 98 | - } else { |
|
| 98 | + }else { |
|
| 99 | 99 | $this->fetch_order = 'asc'; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | break; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return (string)$value; |
|
| 129 | + return (string) $value; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | $this->query->each(function($statement) use (&$query) { |
| 159 | 159 | if (count($statement) == 1) { |
| 160 | 160 | $query .= $statement[0]; |
| 161 | - } else { |
|
| 161 | + }else { |
|
| 162 | 162 | if ($statement[1] === null) { |
| 163 | 163 | $query .= $statement[0]; |
| 164 | - } else { |
|
| 164 | + }else { |
|
| 165 | 165 | if (is_numeric($statement[1])) { |
| 166 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
| 167 | - } else { |
|
| 168 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
| 166 | + $query .= $statement[0].' '.$statement[1]; |
|
| 167 | + }else { |
|
| 168 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $key = $message->getMessageId(); |
| 300 | 300 | break; |
| 301 | 301 | } |
| 302 | - return (string)$key; |
|
| 302 | + return (string) $key; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $extensions = isset($raw_messages["extensions"][$uid]) ? $raw_messages["extensions"][$uid] : []; |
| 330 | 330 | |
| 331 | 331 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
| 332 | - foreach($extensions as $key => $extension) { |
|
| 332 | + foreach ($extensions as $key => $extension) { |
|
| 333 | 333 | $message->getHeader()->set($key, $extension); |
| 334 | 334 | } |
| 335 | 335 | if ($message !== null) { |
@@ -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) { |
| 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); |
@@ -533,7 +537,9 @@ discard block |
||
| 533 | 537 | * @return $this |
| 534 | 538 | */ |
| 535 | 539 | public function limit($limit, $page = 1) { |
| 536 | - if ($page >= 1) $this->page = $page; |
|
| 540 | + if ($page >= 1) { |
|
| 541 | + $this->page = $page; |
|
| 542 | + } |
|
| 537 | 543 | $this->limit = $limit; |
| 538 | 544 | |
| 539 | 545 | return $this; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $this->setDelimiter($delimiter); |
| 124 | 124 | $this->path = $folder_name; |
| 125 | - $this->full_name = $this->decodeName($folder_name); |
|
| 125 | + $this->full_name = $this->decodeName($folder_name); |
|
| 126 | 126 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
| 127 | 127 | |
| 128 | 128 | $this->parseAttributes($attributes); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @throws Exceptions\ConnectionFailedException |
| 137 | 137 | * @throws Exceptions\RuntimeException |
| 138 | 138 | */ |
| 139 | - public function query($extensions = []){ |
|
| 139 | + public function query($extensions = []) { |
|
| 140 | 140 | $this->getClient()->checkConnection(); |
| 141 | 141 | $this->getClient()->openFolder($this->path); |
| 142 | 142 | $extensions = count($extensions) > 0 ? $extensions : $this->getClient()->extensions; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @throws Exceptions\ConnectionFailedException |
| 150 | 150 | * @throws Exceptions\RuntimeException |
| 151 | 151 | */ |
| 152 | - public function search($extensions = 'UTF-8'){ |
|
| 152 | + public function search($extensions = 'UTF-8') { |
|
| 153 | 153 | return $this->query($extensions); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @throws Exceptions\ConnectionFailedException |
| 159 | 159 | * @throws Exceptions\RuntimeException |
| 160 | 160 | */ |
| 161 | - public function messages($extensions = []){ |
|
| 161 | + public function messages($extensions = []) { |
|
| 162 | 162 | return $this->query($extensions); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | public function move($new_name, $expunge = true) { |
| 234 | 234 | $this->client->checkConnection(); |
| 235 | 235 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 236 | - if($expunge) $this->client->expunge(); |
|
| 236 | + if ($expunge) $this->client->expunge(); |
|
| 237 | 237 | |
| 238 | 238 | $folder = $this->client->getFolder($new_name); |
| 239 | 239 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @throws Exceptions\MessageNotFoundException |
| 253 | 253 | * @throws Exceptions\RuntimeException |
| 254 | 254 | */ |
| 255 | - public function overview($sequence = null){ |
|
| 255 | + public function overview($sequence = null) { |
|
| 256 | 256 | $this->client->openFolder($this->path); |
| 257 | 257 | $sequence = $sequence === null ? "1:*" : $sequence; |
| 258 | 258 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | |
| 279 | 279 | if ($internal_date != null) { |
| 280 | - if ($internal_date instanceof Carbon){ |
|
| 280 | + if ($internal_date instanceof Carbon) { |
|
| 281 | 281 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function delete($expunge = true) { |
| 313 | 313 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 314 | - if($expunge) $this->client->expunge(); |
|
| 314 | + if ($expunge) $this->client->expunge(); |
|
| 315 | 315 | |
| 316 | 316 | $event = $this->getEvent("folder", "deleted"); |
| 317 | 317 | $event::dispatch($this); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | try { |
| 373 | 373 | $line = $connection->nextLine(); |
| 374 | 374 | if (($pos = strpos($line, "EXISTS")) !== false) { |
| 375 | - $msgn = (int) substr($line, 2, $pos -2); |
|
| 375 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
| 376 | 376 | $connection->done(); |
| 377 | 377 | |
| 378 | 378 | $this->client->openFolder($this->path, true); |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | |
| 386 | 386 | $connection->idle(); |
| 387 | 387 | } |
| 388 | - }catch (Exceptions\RuntimeException $e) { |
|
| 389 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
| 388 | + } catch (Exceptions\RuntimeException $e) { |
|
| 389 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
| 390 | 390 | throw $e; |
| 391 | 391 | } |
| 392 | 392 | if ($auto_reconnect === true) { |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | * Set the delimiter |
| 436 | 436 | * @param $delimiter |
| 437 | 437 | */ |
| 438 | - public function setDelimiter($delimiter){ |
|
| 439 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 438 | + public function setDelimiter($delimiter) { |
|
| 439 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 440 | 440 | $delimiter = ClientManager::get('options.delimiter', '/'); |
| 441 | 441 | } |
| 442 | 442 | |