@@ -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 |
@@ -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'; |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | $flags = []; |
258 | 258 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
259 | 259 | $raw_flags = (array) $raw_flags[0]; |
260 | - foreach($raw_flags as $flag => $value) { |
|
261 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
260 | + foreach ($raw_flags as $flag => $value) { |
|
261 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
262 | 262 | $flags[] = "\\".ucfirst($flag); |
263 | 263 | } |
264 | 264 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $overview = $this->overview("1:*"); |
285 | 285 | $uids = []; |
286 | - foreach($overview as $set){ |
|
286 | + foreach ($overview as $set) { |
|
287 | 287 | $uids[$set->msgno] = $set->uid; |
288 | 288 | } |
289 | 289 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return array |
313 | 313 | */ |
314 | 314 | public function overview(string $sequence, $uid = IMAP::ST_UID): array { |
315 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
315 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | $result = []; |
328 | 328 | |
329 | 329 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
330 | - if(is_array($items)){ |
|
330 | + if (is_array($items)) { |
|
331 | 331 | foreach ($items as $item) { |
332 | 332 | $name = $this->decodeFolderName($item->name); |
333 | 333 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
334 | 334 | } |
335 | - }else{ |
|
335 | + }else { |
|
336 | 336 | throw new RuntimeException(\imap_last_error()); |
337 | 337 | } |
338 | 338 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) { |
356 | 356 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
357 | 357 | |
358 | - if ($mode == "+"){ |
|
358 | + if ($mode == "+") { |
|
359 | 359 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
360 | - }else{ |
|
360 | + }else { |
|
361 | 361 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
362 | 362 | } |
363 | 363 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool { |
381 | 381 | if ($date != null) { |
382 | - if ($date instanceof \Carbon\Carbon){ |
|
382 | + if ($date instanceof \Carbon\Carbon) { |
|
383 | 383 | $date = $date->format('d-M-Y H:i:s O'); |
384 | 384 | } |
385 | 385 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | * @return array|bool Tokens if operation successful, false if an error occurred |
412 | 412 | */ |
413 | 413 | public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
414 | - foreach($messages as $msg) { |
|
414 | + foreach ($messages as $msg) { |
|
415 | 415 | if (!$this->copyMessage($folder, $msg, null, $uid)) { |
416 | 416 | return false; |
417 | 417 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @return array|bool Tokens if operation successful, false if an error occurred |
444 | 444 | */ |
445 | 445 | public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
446 | - foreach($messages as $msg) { |
|
446 | + foreach ($messages as $msg) { |
|
447 | 447 | if (!$this->moveMessage($folder, $msg, null, $uid)) { |
448 | 448 | return false; |
449 | 449 | } |
@@ -570,14 +570,14 @@ discard block |
||
570 | 570 | /** |
571 | 571 | * Enable the debug mode |
572 | 572 | */ |
573 | - public function enableDebug(){ |
|
573 | + public function enableDebug() { |
|
574 | 574 | $this->debug = true; |
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
578 | 578 | * Disable the debug mode |
579 | 579 | */ |
580 | - public function disableDebug(){ |
|
580 | + public function disableDebug() { |
|
581 | 581 | $this->debug = false; |
582 | 582 | } |
583 | 583 |
@@ -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; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
94 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | if (isset($this->attributes[$name]) && $strict === false) { |
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - } else { |
|
133 | + }else { |
|
134 | 134 | if (isset($this->attributes[$name])) { |
135 | 135 | if (!is_array($this->attributes[$name])) { |
136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
137 | - } else { |
|
137 | + }else { |
|
138 | 138 | $this->attributes[$name][] = $value; |
139 | 139 | } |
140 | - } else { |
|
140 | + }else { |
|
141 | 141 | $this->attributes[$name] = $value; |
142 | 142 | } |
143 | 143 | } |
144 | 144 | } elseif (!$this->attributize) { |
145 | 145 | $this->attributes[$name] = $value; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $headers = []; |
237 | 237 | $imap_headers = []; |
238 | 238 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
239 | - $raw_imap_headers = (array)\imap_rfc822_parse_headers($this->raw); |
|
239 | + $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
|
240 | 240 | foreach ($raw_imap_headers as $key => $values) { |
241 | 241 | $key = str_replace("-", "_", $key); |
242 | 242 | $imap_headers[$key] = $values; |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | } |
265 | 265 | if (is_array($headers[$prev_header])) { |
266 | 266 | $headers[$prev_header][] = $line; |
267 | - } else { |
|
267 | + }else { |
|
268 | 268 | $headers[$prev_header] .= $line; |
269 | 269 | } |
270 | 270 | } |
271 | - } else { |
|
271 | + }else { |
|
272 | 272 | if (($pos = strpos($line, ":")) > 0) { |
273 | 273 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
274 | 274 | $key = str_replace("-", "_", $key); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $value = trim(rtrim(substr($line, $pos + 1))); |
277 | 277 | if (isset($headers[$key])) { |
278 | 278 | $headers[$key][] = $value; |
279 | - } else { |
|
279 | + }else { |
|
280 | 280 | $headers[$key] = [$value]; |
281 | 281 | } |
282 | 282 | $prev_header = $key; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | case 'reply_to': |
296 | 296 | case 'sender': |
297 | 297 | $value = $this->decodeAddresses($values); |
298 | - $headers[$key . "address"] = implode(", ", $values); |
|
298 | + $headers[$key."address"] = implode(", ", $values); |
|
299 | 299 | break; |
300 | 300 | case 'subject': |
301 | 301 | $value = implode(" ", $values); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $value = implode(" ", $values); |
315 | 315 | } elseif ($available_values > 2) { |
316 | 316 | $value = array_values($values); |
317 | - } else { |
|
317 | + }else { |
|
318 | 318 | $value = ""; |
319 | 319 | } |
320 | 320 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $headers[$key] = $value; |
324 | 324 | } |
325 | 325 | |
326 | - return (object)array_merge($headers, $imap_headers); |
|
326 | + return (object) array_merge($headers, $imap_headers); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | return is_array($result) ? $result : []; |
341 | 341 | } |
342 | 342 | $charset = $this->getEncoding($text); |
343 | - return [(object)[ |
|
343 | + return [(object) [ |
|
344 | 344 | "charset" => $charset, |
345 | 345 | "text" => $this->convertEncoding($text, $charset) |
346 | 346 | ]]; |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | try { |
395 | 395 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
396 | 396 | return iconv($from, $to, $str); |
397 | - } else { |
|
397 | + }else { |
|
398 | 398 | if (!$from) { |
399 | 399 | return mb_convert_encoding($str, $to); |
400 | 400 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | if (strstr($from, '-')) { |
405 | 405 | $from = str_replace('-', '', $from); |
406 | 406 | return $this->convertEncoding($str, $from, $to); |
407 | - } else { |
|
407 | + }else { |
|
408 | 408 | return $str; |
409 | 409 | } |
410 | 410 | } |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | */ |
510 | 510 | private function findPriority() { |
511 | 511 | if (($priority = $this->get("x_priority")) === null) return; |
512 | - switch ((int)"$priority") { |
|
512 | + switch ((int) "$priority") { |
|
513 | 513 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
514 | 514 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
515 | 515 | break; |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | if (isset($parsed_address['address'])) { |
549 | 549 | $mail_address = explode('@', $parsed_address['address']); |
550 | 550 | if (count($mail_address) == 2) { |
551 | - $addresses[] = (object)[ |
|
551 | + $addresses[] = (object) [ |
|
552 | 552 | "personal" => $parsed_address['display'] ?? '', |
553 | 553 | "mailbox" => $mail_address[0], |
554 | 554 | "host" => $mail_address[1], |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $name = trim(rtrim($matches["name"])); |
577 | 577 | $email = trim(rtrim($matches["email"])); |
578 | 578 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
579 | - $addresses[] = (object)[ |
|
579 | + $addresses[] = (object) [ |
|
580 | 580 | "personal" => $name, |
581 | 581 | "mailbox" => $mailbox, |
582 | 582 | "host" => $host, |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | } |
615 | 615 | |
616 | 616 | foreach ($list as $item) { |
617 | - $address = (object)$item; |
|
617 | + $address = (object) $item; |
|
618 | 618 | |
619 | 619 | if (!property_exists($address, 'mailbox')) { |
620 | 620 | $address->mailbox = false; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } |
625 | 625 | if (!property_exists($address, 'personal')) { |
626 | 626 | $address->personal = false; |
627 | - } else { |
|
627 | + }else { |
|
628 | 628 | $personalParts = $this->mime_header_decode($address->personal); |
629 | 629 | |
630 | 630 | if (is_array($personalParts)) { |
@@ -639,8 +639,8 @@ discard block |
||
639 | 639 | } |
640 | 640 | } |
641 | 641 | |
642 | - $address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false; |
|
643 | - $address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail; |
|
642 | + $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false; |
|
643 | + $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail; |
|
644 | 644 | |
645 | 645 | $addresses[] = new Address($address); |
646 | 646 | } |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | foreach ($this->attributes as $key => $value) { |
656 | 656 | if (is_array($value)) { |
657 | 657 | $value = implode(", ", $value); |
658 | - } else { |
|
659 | - $value = (string)$value; |
|
658 | + }else { |
|
659 | + $value = (string) $value; |
|
660 | 660 | } |
661 | 661 | // Only parse strings and don't parse any attributes like the user-agent |
662 | 662 | if (($key == "user_agent") === false) { |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | $date = trim(rtrim($date)); |
717 | 717 | try { |
718 | - if(strpos($date, ' ') !== false){ |
|
718 | + if (strpos($date, ' ') !== false) { |
|
719 | 719 | $date = str_replace(' ', ' ', $date); |
720 | 720 | } |
721 | 721 | $parsed_date = Carbon::parse($date); |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | $parsed_date = Carbon::parse($date); |
743 | 743 | } catch (\Exception $_e) { |
744 | 744 | if (!isset($this->config["fallback_date"])) { |
745 | - throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e); |
|
746 | - } else { |
|
745 | + throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date, 1100, $e); |
|
746 | + }else { |
|
747 | 747 | $parsed_date = Carbon::parse($this->config["fallback_date"]); |
748 | 748 | } |
749 | 749 | } |
@@ -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 | } |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | public static function get(string $key, $default = null) { |
77 | 77 | $parts = explode('.', $key); |
78 | 78 | $value = null; |
79 | - foreach($parts as $part) { |
|
80 | - if($value === null) { |
|
81 | - if(isset(self::$config[$part])) { |
|
79 | + foreach ($parts as $part) { |
|
80 | + if ($value === null) { |
|
81 | + if (isset(self::$config[$part])) { |
|
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + }else { |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
87 | - if(isset($value[$part])) { |
|
86 | + }else { |
|
87 | + if (isset($value[$part])) { |
|
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + }else { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function setConfig($config): ClientManager { |
177 | 177 | |
178 | - if(is_array($config) === false) { |
|
178 | + if (is_array($config) === false) { |
|
179 | 179 | $config = require $config; |
180 | 180 | } |
181 | 181 | |
@@ -185,17 +185,17 @@ discard block |
||
185 | 185 | $vendor_config = require $path; |
186 | 186 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
187 | 187 | |
188 | - if(is_array($config)){ |
|
189 | - if(isset($config['default'])){ |
|
190 | - if(isset($config['accounts']) && $config['default']){ |
|
188 | + if (is_array($config)) { |
|
189 | + if (isset($config['default'])) { |
|
190 | + if (isset($config['accounts']) && $config['default']) { |
|
191 | 191 | |
192 | 192 | $default_config = $vendor_config['accounts']['default']; |
193 | - if(isset($config['accounts'][$config['default']])){ |
|
193 | + if (isset($config['accounts'][$config['default']])) { |
|
194 | 194 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
195 | 195 | } |
196 | 196 | |
197 | - if(is_array($config['accounts'])){ |
|
198 | - foreach($config['accounts'] as $account_key => $account){ |
|
197 | + if (is_array($config['accounts'])) { |
|
198 | + foreach ($config['accounts'] as $account_key => $account) { |
|
199 | 199 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
200 | 200 | } |
201 | 201 | } |
@@ -234,20 +234,20 @@ discard block |
||
234 | 234 | return array_keys($arr) !== range(0, count($arr) - 1); |
235 | 235 | }; |
236 | 236 | |
237 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
237 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
238 | 238 | |
239 | - foreach($arrays as $append) { |
|
239 | + foreach ($arrays as $append) { |
|
240 | 240 | |
241 | - if(!is_array($append)) $append = array($append); |
|
241 | + if (!is_array($append)) $append = array($append); |
|
242 | 242 | |
243 | - foreach($append as $key => $value) { |
|
243 | + foreach ($append as $key => $value) { |
|
244 | 244 | |
245 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
245 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
246 | 246 | $base[$key] = $value; |
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | - if( |
|
250 | + if ( |
|
251 | 251 | ( |
252 | 252 | is_array($value) |
253 | 253 | && $isAssoc($value) |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment'] |
262 | 262 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
263 | 263 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
264 | - } else if(is_numeric($key)) { |
|
265 | - if(!in_array($value, $base)) $base[] = $value; |
|
266 | - } else { |
|
264 | + }else if (is_numeric($key)) { |
|
265 | + if (!in_array($value, $base)) $base[] = $value; |
|
266 | + }else { |
|
267 | 267 | $base[$key] = $value; |
268 | 268 | } |
269 | 269 |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function offsetSet($offset, $value) { |
116 | 116 | if (is_null($offset)) { |
117 | 117 | $this->values[] = $value; |
118 | - } else { |
|
118 | + }else { |
|
119 | 119 | $this->values[$offset] = $value; |
120 | 120 | } |
121 | 121 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($this->contains($value) === false) { |
189 | 189 | $this->values[] = $value; |
190 | 190 | } |
191 | - }else{ |
|
191 | + }else { |
|
192 | 192 | $this->values[] = $value; |
193 | 193 | } |
194 | 194 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * |
238 | 238 | * @return mixed|null |
239 | 239 | */ |
240 | - public function first(){ |
|
240 | + public function first() { |
|
241 | 241 | if ($this->offsetExists(0)) { |
242 | 242 | return $this->values[0]; |
243 | 243 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return mixed|null |
251 | 251 | */ |
252 | - public function last(){ |
|
252 | + public function last() { |
|
253 | 253 | if (($cnt = $this->count()) > 0) { |
254 | 254 | return $this->values[$cnt - 1]; |
255 | 255 | } |
@@ -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 | } |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | if (strpos(strtolower($name), "where") === false) { |
88 | - $method = 'where' . ucfirst($name); |
|
89 | - } else { |
|
88 | + $method = 'where'.ucfirst($name); |
|
89 | + }else { |
|
90 | 90 | $method = lcfirst($name); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return call_user_func_array([$that, $method], $arguments); |
95 | 95 | } |
96 | 96 | |
97 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
97 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -137,11 +137,11 @@ 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 | } |
144 | - } else { |
|
144 | + }else { |
|
145 | 145 | $this->push_search_criteria($criteria, $value); |
146 | 146 | } |
147 | 147 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @throws InvalidWhereQueryCriteriaException |
157 | 157 | */ |
158 | - protected function push_search_criteria(string $criteria, $value){ |
|
158 | + protected function push_search_criteria(string $criteria, $value) { |
|
159 | 159 | $criteria = $this->validate_criteria($criteria); |
160 | 160 | $value = $this->parse_value($value); |
161 | 161 | |
162 | 162 | if ($value === null || $value === '') { |
163 | 163 | $this->query->push([$criteria]); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $this->query->push([$criteria, $value]); |
166 | 166 | } |
167 | 167 | } |
@@ -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; |
@@ -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 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $value = $value->format($this->date_format); |
125 | 125 | } |
126 | 126 | |
127 | - return (string)$value; |
|
127 | + return (string) $value; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -156,14 +156,14 @@ discard block |
||
156 | 156 | $this->query->each(function($statement) use (&$query) { |
157 | 157 | if (count($statement) == 1) { |
158 | 158 | $query .= $statement[0]; |
159 | - } else { |
|
159 | + }else { |
|
160 | 160 | if ($statement[1] === null) { |
161 | 161 | $query .= $statement[0]; |
162 | - } else { |
|
162 | + }else { |
|
163 | 163 | if (is_numeric($statement[1])) { |
164 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
165 | - } else { |
|
166 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
164 | + $query .= $statement[0].' '.$statement[1]; |
|
165 | + }else { |
|
166 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | $key = $message->getMessageId(); |
298 | 298 | break; |
299 | 299 | } |
300 | - return (string)$key; |
|
300 | + return (string) $key; |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $extensions = $raw_messages["extensions"][$uid] ?? []; |
346 | 346 | |
347 | 347 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
348 | - foreach($extensions as $key => $extension) { |
|
348 | + foreach ($extensions as $key => $extension) { |
|
349 | 349 | $message->getHeader()->set($key, $extension); |
350 | 350 | } |
351 | 351 | if ($message !== null) { |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | $uids = $connection->getUid(); |
498 | 498 | $available_messages = new Collection(); |
499 | 499 | if (is_array($uids)) { |
500 | - foreach ($uids as $id){ |
|
500 | + foreach ($uids as $id) { |
|
501 | 501 | if ($closure($id)) { |
502 | 502 | $available_messages->push($id); |
503 | 503 | } |
@@ -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 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->boot(); |
193 | 193 | |
194 | 194 | $default_mask = $client->getDefaultMessageMask(); |
195 | - if($default_mask != null) { |
|
195 | + if ($default_mask != null) { |
|
196 | 196 | $this->mask = $default_mask; |
197 | 197 | } |
198 | 198 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $instance->boot(); |
254 | 254 | |
255 | 255 | $default_mask = $client->getDefaultMessageMask(); |
256 | - if($default_mask != null) { |
|
256 | + if ($default_mask != null) { |
|
257 | 257 | $instance->setMask($default_mask); |
258 | 258 | } |
259 | 259 | $instance->setEvents([ |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Boot a new instance |
280 | 280 | */ |
281 | - public function boot(){ |
|
281 | + public function boot() { |
|
282 | 282 | $this->attributes = []; |
283 | 283 | |
284 | 284 | $this->config = ClientManager::get('options'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @throws MethodNotFoundException |
298 | 298 | */ |
299 | 299 | public function __call(string $method, array $arguments) { |
300 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
300 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
301 | 301 | $name = Str::snake(substr($method, 3)); |
302 | 302 | return $this->get($name); |
303 | 303 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
304 | 304 | $name = Str::snake(substr($method, 3)); |
305 | 305 | |
306 | - if(in_array($name, array_keys($this->attributes))) { |
|
306 | + if (in_array($name, array_keys($this->attributes))) { |
|
307 | 307 | return $this->__set($name, array_pop($arguments)); |
308 | 308 | } |
309 | 309 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @return Attribute|mixed|null |
343 | 343 | */ |
344 | 344 | public function get($name) { |
345 | - if(isset($this->attributes[$name])) { |
|
345 | + if (isset($this->attributes[$name])) { |
|
346 | 346 | return $this->attributes[$name]; |
347 | 347 | } |
348 | 348 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @throws InvalidMessageDateException |
418 | 418 | */ |
419 | - public function parseRawHeader(string $raw_header){ |
|
419 | + public function parseRawHeader(string $raw_header) { |
|
420 | 420 | $this->header = new Header($raw_header); |
421 | 421 | } |
422 | 422 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | public function parseRawFlags(array $raw_flags) { |
428 | 428 | $this->flags = FlagCollection::make([]); |
429 | 429 | |
430 | - foreach($raw_flags as $flag) { |
|
431 | - if (strpos($flag, "\\") === 0){ |
|
430 | + foreach ($raw_flags as $flag) { |
|
431 | + if (strpos($flag, "\\") === 0) { |
|
432 | 432 | $flag = substr($flag, 1); |
433 | 433 | } |
434 | 434 | $flag_key = strtolower($flag); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @throws MessageFlagException |
502 | 502 | * @throws Exceptions\RuntimeException |
503 | 503 | */ |
504 | - public function peek(){ |
|
504 | + public function peek() { |
|
505 | 505 | if ($this->fetch_options == IMAP::FT_PEEK) { |
506 | 506 | if ($this->getFlags()->get("seen") == null) { |
507 | 507 | $this->unsetFlag("Seen"); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | private function fetchPart(Part $part) { |
551 | 551 | if ($part->isAttachment()) { |
552 | 552 | $this->fetchAttachment($part); |
553 | - }else{ |
|
553 | + }else { |
|
554 | 554 | $encoding = $this->getEncoding($part); |
555 | 555 | |
556 | 556 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | if (isset($this->bodies[$subtype])) { |
577 | 577 | $this->bodies[$subtype] .= "\n".$content; |
578 | - }else{ |
|
578 | + }else { |
|
579 | 579 | $this->bodies[$subtype] = $content; |
580 | 580 | } |
581 | 581 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
592 | 592 | if ($oAttachment->getId() !== null) { |
593 | 593 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
594 | - } else { |
|
594 | + }else { |
|
595 | 595 | $this->attachments->push($oAttachment); |
596 | 596 | } |
597 | 597 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | |
726 | 726 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
727 | 727 | return @iconv($from, $to.'//IGNORE', $str); |
728 | - } else { |
|
728 | + }else { |
|
729 | 729 | if (!$from) { |
730 | 730 | return mb_convert_encoding($str, $to); |
731 | 731 | } |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | return EncodingAliases::get($parameter->value, "ISO-8859-2"); |
747 | 747 | } |
748 | 748 | } |
749 | - }elseif (property_exists($structure, 'charset')){ |
|
749 | + }elseif (property_exists($structure, 'charset')) { |
|
750 | 750 | return EncodingAliases::get($structure->charset, "ISO-8859-2"); |
751 | - }elseif (is_string($structure) === true){ |
|
751 | + }elseif (is_string($structure) === true) { |
|
752 | 752 | return mb_detect_encoding($structure); |
753 | 753 | } |
754 | 754 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | * @throws Exceptions\FolderFetchingException |
764 | 764 | * @throws Exceptions\RuntimeException |
765 | 765 | */ |
766 | - public function getFolder(){ |
|
766 | + public function getFolder() { |
|
767 | 767 | return $this->client->getFolderByPath($this->folder_path); |
768 | 768 | } |
769 | 769 | |
@@ -779,13 +779,13 @@ discard block |
||
779 | 779 | * @throws Exceptions\GetMessagesFailedException |
780 | 780 | * @throws Exceptions\RuntimeException |
781 | 781 | */ |
782 | - public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection { |
|
782 | + public function thread(Folder $sent_folder = null, MessageCollection & $thread = null, Folder $folder = null): MessageCollection { |
|
783 | 783 | $thread = $thread ?: MessageCollection::make([]); |
784 | - $folder = $folder ?: $this->getFolder(); |
|
784 | + $folder = $folder ?: $this->getFolder(); |
|
785 | 785 | $sent_folder = $sent_folder ?: $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
786 | 786 | |
787 | 787 | /** @var Message $message */ |
788 | - foreach($thread as $message) { |
|
788 | + foreach ($thread as $message) { |
|
789 | 789 | if ($message->message_id->first() == $this->message_id->first()) { |
790 | 790 | return $thread; |
791 | 791 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
797 | 797 | |
798 | 798 | if (is_array($this->in_reply_to)) { |
799 | - foreach($this->in_reply_to as $in_reply_to) { |
|
799 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
800 | 800 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
801 | 801 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
802 | 802 | } |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | * @throws Exceptions\RuntimeException |
819 | 819 | * @throws Exceptions\FolderFetchingException |
820 | 820 | */ |
821 | - protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){ |
|
821 | + protected function fetchThreadByInReplyTo(MessageCollection & $thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) { |
|
822 | 822 | $primary_folder->query()->inReplyTo($in_reply_to) |
823 | 823 | ->setFetchBody($this->getFetchBodyOption()) |
824 | 824 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @throws Exceptions\RuntimeException |
841 | 841 | * @throws Exceptions\FolderFetchingException |
842 | 842 | */ |
843 | - protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){ |
|
843 | + protected function fetchThreadByMessageId(MessageCollection & $thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) { |
|
844 | 844 | $primary_folder->query()->messageId($message_id) |
845 | 845 | ->setFetchBody($this->getFetchBodyOption()) |
846 | 846 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | 939 | protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message { |
940 | - if($expunge) $this->client->expunge(); |
|
940 | + if ($expunge) $this->client->expunge(); |
|
941 | 941 | |
942 | 942 | $this->client->openFolder($folder->path); |
943 | 943 | |
944 | 944 | if ($this->sequence === IMAP::ST_UID) { |
945 | 945 | $sequence_id = $next_uid; |
946 | - }else{ |
|
946 | + }else { |
|
947 | 947 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 948 | } |
949 | 949 | |
@@ -973,11 +973,11 @@ discard block |
||
973 | 973 | */ |
974 | 974 | public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false) { |
975 | 975 | $status = $this->setFlag("Deleted"); |
976 | - if($force_move) { |
|
977 | - $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path; |
|
976 | + if ($force_move) { |
|
977 | + $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"] : $trash_path; |
|
978 | 978 | $status = $this->move($trash_path); |
979 | 979 | } |
980 | - if($expunge) $this->client->expunge(); |
|
980 | + if ($expunge) $this->client->expunge(); |
|
981 | 981 | |
982 | 982 | $event = $this->getEvent("message", "deleted"); |
983 | 983 | $event::dispatch($this); |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | */ |
998 | 998 | public function restore(bool $expunge = true): bool { |
999 | 999 | $status = $this->unsetFlag("Deleted"); |
1000 | - if($expunge) $this->client->expunge(); |
|
1000 | + if ($expunge) $this->client->expunge(); |
|
1001 | 1001 | |
1002 | 1002 | $event = $this->getEvent("message", "restored"); |
1003 | 1003 | $event::dispatch($this); |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $event = $this->getEvent("flag", "new"); |
1030 | 1030 | $event::dispatch($this, $flag); |
1031 | 1031 | |
1032 | - return (bool)$status; |
|
1032 | + return (bool) $status; |
|
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | /** |
@@ -1057,7 +1057,7 @@ discard block |
||
1057 | 1057 | $event = $this->getEvent("flag", "deleted"); |
1058 | 1058 | $event::dispatch($this, $flag); |
1059 | 1059 | |
1060 | - return (bool)$status; |
|
1060 | + return (bool) $status; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | /** |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return Structure|null |
1211 | 1211 | */ |
1212 | - public function getStructure(){ |
|
1212 | + public function getStructure() { |
|
1213 | 1213 | return $this->structure; |
1214 | 1214 | } |
1215 | 1215 | |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | * @return $this |
1247 | 1247 | */ |
1248 | 1248 | public function setMask($mask): Message { |
1249 | - if(class_exists($mask)){ |
|
1249 | + if (class_exists($mask)) { |
|
1250 | 1250 | $this->mask = $mask; |
1251 | 1251 | } |
1252 | 1252 | |
@@ -1269,9 +1269,9 @@ discard block |
||
1269 | 1269 | * @return mixed |
1270 | 1270 | * @throws MaskNotFoundException |
1271 | 1271 | */ |
1272 | - public function mask($mask = null){ |
|
1272 | + public function mask($mask = null) { |
|
1273 | 1273 | $mask = $mask !== null ? $mask : $this->mask; |
1274 | - if(class_exists($mask)){ |
|
1274 | + if (class_exists($mask)) { |
|
1275 | 1275 | return new $mask($this); |
1276 | 1276 | } |
1277 | 1277 | |
@@ -1421,11 +1421,11 @@ discard block |
||
1421 | 1421 | * @throws Exceptions\ConnectionFailedException |
1422 | 1422 | * @throws Exceptions\MessageNotFoundException |
1423 | 1423 | */ |
1424 | - public function setSequenceId($uid, int $msglist = null){ |
|
1424 | + public function setSequenceId($uid, int $msglist = null) { |
|
1425 | 1425 | if ($this->getSequence() === IMAP::ST_UID) { |
1426 | 1426 | $this->setUid($uid); |
1427 | 1427 | $this->setMsglist($msglist); |
1428 | - }else{ |
|
1428 | + }else { |
|
1429 | 1429 | $this->setMsgn($uid, $msglist); |
1430 | 1430 | } |
1431 | 1431 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $this->setDelimiter($delimiter); |
125 | 125 | $this->path = $folder_name; |
126 | - $this->full_name = $this->decodeName($folder_name); |
|
126 | + $this->full_name = $this->decodeName($folder_name); |
|
127 | 127 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
128 | 128 | |
129 | 129 | $this->parseAttributes($attributes); |
@@ -240,7 +240,7 @@ 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) $this->client->expunge(); |
|
244 | 244 | |
245 | 245 | $folder = $this->client->getFolder($new_name); |
246 | 246 | $event = $this->getEvent("folder", "moved"); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object. |
284 | 284 | */ |
285 | 285 | |
286 | - if ($internal_date instanceof Carbon){ |
|
286 | + if ($internal_date instanceof Carbon) { |
|
287 | 287 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
288 | 288 | } |
289 | 289 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function delete(bool $expunge = true): bool { |
318 | 318 | $status = $this->client->getConnection()->deleteFolder($this->path); |
319 | - if($expunge) $this->client->expunge(); |
|
319 | + if ($expunge) $this->client->expunge(); |
|
320 | 320 | |
321 | 321 | $event = $this->getEvent("folder", "deleted"); |
322 | 322 | $event::dispatch($this); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | |
382 | 382 | if (($pos = strpos($line, "EXISTS")) !== false) { |
383 | 383 | $connection->done(); |
384 | - $msgn = (int) substr($line, 2, $pos -2); |
|
384 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
385 | 385 | |
386 | 386 | $this->client->openFolder($this->path, true); |
387 | 387 | $message = $this->query()->getMessageByMsgn($msgn); |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | $connection->done(); |
396 | 396 | $connection->idle(); |
397 | 397 | } |
398 | - }catch (Exceptions\RuntimeException $e) { |
|
399 | - if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) { |
|
398 | + } catch (Exceptions\RuntimeException $e) { |
|
399 | + if (strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) { |
|
400 | 400 | $connection->done(); |
401 | 401 | $connection->idle(); |
402 | 402 | continue; |
403 | 403 | } |
404 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
404 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
405 | 405 | throw $e; |
406 | 406 | } |
407 | 407 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * Set the delimiter |
450 | 450 | * @param $delimiter |
451 | 451 | */ |
452 | - public function setDelimiter($delimiter){ |
|
453 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
452 | + public function setDelimiter($delimiter) { |
|
453 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
454 | 454 | $delimiter = ClientManager::get('options.delimiter', '/'); |
455 | 455 | } |
456 | 456 |
@@ -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') { |
@@ -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) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | throw new RuntimeException('empty response'); |
113 | 113 | } |
114 | 114 | if ($this->debug) echo "<< ".$line."\n"; |
115 | - return $line . "\n"; |
|
115 | + return $line."\n"; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $stack = []; |
166 | 166 | |
167 | 167 | // replace any trailing <NL> including spaces with a single space |
168 | - $line = rtrim($line) . ' '; |
|
168 | + $line = rtrim($line).' '; |
|
169 | 169 | while (($pos = strpos($line, ' ')) !== false) { |
170 | 170 | $token = substr($line, 0, $pos); |
171 | 171 | if (!strlen($token)) { |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | if (strlen($token) > $chars) { |
196 | 196 | $line = substr($token, $chars); |
197 | 197 | $token = substr($token, 0, $chars); |
198 | - } else { |
|
198 | + }else { |
|
199 | 199 | $line .= $this->nextLine(); |
200 | 200 | } |
201 | 201 | $tokens[] = $token; |
202 | - $line = trim($line) . ' '; |
|
202 | + $line = trim($line).' '; |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $line = $this->nextTaggedLine($tag); // get next tag |
250 | 250 | if (!$dontParse) { |
251 | 251 | $tokens = $this->decodeLine($line); |
252 | - } else { |
|
252 | + }else { |
|
253 | 253 | $tokens = $line; |
254 | 254 | } |
255 | 255 | |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | public function sendRequest(string $command, array $tokens = [], string &$tag = null) { |
300 | 300 | if (!$tag) { |
301 | 301 | $this->noun++; |
302 | - $tag = 'TAG' . $this->noun; |
|
302 | + $tag = 'TAG'.$this->noun; |
|
303 | 303 | } |
304 | 304 | |
305 | - $line = $tag . ' ' . $command; |
|
305 | + $line = $tag.' '.$command; |
|
306 | 306 | |
307 | 307 | foreach ($tokens as $token) { |
308 | 308 | if (is_array($token)) { |
309 | - $this->write($line . ' ' . $token[0]); |
|
309 | + $this->write($line.' '.$token[0]); |
|
310 | 310 | if (!$this->assumedNextLine('+ ')) { |
311 | 311 | throw new RuntimeException('failed to send literal string'); |
312 | 312 | } |
313 | 313 | $line = $token[1]; |
314 | - } else { |
|
315 | - $line .= ' ' . $token; |
|
314 | + }else { |
|
315 | + $line .= ' '.$token; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | $this->write($line); |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | * @throws RuntimeException |
326 | 326 | */ |
327 | 327 | public function write(string $data) { |
328 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
328 | + if ($this->debug) echo ">> ".$data."\n"; |
|
329 | 329 | |
330 | - if (fwrite($this->stream, $data . "\r\n") === false) { |
|
330 | + if (fwrite($this->stream, $data."\r\n") === false) { |
|
331 | 331 | throw new RuntimeException('failed to write - connection closed?'); |
332 | 332 | } |
333 | 333 | } |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | public function escapeString($string) { |
358 | 358 | if (func_num_args() < 2) { |
359 | 359 | if (strpos($string, "\n") !== false) { |
360 | - return ['{' . strlen($string) . '}', $string]; |
|
361 | - } else { |
|
362 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
360 | + return ['{'.strlen($string).'}', $string]; |
|
361 | + }else { |
|
362 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | $result = []; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | $result[] = $this->escapeList($v); |
386 | 386 | } |
387 | - return '(' . implode(' ', $result) . ')'; |
|
387 | + return '('.implode(' ', $result).')'; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | error_log("got an extra server challenge: $response"); |
426 | 426 | // respond with an empty response. |
427 | 427 | $this->sendRequest(''); |
428 | - } else { |
|
428 | + }else { |
|
429 | 429 | if (preg_match('/^NO /i', $response) || |
430 | 430 | preg_match('/^BAD /i', $response)) { |
431 | 431 | error_log("got failure response: $response"); |
432 | 432 | return false; |
433 | - } else if (preg_match("/^OK /i", $response)) { |
|
433 | + }else if (preg_match("/^OK /i", $response)) { |
|
434 | 434 | return true; |
435 | 435 | } |
436 | 436 | } |
@@ -508,16 +508,16 @@ discard block |
||
508 | 508 | switch ($tokens[1]) { |
509 | 509 | case 'EXISTS': |
510 | 510 | case 'RECENT': |
511 | - $result[strtolower($tokens[1])] = (int)$tokens[0]; |
|
511 | + $result[strtolower($tokens[1])] = (int) $tokens[0]; |
|
512 | 512 | break; |
513 | 513 | case '[UIDVALIDITY': |
514 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
514 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
515 | 515 | break; |
516 | 516 | case '[UIDNEXT': |
517 | - $result['uidnext'] = (int)$tokens[2]; |
|
517 | + $result['uidnext'] = (int) $tokens[2]; |
|
518 | 518 | break; |
519 | 519 | case '[UNSEEN': |
520 | - $result['unseen'] = (int)$tokens[2]; |
|
520 | + $result['unseen'] = (int) $tokens[2]; |
|
521 | 521 | break; |
522 | 522 | case '[NONEXISTENT]': |
523 | 523 | throw new RuntimeException("folder doesn't exist"); |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | if (is_array($from)) { |
577 | 577 | $set = implode(',', $from); |
578 | 578 | } elseif ($to === null) { |
579 | - $set = (int)$from; |
|
579 | + $set = (int) $from; |
|
580 | 580 | } elseif ($to === INF) { |
581 | - $set = (int)$from . ':*'; |
|
582 | - } else { |
|
583 | - $set = (int)$from . ':' . (int)$to; |
|
581 | + $set = (int) $from.':*'; |
|
582 | + }else { |
|
583 | + $set = (int) $from.':'.(int) $to; |
|
584 | 584 | } |
585 | 585 | |
586 | - $items = (array)$items; |
|
586 | + $items = (array) $items; |
|
587 | 587 | $itemList = $this->escapeList($items); |
588 | 588 | |
589 | 589 | $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag); |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | $count = count($tokens[2]); |
601 | 601 | if ($tokens[2][$count - 2] == 'UID') { |
602 | 602 | $uidKey = $count - 1; |
603 | - } else if ($tokens[2][0] == 'UID') { |
|
603 | + }else if ($tokens[2][0] == 'UID') { |
|
604 | 604 | $uidKey = 1; |
605 | - } else { |
|
605 | + }else { |
|
606 | 606 | $found = array_search('UID', $tokens[2]); |
607 | 607 | if ($found === false || $found === -1) { |
608 | 608 | continue; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | $data = $tokens[2][1]; |
624 | 624 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
625 | 625 | $data = $tokens[2][3]; |
626 | - } else { |
|
626 | + }else { |
|
627 | 627 | $expectedResponse = 0; |
628 | 628 | // maybe the server send an other field we didn't wanted |
629 | 629 | $count = count($tokens[2]); |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | continue; |
641 | 641 | } |
642 | 642 | } |
643 | - } else { |
|
643 | + }else { |
|
644 | 644 | $data = []; |
645 | 645 | while (key($tokens[2]) !== null) { |
646 | 646 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | } |
658 | 658 | if ($uid) { |
659 | 659 | $result[$tokens[2][$uidKey]] = $data; |
660 | - }else{ |
|
660 | + }else { |
|
661 | 661 | $result[$tokens[0]] = $data; |
662 | 662 | } |
663 | 663 | } |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $ids = $this->getUid(); |
759 | 759 | foreach ($ids as $k => $v) { |
760 | 760 | if ($v == $id) { |
761 | - return (int)$k; |
|
761 | + return (int) $k; |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
816 | 816 | |
817 | 817 | if ($silent) { |
818 | - return (bool)$response; |
|
818 | + return (bool) $response; |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | $result = []; |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool { |
869 | 869 | $set = $this->buildSet($from, $to); |
870 | 870 | $command = $this->buildUIDCommand("COPY", $uid); |
871 | - return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
871 | + return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | /** |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | $set = $this->buildSet($from, $to); |
908 | 908 | $command = $this->buildUIDCommand("MOVE", $uid); |
909 | 909 | |
910 | - return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
910 | + return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * @throws RuntimeException |
960 | 960 | */ |
961 | 961 | public function createFolder(string $folder): bool { |
962 | - return (bool)$this->requestAndResponse('CREATE', [$this->escapeString($folder)], true); |
|
962 | + return (bool) $this->requestAndResponse('CREATE', [$this->escapeString($folder)], true); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | /** |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | * @throws RuntimeException |
972 | 972 | */ |
973 | 973 | public function renameFolder(string $old, string $new): bool { |
974 | - return (bool)$this->requestAndResponse('RENAME', $this->escapeString($old, $new), true); |
|
974 | + return (bool) $this->requestAndResponse('RENAME', $this->escapeString($old, $new), true); |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | * @throws RuntimeException |
983 | 983 | */ |
984 | 984 | public function deleteFolder(string $folder): bool { |
985 | - return (bool)$this->requestAndResponse('DELETE', [$this->escapeString($folder)], true); |
|
985 | + return (bool) $this->requestAndResponse('DELETE', [$this->escapeString($folder)], true); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | /** |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | * @throws RuntimeException |
994 | 994 | */ |
995 | 995 | public function subscribeFolder(string $folder): bool { |
996 | - return (bool)$this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true); |
|
996 | + return (bool) $this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true); |
|
997 | 997 | } |
998 | 998 | |
999 | 999 | /** |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | * @throws RuntimeException |
1005 | 1005 | */ |
1006 | 1006 | public function unsubscribeFolder(string $folder): bool { |
1007 | - return (bool)$this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true); |
|
1007 | + return (bool) $this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true); |
|
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | /** |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | * @throws RuntimeException |
1015 | 1015 | */ |
1016 | 1016 | public function expunge(): bool { |
1017 | - return (bool)$this->requestAndResponse('EXPUNGE'); |
|
1017 | + return (bool) $this->requestAndResponse('EXPUNGE'); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | /** |
@@ -1024,7 +1024,7 @@ discard block |
||
1024 | 1024 | * @throws RuntimeException |
1025 | 1025 | */ |
1026 | 1026 | public function noop(): bool { |
1027 | - return (bool)$this->requestAndResponse('NOOP'); |
|
1027 | + return (bool) $this->requestAndResponse('NOOP'); |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | /** |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | $ids = []; |
1118 | 1118 | foreach ($uids as $msgn => $v) { |
1119 | 1119 | $id = $uid ? $v : $msgn; |
1120 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1120 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1121 | 1121 | $ids[] = $id; |
1122 | 1122 | } |
1123 | 1123 | } |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | /** |
1132 | 1132 | * Enable the debug mode |
1133 | 1133 | */ |
1134 | - public function enableDebug(){ |
|
1134 | + public function enableDebug() { |
|
1135 | 1135 | $this->debug = true; |
1136 | 1136 | } |
1137 | 1137 | |
1138 | 1138 | /** |
1139 | 1139 | * Disable the debug mode |
1140 | 1140 | */ |
1141 | - public function disableDebug(){ |
|
1141 | + public function disableDebug() { |
|
1142 | 1142 | $this->debug = false; |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1150,9 +1150,9 @@ discard block |
||
1150 | 1150 | * @return int|string |
1151 | 1151 | */ |
1152 | 1152 | public function buildSet($from, $to = null) { |
1153 | - $set = (int)$from; |
|
1153 | + $set = (int) $from; |
|
1154 | 1154 | if ($to !== null) { |
1155 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
1155 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
1156 | 1156 | } |
1157 | 1157 | return $set; |
1158 | 1158 | } |