@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | foreach ($criteria as $key => $value) { |
| 138 | 138 | if (is_numeric($key)) { |
| 139 | 139 | $this->where($value); |
| 140 | - }else{ |
|
| 140 | + } else{ |
|
| 141 | 141 | $this->where($key, $value); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -173,7 +173,9 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function orWhere(Closure $closure = null): WhereQuery { |
| 175 | 175 | $this->query->push(['OR']); |
| 176 | - if ($closure !== null) $closure($this); |
|
| 176 | + if ($closure !== null) { |
|
| 177 | + $closure($this); |
|
| 178 | + } |
|
| 177 | 179 | |
| 178 | 180 | return $this; |
| 179 | 181 | } |
@@ -185,7 +187,9 @@ discard block |
||
| 185 | 187 | */ |
| 186 | 188 | public function andWhere(Closure $closure = null): WhereQuery { |
| 187 | 189 | $this->query->push(['AND']); |
| 188 | - if ($closure !== null) $closure($this); |
|
| 190 | + if ($closure !== null) { |
|
| 191 | + $closure($this); |
|
| 192 | + } |
|
| 189 | 193 | |
| 190 | 194 | return $this; |
| 191 | 195 | } |
@@ -91,7 +91,9 @@ discard block |
||
| 91 | 91 | $this->setClient($client); |
| 92 | 92 | |
| 93 | 93 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
| 94 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 94 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
| 95 | + $this->leaveUnread(); |
|
| 96 | + } |
|
| 95 | 97 | |
| 96 | 98 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 97 | 99 | $this->fetch_order = 'desc'; |
@@ -137,7 +139,9 @@ discard block |
||
| 137 | 139 | * @throws MessageSearchValidationException |
| 138 | 140 | */ |
| 139 | 141 | protected function parse_date($date): Carbon { |
| 140 | - if ($date instanceof Carbon) return $date; |
|
| 142 | + if ($date instanceof Carbon) { |
|
| 143 | + return $date; |
|
| 144 | + } |
|
| 141 | 145 | |
| 142 | 146 | try { |
| 143 | 147 | $date = Carbon::parse($date); |
@@ -644,7 +648,9 @@ discard block |
||
| 644 | 648 | * @return $this |
| 645 | 649 | */ |
| 646 | 650 | public function limit(int $limit, int $page = 1): Query { |
| 647 | - if ($page >= 1) $this->page = $page; |
|
| 651 | + if ($page >= 1) { |
|
| 652 | + $this->page = $page; |
|
| 653 | + } |
|
| 648 | 654 | $this->limit = $limit; |
| 649 | 655 | |
| 650 | 656 | return $this; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | if(strtolower(substr($method, 0, 3)) === 'get') { |
| 300 | 300 | $name = Str::snake(substr($method, 3)); |
| 301 | 301 | return $this->get($name); |
| 302 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 302 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 303 | 303 | $name = Str::snake(substr($method, 3)); |
| 304 | 304 | |
| 305 | 305 | if(in_array($name, array_keys($this->attributes))) { |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | if ($this->getFlags()->get("seen") == null) { |
| 506 | 506 | $this->unsetFlag("Seen"); |
| 507 | 507 | } |
| 508 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
| 508 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
| 509 | 509 | $this->setFlag("Seen"); |
| 510 | 510 | } |
| 511 | 511 | } |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | private function fetchPart(Part $part) { |
| 550 | 550 | if ($part->isAttachment()) { |
| 551 | 551 | $this->fetchAttachment($part); |
| 552 | - }else{ |
|
| 552 | + } else{ |
|
| 553 | 553 | $encoding = $this->getEncoding($part); |
| 554 | 554 | |
| 555 | 555 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | if (isset($this->bodies[$subtype])) { |
| 576 | 576 | $this->bodies[$subtype] .= "\n".$content; |
| 577 | - }else{ |
|
| 577 | + } else{ |
|
| 578 | 578 | $this->bodies[$subtype] = $content; |
| 579 | 579 | } |
| 580 | 580 | } |
@@ -745,9 +745,9 @@ discard block |
||
| 745 | 745 | return EncodingAliases::get($parameter->value, "ISO-8859-2"); |
| 746 | 746 | } |
| 747 | 747 | } |
| 748 | - }elseif (property_exists($structure, 'charset')){ |
|
| 748 | + } elseif (property_exists($structure, 'charset')){ |
|
| 749 | 749 | return EncodingAliases::get($structure->charset, "ISO-8859-2"); |
| 750 | - }elseif (is_string($structure) === true){ |
|
| 750 | + } elseif (is_string($structure) === true){ |
|
| 751 | 751 | return mb_detect_encoding($structure); |
| 752 | 752 | } |
| 753 | 753 | |
@@ -936,13 +936,15 @@ discard block |
||
| 936 | 936 | * @throws MessageHeaderFetchingException |
| 937 | 937 | */ |
| 938 | 938 | protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message { |
| 939 | - if($expunge) $this->client->expunge(); |
|
| 939 | + if($expunge) { |
|
| 940 | + $this->client->expunge(); |
|
| 941 | + } |
|
| 940 | 942 | |
| 941 | 943 | $this->client->openFolder($folder->path); |
| 942 | 944 | |
| 943 | 945 | if ($this->sequence === IMAP::ST_UID) { |
| 944 | 946 | $sequence_id = $next_uid; |
| 945 | - }else{ |
|
| 947 | + } else{ |
|
| 946 | 948 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
| 947 | 949 | } |
| 948 | 950 | |
@@ -976,7 +978,9 @@ discard block |
||
| 976 | 978 | $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path; |
| 977 | 979 | $status = $this->move($trash_path); |
| 978 | 980 | } |
| 979 | - if($expunge) $this->client->expunge(); |
|
| 981 | + if($expunge) { |
|
| 982 | + $this->client->expunge(); |
|
| 983 | + } |
|
| 980 | 984 | |
| 981 | 985 | $event = $this->getEvent("message", "deleted"); |
| 982 | 986 | $event::dispatch($this); |
@@ -996,7 +1000,9 @@ discard block |
||
| 996 | 1000 | */ |
| 997 | 1001 | public function restore(bool $expunge = true): bool { |
| 998 | 1002 | $status = $this->unsetFlag("Deleted"); |
| 999 | - if($expunge) $this->client->expunge(); |
|
| 1003 | + if($expunge) { |
|
| 1004 | + $this->client->expunge(); |
|
| 1005 | + } |
|
| 1000 | 1006 | |
| 1001 | 1007 | $event = $this->getEvent("message", "restored"); |
| 1002 | 1008 | $event::dispatch($this); |
@@ -1424,7 +1430,7 @@ discard block |
||
| 1424 | 1430 | if ($this->getSequence() === IMAP::ST_UID) { |
| 1425 | 1431 | $this->setUid($uid); |
| 1426 | 1432 | $this->setMsglist($msglist); |
| 1427 | - }else{ |
|
| 1433 | + } else{ |
|
| 1428 | 1434 | $this->setMsgn($uid, $msglist); |
| 1429 | 1435 | } |
| 1430 | 1436 | } |
@@ -240,7 +240,9 @@ discard block |
||
| 240 | 240 | public function move(string $new_name, bool $expunge = true): bool { |
| 241 | 241 | $this->client->checkConnection(); |
| 242 | 242 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 243 | - if($expunge) $this->client->expunge(); |
|
| 243 | + if($expunge) { |
|
| 244 | + $this->client->expunge(); |
|
| 245 | + } |
|
| 244 | 246 | |
| 245 | 247 | $folder = $this->client->getFolder($new_name); |
| 246 | 248 | $event = $this->getEvent("folder", "moved"); |
@@ -316,7 +318,9 @@ discard block |
||
| 316 | 318 | */ |
| 317 | 319 | public function delete(bool $expunge = true): bool { |
| 318 | 320 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 319 | - if($expunge) $this->client->expunge(); |
|
| 321 | + if($expunge) { |
|
| 322 | + $this->client->expunge(); |
|
| 323 | + } |
|
| 320 | 324 | |
| 321 | 325 | $event = $this->getEvent("folder", "deleted"); |
| 322 | 326 | $event::dispatch($this); |
@@ -395,7 +399,7 @@ discard block |
||
| 395 | 399 | $connection->done(); |
| 396 | 400 | $connection->idle(); |
| 397 | 401 | } |
| 398 | - }catch (Exceptions\RuntimeException $e) { |
|
| 402 | + } catch (Exceptions\RuntimeException $e) { |
|
| 399 | 403 | if(strpos($e->getMessage(), "empty response") >= 0 && $connection->connected()) { |
| 400 | 404 | $connection->done(); |
| 401 | 405 | $connection->idle(); |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | $value = $this->default_account_config[$key]; |
| 215 | 215 | if(isset($config[$key])) { |
| 216 | 216 | $value = $config[$key]; |
| 217 | - }elseif(isset($default_config[$key])) { |
|
| 217 | + } elseif(isset($default_config[$key])) { |
|
| 218 | 218 | $value = $default_config[$key]; |
| 219 | 219 | } |
| 220 | 220 | $this->$key = $value; |
@@ -246,39 +246,39 @@ discard block |
||
| 246 | 246 | if(isset($config['masks']['message'])) { |
| 247 | 247 | if(class_exists($config['masks']['message'])) { |
| 248 | 248 | $this->default_message_mask = $config['masks']['message']; |
| 249 | - }else{ |
|
| 249 | + } else{ |
|
| 250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 251 | 251 | } |
| 252 | - }else{ |
|
| 252 | + } else{ |
|
| 253 | 253 | if(class_exists($default_config['message'])) { |
| 254 | 254 | $this->default_message_mask = $default_config['message']; |
| 255 | - }else{ |
|
| 255 | + } else{ |
|
| 256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | if(isset($config['masks']['attachment'])) { |
| 260 | 260 | if(class_exists($config['masks']['attachment'])) { |
| 261 | 261 | $this->default_attachment_mask = $config['masks']['attachment']; |
| 262 | - }else{ |
|
| 262 | + } else{ |
|
| 263 | 263 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 264 | 264 | } |
| 265 | - }else{ |
|
| 265 | + } else{ |
|
| 266 | 266 | if(class_exists($default_config['attachment'])) { |
| 267 | 267 | $this->default_attachment_mask = $default_config['attachment']; |
| 268 | - }else{ |
|
| 268 | + } else{ |
|
| 269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | - }else{ |
|
| 272 | + } else{ |
|
| 273 | 273 | if(class_exists($default_config['message'])) { |
| 274 | 274 | $this->default_message_mask = $default_config['message']; |
| 275 | - }else{ |
|
| 275 | + } else{ |
|
| 276 | 276 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | if(class_exists($default_config['attachment'])) { |
| 280 | 280 | $this->default_attachment_mask = $default_config['attachment']; |
| 281 | - }else{ |
|
| 281 | + } else{ |
|
| 282 | 282 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
| 343 | 343 | $this->connection->setConnectionTimeout($this->timeout); |
| 344 | 344 | $this->connection->setProxy($this->proxy); |
| 345 | - }else{ |
|
| 345 | + } else{ |
|
| 346 | 346 | if (extension_loaded('imap') === false) { |
| 347 | 347 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 348 | 348 | } |
@@ -490,7 +490,7 @@ discard block |
||
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | return $folders; |
| 493 | - }else{ |
|
| 493 | + } else{ |
|
| 494 | 494 | throw new FolderFetchingException("failed to fetch any folders"); |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | return $folders; |
| 533 | - }else{ |
|
| 533 | + } else{ |
|
| 534 | 534 | throw new FolderFetchingException("failed to fetch any folders"); |
| 535 | 535 | } |
| 536 | 536 | } |
@@ -568,7 +568,9 @@ discard block |
||
| 568 | 568 | $this->checkConnection(); |
| 569 | 569 | $status = $this->connection->createFolder($folder); |
| 570 | 570 | |
| 571 | - if($expunge) $this->expunge(); |
|
| 571 | + if($expunge) { |
|
| 572 | + $this->expunge(); |
|
| 573 | + } |
|
| 572 | 574 | |
| 573 | 575 | $folder = $this->getFolderByPath($folder); |
| 574 | 576 | if($status && $folder) { |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
| 91 | 91 | if($content_type && stripos($content_type, 'multipart') === 0) { |
| 92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | return null; |
| 131 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 131 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 132 | 132 | $name = Str::snake(substr($method, 3)); |
| 133 | 133 | |
| 134 | 134 | $this->attributes[$name] = array_pop($arguments); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if (($id = $this->part->id) !== null) { |
| 215 | 215 | $this->id = str_replace(['<', '>'], '', $id); |
| 216 | - }else{ |
|
| 216 | + } else{ |
|
| 217 | 217 | $this->id = hash("sha256", (string)microtime(true)); |
| 218 | 218 | } |
| 219 | 219 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $this->setName($filename); |
| 225 | 225 | } elseif (($name = $this->part->name) !== null) { |
| 226 | 226 | $this->setName($name); |
| 227 | - }else { |
|
| 227 | + } else { |
|
| 228 | 228 | $this->setName("undefined"); |
| 229 | 229 | } |
| 230 | 230 | |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | if ($name !== null) { |
| 260 | 260 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
| 261 | 261 | $this->name = \imap_utf8($name); |
| 262 | - }else{ |
|
| 262 | + } else{ |
|
| 263 | 263 | $this->name = mb_decode_mimeheader($name); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -117,7 +117,9 @@ discard block |
||
| 117 | 117 | if ($line === "" && $next_char === false) { |
| 118 | 118 | throw new RuntimeException('empty response'); |
| 119 | 119 | } |
| 120 | - if ($this->debug) echo "<< ".$line."\n"; |
|
| 120 | + if ($this->debug) { |
|
| 121 | + echo "<< ".$line."\n"; |
|
| 122 | + } |
|
| 121 | 123 | return $line . "\n"; |
| 122 | 124 | } |
| 123 | 125 | |
@@ -336,7 +338,9 @@ discard block |
||
| 336 | 338 | * @throws RuntimeException |
| 337 | 339 | */ |
| 338 | 340 | public function write(string $data) { |
| 339 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
| 341 | + if ($this->debug) { |
|
| 342 | + echo ">> ".$data ."\n"; |
|
| 343 | + } |
|
| 340 | 344 | |
| 341 | 345 | if (fwrite($this->stream, $data . "\r\n") === false) { |
| 342 | 346 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -504,7 +508,9 @@ discard block |
||
| 504 | 508 | public function getCapabilities(): array { |
| 505 | 509 | $response = $this->requestAndResponse('CAPABILITY'); |
| 506 | 510 | |
| 507 | - if (!$response) return []; |
|
| 511 | + if (!$response) { |
|
| 512 | + return []; |
|
| 513 | + } |
|
| 508 | 514 | |
| 509 | 515 | $capabilities = []; |
| 510 | 516 | foreach ($response as $line) { |
@@ -678,13 +684,14 @@ discard block |
||
| 678 | 684 | // if we want only one message we can ignore everything else and just return |
| 679 | 685 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 680 | 686 | // we still need to read all lines |
| 681 | - while (!$this->readLine($tokens, $tag)) |
|
| 682 | - |
|
| 687 | + while (!$this->readLine($tokens, $tag)) { |
|
| 688 | + |
|
| 683 | 689 | return $data; |
| 690 | + } |
|
| 684 | 691 | } |
| 685 | 692 | if ($uid) { |
| 686 | 693 | $result[$tokens[2][$uidKey]] = $data; |
| 687 | - }else{ |
|
| 694 | + } else{ |
|
| 688 | 695 | $result[$tokens[0]] = $data; |
| 689 | 696 | } |
| 690 | 697 | } |