@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $this->setDelimiter($delimiter); |
127 | 127 | $this->path = $folder_name; |
128 | - $this->full_name = $this->decodeName($folder_name); |
|
128 | + $this->full_name = $this->decodeName($folder_name); |
|
129 | 129 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
130 | 130 | |
131 | 131 | $this->parseAttributes($attributes); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return WhereQuery |
139 | 139 | * @throws Exceptions\ConnectionFailedException |
140 | 140 | */ |
141 | - public function query($charset = 'UTF-8'){ |
|
141 | + public function query($charset = 'UTF-8') { |
|
142 | 142 | $this->getClient()->checkConnection(); |
143 | 143 | $this->getClient()->openFolder($this->path); |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @inheritdoc self::query($charset = 'UTF-8') |
150 | 150 | * @throws Exceptions\ConnectionFailedException |
151 | 151 | */ |
152 | - public function search($charset = 'UTF-8'){ |
|
152 | + public function search($charset = 'UTF-8') { |
|
153 | 153 | return $this->query($charset); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @inheritdoc self::query($charset = 'UTF-8') |
158 | 158 | * @throws Exceptions\ConnectionFailedException |
159 | 159 | */ |
160 | - public function messages($charset = 'UTF-8'){ |
|
160 | + public function messages($charset = 'UTF-8') { |
|
161 | 161 | return $this->query($charset); |
162 | 162 | } |
163 | 163 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function move($new_name, $expunge = true) { |
233 | 233 | $this->client->checkConnection(); |
234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
235 | - if($expunge) $this->client->expunge(); |
|
235 | + if ($expunge) $this->client->expunge(); |
|
236 | 236 | |
237 | 237 | $folder = $this->client->getFolder($new_name); |
238 | 238 | $event = $this->getEvent("folder", "moved"); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @return array |
249 | 249 | * @throws ConnectionFailedException |
250 | 250 | */ |
251 | - public function overview($sequence = null){ |
|
251 | + public function overview($sequence = null) { |
|
252 | 252 | $this->client->openFolder($this->path); |
253 | 253 | $sequence = $sequence === null ? "1:*" : $sequence; |
254 | 254 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | */ |
274 | 274 | |
275 | 275 | if ($internal_date != null) { |
276 | - if ($internal_date instanceof Carbon){ |
|
276 | + if ($internal_date instanceof Carbon) { |
|
277 | 277 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
278 | 278 | } |
279 | 279 | } |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | */ |
308 | 308 | public function delete($expunge = true) { |
309 | 309 | $status = $this->client->getConnection()->deleteFolder($this->path); |
310 | - if($expunge) $this->client->expunge(); |
|
310 | + if ($expunge) $this->client->expunge(); |
|
311 | 311 | |
312 | 312 | $event = $this->getEvent("folder", "deleted"); |
313 | 313 | $event::dispatch($this); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | try { |
363 | 363 | $line = $connection->nextLine(); |
364 | 364 | if (($pos = strpos($line, "EXISTS")) !== false) { |
365 | - $msgn = (int) substr($line, 2, $pos -2); |
|
365 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
366 | 366 | $connection->done(); |
367 | 367 | |
368 | 368 | $this->client->openFolder($this->path, true); |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | |
375 | 375 | $connection->idle(); |
376 | 376 | } |
377 | - }catch (Exceptions\RuntimeException $e) { |
|
378 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
377 | + } catch (Exceptions\RuntimeException $e) { |
|
378 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
379 | 379 | throw $e; |
380 | 380 | } |
381 | 381 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * Set the delimiter |
418 | 418 | * @param $delimiter |
419 | 419 | */ |
420 | - public function setDelimiter($delimiter){ |
|
421 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
420 | + public function setDelimiter($delimiter) { |
|
421 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
422 | 422 | $delimiter = ClientManager::get('options.delimiter', '/'); |
423 | 423 | } |
424 | 424 |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws ConnectionFailedException |
85 | 85 | * @throws RuntimeException |
86 | 86 | */ |
87 | - protected function enableTls(){ |
|
87 | + protected function enableTls() { |
|
88 | 88 | $response = $this->requestAndResponse('STARTTLS'); |
89 | 89 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
90 | 90 | if (!$result) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $stack = []; |
147 | 147 | |
148 | 148 | // replace any trailing <NL> including spaces with a single space |
149 | - $line = rtrim($line) . ' '; |
|
149 | + $line = rtrim($line).' '; |
|
150 | 150 | while (($pos = strpos($line, ' ')) !== false) { |
151 | 151 | $token = substr($line, 0, $pos); |
152 | 152 | if (!strlen($token)) { |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | if (strlen($token) > $chars) { |
177 | 177 | $line = substr($token, $chars); |
178 | 178 | $token = substr($token, 0, $chars); |
179 | - } else { |
|
179 | + }else { |
|
180 | 180 | $line .= $this->nextLine(); |
181 | 181 | } |
182 | 182 | $tokens[] = $token; |
183 | - $line = trim($line) . ' '; |
|
183 | + $line = trim($line).' '; |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $line = $this->nextTaggedLine($tag); // get next tag |
231 | 231 | if (!$dontParse) { |
232 | 232 | $tokens = $this->decodeLine($line); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | 236 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | // First two chars are still needed for the response code |
258 | 258 | $tokens = [substr($tokens, 0, 2)]; |
259 | 259 | } |
260 | - if (is_array($lines)){ |
|
260 | + if (is_array($lines)) { |
|
261 | 261 | if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
262 | - }else{ |
|
262 | + }else { |
|
263 | 263 | if ($this->debug) echo "<< ".$lines."\n"; |
264 | 264 | } |
265 | 265 | |
@@ -284,27 +284,27 @@ discard block |
||
284 | 284 | public function sendRequest($command, $tokens = [], &$tag = null) { |
285 | 285 | if (!$tag) { |
286 | 286 | $this->noun++; |
287 | - $tag = 'TAG' . $this->noun; |
|
287 | + $tag = 'TAG'.$this->noun; |
|
288 | 288 | } |
289 | 289 | |
290 | - $line = $tag . ' ' . $command; |
|
290 | + $line = $tag.' '.$command; |
|
291 | 291 | |
292 | 292 | foreach ($tokens as $token) { |
293 | 293 | if (is_array($token)) { |
294 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
294 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
295 | 295 | throw new RuntimeException('failed to write - connection closed?'); |
296 | 296 | } |
297 | 297 | if (!$this->assumedNextLine('+ ')) { |
298 | 298 | throw new RuntimeException('failed to send literal string'); |
299 | 299 | } |
300 | 300 | $line = $token[1]; |
301 | - } else { |
|
302 | - $line .= ' ' . $token; |
|
301 | + }else { |
|
302 | + $line .= ' '.$token; |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | if ($this->debug) echo ">> ".$line."\n"; |
306 | 306 | |
307 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
307 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
308 | 308 | throw new RuntimeException('failed to write - connection closed?'); |
309 | 309 | } |
310 | 310 | } |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | public function escapeString($string) { |
335 | 335 | if (func_num_args() < 2) { |
336 | 336 | if (strpos($string, "\n") !== false) { |
337 | - return ['{' . strlen($string) . '}', $string]; |
|
338 | - } else { |
|
339 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
337 | + return ['{'.strlen($string).'}', $string]; |
|
338 | + }else { |
|
339 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | $result = []; |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | $result[] = $this->escapeList($v); |
363 | 363 | } |
364 | - return '(' . implode(' ', $result) . ')'; |
|
364 | + return '('.implode(' ', $result).')'; |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | error_log("got an extra server challenge: $response"); |
402 | 402 | // respond with an empty response. |
403 | 403 | $this->sendRequest(''); |
404 | - } else { |
|
404 | + }else { |
|
405 | 405 | if (preg_match('/^NO /i', $response) || |
406 | 406 | preg_match('/^BAD /i', $response)) { |
407 | 407 | error_log("got failure response: $response"); |
408 | 408 | return false; |
409 | - } else if (preg_match("/^OK /i", $response)) { |
|
409 | + }else if (preg_match("/^OK /i", $response)) { |
|
410 | 410 | return true; |
411 | 411 | } |
412 | 412 | } |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return bool |
441 | 441 | */ |
442 | - public function connected(){ |
|
442 | + public function connected() { |
|
443 | 443 | return (boolean) $this->stream; |
444 | 444 | } |
445 | 445 | |
@@ -486,10 +486,10 @@ discard block |
||
486 | 486 | $result[strtolower($tokens[1])] = $tokens[0]; |
487 | 487 | break; |
488 | 488 | case '[UIDVALIDITY': |
489 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
489 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
490 | 490 | break; |
491 | 491 | case '[UIDNEXT': |
492 | - $result['uidnext'] = (int)$tokens[2]; |
|
492 | + $result['uidnext'] = (int) $tokens[2]; |
|
493 | 493 | break; |
494 | 494 | default: |
495 | 495 | // ignore |
@@ -543,17 +543,17 @@ discard block |
||
543 | 543 | if (is_array($from)) { |
544 | 544 | $set = implode(',', $from); |
545 | 545 | } elseif ($to === null) { |
546 | - $set = (int)$from; |
|
546 | + $set = (int) $from; |
|
547 | 547 | } elseif ($to === INF) { |
548 | - $set = (int)$from . ':*'; |
|
549 | - } else { |
|
550 | - $set = (int)$from . ':' . (int)$to; |
|
548 | + $set = (int) $from.':*'; |
|
549 | + }else { |
|
550 | + $set = (int) $from.':'.(int) $to; |
|
551 | 551 | } |
552 | 552 | |
553 | - $items = (array)$items; |
|
553 | + $items = (array) $items; |
|
554 | 554 | $itemList = $this->escapeList($items); |
555 | 555 | |
556 | - $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag); |
|
556 | + $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag); |
|
557 | 557 | |
558 | 558 | $result = []; |
559 | 559 | $tokens = null; // define $tokens variable before first use |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | $count = count($tokens[2]); |
569 | 569 | if ($tokens[2][$count - 2] == 'UID') { |
570 | 570 | $uidKey = $count - 1; |
571 | - } else if ($tokens[2][0] == 'UID') { |
|
571 | + }else if ($tokens[2][0] == 'UID') { |
|
572 | 572 | $uidKey = 1; |
573 | - } else { |
|
573 | + }else { |
|
574 | 574 | $uidKey = array_search('UID', $tokens[2]) + 1; |
575 | 575 | } |
576 | 576 | } |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $data = $tokens[2][1]; |
587 | 587 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
588 | 588 | $data = $tokens[2][3]; |
589 | - } else { |
|
589 | + }else { |
|
590 | 590 | // maybe the server send an other field we didn't wanted |
591 | 591 | $count = count($tokens[2]); |
592 | 592 | // we start with 2, because 0 was already checked |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | break; |
599 | 599 | } |
600 | 600 | } |
601 | - } else { |
|
601 | + }else { |
|
602 | 602 | $data = []; |
603 | 603 | while (key($tokens[2]) !== null) { |
604 | 604 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | if ($uid) { |
617 | 617 | $result[$tokens[2][$uidKey]] = $data; |
618 | - }else{ |
|
618 | + }else { |
|
619 | 619 | $result[$tokens[0]] = $data; |
620 | 620 | } |
621 | 621 | } |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | * @return array |
650 | 650 | * @throws RuntimeException |
651 | 651 | */ |
652 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
652 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
653 | 653 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
654 | 654 | } |
655 | 655 | |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | * @return array |
662 | 662 | * @throws RuntimeException |
663 | 663 | */ |
664 | - public function flags($uids, $uid = false){ |
|
664 | + public function flags($uids, $uid = false) { |
|
665 | 665 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
666 | 666 | } |
667 | 667 | |
@@ -746,22 +746,22 @@ discard block |
||
746 | 746 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
747 | 747 | $item = 'FLAGS'; |
748 | 748 | if ($mode == '+' || $mode == '-') { |
749 | - $item = $mode . $item; |
|
749 | + $item = $mode.$item; |
|
750 | 750 | } |
751 | 751 | if ($silent) { |
752 | 752 | $item .= '.SILENT'; |
753 | 753 | } |
754 | 754 | |
755 | 755 | $flags = $this->escapeList($flags); |
756 | - $set = (int)$from; |
|
756 | + $set = (int) $from; |
|
757 | 757 | if ($to !== null) { |
758 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
758 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent); |
762 | 762 | |
763 | 763 | if ($silent) { |
764 | - return (bool)$result; |
|
764 | + return (bool) $result; |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | $tokens = $result; |
@@ -812,9 +812,9 @@ discard block |
||
812 | 812 | * @throws RuntimeException |
813 | 813 | */ |
814 | 814 | public function copyMessage($folder, $from, $to = null, $uid = false) { |
815 | - $set = (int)$from; |
|
815 | + $set = (int) $from; |
|
816 | 816 | if ($to !== null) { |
817 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
817 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true); |
@@ -832,9 +832,9 @@ discard block |
||
832 | 832 | * @throws RuntimeException |
833 | 833 | */ |
834 | 834 | public function moveMessage($folder, $from, $to = null, $uid = false) { |
835 | - $set = (int)$from; |
|
835 | + $set = (int) $from; |
|
836 | 836 | if ($to !== null) { |
837 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
837 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | return $this->requestAndResponse('MOVE', [$set, $this->escapeString($folder)], true); |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $uids = $this->getUid(); |
1003 | 1003 | $ids = []; |
1004 | 1004 | foreach ($uids as $msgn => $v) { |
1005 | - if ( ($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn) ){ |
|
1005 | + if (($to >= $msgn && $from <= $msgn) || ($to === "*" && $from <= $msgn)) { |
|
1006 | 1006 | $ids[] = $uid ? $v : $msgn; |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | /** |
1017 | 1017 | * Enable the debug mode |
1018 | 1018 | */ |
1019 | - public function enableDebug(){ |
|
1019 | + public function enableDebug() { |
|
1020 | 1020 | $this->debug = true; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
1024 | 1024 | * Disable the debug mode |
1025 | 1025 | */ |
1026 | - public function disableDebug(){ |
|
1026 | + public function disableDebug() { |
|
1027 | 1027 | $this->debug = false; |
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | \ No newline at end of file |