@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | $value = $this->default_account_config[$key]; |
| 214 | 214 | if(isset($config[$key])) { |
| 215 | 215 | $value = $config[$key]; |
| 216 | - }elseif(isset($default_config[$key])) { |
|
| 216 | + } elseif(isset($default_config[$key])) { |
|
| 217 | 217 | $value = $default_config[$key]; |
| 218 | 218 | } |
| 219 | 219 | $this->$key = $value; |
@@ -247,39 +247,39 @@ discard block |
||
| 247 | 247 | if(isset($config['masks']['message'])) { |
| 248 | 248 | if(class_exists($config['masks']['message'])) { |
| 249 | 249 | $this->default_message_mask = $config['masks']['message']; |
| 250 | - }else{ |
|
| 250 | + } else{ |
|
| 251 | 251 | throw new MaskNotFoundException("Unknown mask provided: " . $config['masks']['message']); |
| 252 | 252 | } |
| 253 | - }else{ |
|
| 253 | + } else{ |
|
| 254 | 254 | if(class_exists($default_config['message'])) { |
| 255 | 255 | $this->default_message_mask = $default_config['message']; |
| 256 | - }else{ |
|
| 256 | + } else{ |
|
| 257 | 257 | throw new MaskNotFoundException("Unknown mask provided: " . $default_config['message']); |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | if(isset($config['masks']['attachment'])) { |
| 261 | 261 | if(class_exists($config['masks']['attachment'])) { |
| 262 | 262 | $this->default_attachment_mask = $config['masks']['attachment']; |
| 263 | - }else{ |
|
| 263 | + } else{ |
|
| 264 | 264 | throw new MaskNotFoundException("Unknown mask provided: " . $config['masks']['attachment']); |
| 265 | 265 | } |
| 266 | - }else{ |
|
| 266 | + } else{ |
|
| 267 | 267 | if(class_exists($default_config['attachment'])) { |
| 268 | 268 | $this->default_attachment_mask = $default_config['attachment']; |
| 269 | - }else{ |
|
| 269 | + } else{ |
|
| 270 | 270 | throw new MaskNotFoundException("Unknown mask provided: " . $default_config['attachment']); |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | - }else{ |
|
| 273 | + } else{ |
|
| 274 | 274 | if(class_exists($default_config['message'])) { |
| 275 | 275 | $this->default_message_mask = $default_config['message']; |
| 276 | - }else{ |
|
| 276 | + } else{ |
|
| 277 | 277 | throw new MaskNotFoundException("Unknown mask provided: " . $default_config['message']); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | if(class_exists($default_config['attachment'])) { |
| 281 | 281 | $this->default_attachment_mask = $default_config['attachment']; |
| 282 | - }else{ |
|
| 282 | + } else{ |
|
| 283 | 283 | throw new MaskNotFoundException("Unknown mask provided: " . $default_config['attachment']); |
| 284 | 284 | } |
| 285 | 285 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
| 348 | 348 | $this->connection->setConnectionTimeout($this->timeout); |
| 349 | 349 | $this->connection->setProxy($this->proxy); |
| 350 | - }else{ |
|
| 350 | + } else{ |
|
| 351 | 351 | if (extension_loaded('imap') === false) { |
| 352 | 352 | throw new ConnectionFailedException("connection setup failed - no imap function", 0, new ProtocolNotSupportedException($protocol . " is an unsupported protocol")); |
| 353 | 353 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | return $folders; |
| 497 | - }else{ |
|
| 497 | + } else{ |
|
| 498 | 498 | throw new FolderFetchingException("failed to fetch any folders"); |
| 499 | 499 | } |
| 500 | 500 | } |
@@ -534,7 +534,9 @@ discard block |
||
| 534 | 534 | $this->checkConnection(); |
| 535 | 535 | $status = $this->connection->createFolder($folder); |
| 536 | 536 | |
| 537 | - if($expunge) $this->expunge(); |
|
| 537 | + if($expunge) { |
|
| 538 | + $this->expunge(); |
|
| 539 | + } |
|
| 538 | 540 | |
| 539 | 541 | $folder = $this->getFolder($folder); |
| 540 | 542 | if($status && $folder) { |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | // so add them back in manually if we can |
| 75 | 75 | if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { |
| 76 | 76 | $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; |
| 77 | - }elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) { |
|
| 77 | + } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT')) { |
|
| 78 | 78 | $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; |
| 79 | 79 | } |
| 80 | 80 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $name = $this->decodeFolderName($item->name); |
| 343 | 343 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 344 | 344 | } |
| 345 | - }else{ |
|
| 345 | + } else{ |
|
| 346 | 346 | throw new RuntimeException(\imap_last_error()); |
| 347 | 347 | } |
| 348 | 348 | |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | if ($mode == "+"){ |
| 369 | 369 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 370 | - }else{ |
|
| 370 | + } else{ |
|
| 371 | 371 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
| 372 | 372 | } |
| 373 | 373 | |
@@ -247,7 +247,9 @@ discard block |
||
| 247 | 247 | } else { |
| 248 | 248 | $tokens = $line; |
| 249 | 249 | } |
| 250 | - if ($this->debug) echo "<< " . $line . "\n"; |
|
| 250 | + if ($this->debug) { |
|
| 251 | + echo "<< " . $line . "\n"; |
|
| 252 | + } |
|
| 251 | 253 | |
| 252 | 254 | // if tag is wanted tag we might be at the end of a multiline response |
| 253 | 255 | return $tag == $wantedTag; |
@@ -315,7 +317,9 @@ discard block |
||
| 315 | 317 | $line .= ' ' . $token; |
| 316 | 318 | } |
| 317 | 319 | } |
| 318 | - if ($this->debug) echo ">> " . $line . "\n"; |
|
| 320 | + if ($this->debug) { |
|
| 321 | + echo ">> " . $line . "\n"; |
|
| 322 | + } |
|
| 319 | 323 | |
| 320 | 324 | if (fwrite($this->stream, $line . "\r\n") === false) { |
| 321 | 325 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -476,7 +480,9 @@ discard block |
||
| 476 | 480 | { |
| 477 | 481 | $response = $this->requestAndResponse('CAPABILITY'); |
| 478 | 482 | |
| 479 | - if (!$response) return []; |
|
| 483 | + if (!$response) { |
|
| 484 | + return []; |
|
| 485 | + } |
|
| 480 | 486 | |
| 481 | 487 | $capabilities = []; |
| 482 | 488 | foreach ($response as $line) { |
@@ -637,13 +643,14 @@ discard block |
||
| 637 | 643 | // if we want only one message we can ignore everything else and just return |
| 638 | 644 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 639 | 645 | // we still need to read all lines |
| 640 | - while (!$this->readLine($tokens, $tag)) |
|
| 641 | - |
|
| 646 | + while (!$this->readLine($tokens, $tag)) { |
|
| 647 | + |
|
| 642 | 648 | return $data; |
| 649 | + } |
|
| 643 | 650 | } |
| 644 | 651 | if ($uid) { |
| 645 | 652 | $result[$tokens[2][$uidKey]] = $data; |
| 646 | - }else{ |
|
| 653 | + } else{ |
|
| 647 | 654 | $result[$tokens[0]] = $data; |
| 648 | 655 | } |
| 649 | 656 | } |
@@ -164,7 +164,7 @@ |
||
| 164 | 164 | { |
| 165 | 165 | if ($this->header === null) { |
| 166 | 166 | $body = $this->findHeaders(); |
| 167 | - }else{ |
|
| 167 | + } else{ |
|
| 168 | 168 | $body = $this->raw; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | if(strtolower(substr($method, 0, 3)) === 'get') { |
| 307 | 307 | $name = Str::snake(substr($method, 3)); |
| 308 | 308 | return $this->get($name); |
| 309 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 309 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 310 | 310 | $name = Str::snake(substr($method, 3)); |
| 311 | 311 | |
| 312 | 312 | if(in_array($name, array_keys($this->attributes))) { |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | if ($this->getFlags()->get("seen") == null) { |
| 525 | 525 | $this->unsetFlag("Seen"); |
| 526 | 526 | } |
| 527 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
| 527 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
| 528 | 528 | $this->setFlag("Seen"); |
| 529 | 529 | } |
| 530 | 530 | } |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | { |
| 572 | 572 | if ($part->isAttachment()) { |
| 573 | 573 | $this->fetchAttachment($part); |
| 574 | - }else{ |
|
| 574 | + } else{ |
|
| 575 | 575 | $encoding = $this->getEncoding($part); |
| 576 | 576 | |
| 577 | 577 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | if (isset($this->bodies[$subtype])) { |
| 598 | 598 | $this->bodies[$subtype] .= "\n" . $content; |
| 599 | - }else{ |
|
| 599 | + } else{ |
|
| 600 | 600 | $this->bodies[$subtype] = $content; |
| 601 | 601 | } |
| 602 | 602 | } |
@@ -775,9 +775,9 @@ discard block |
||
| 775 | 775 | return EncodingAliases::get($parameter->value); |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | - }elseif (property_exists($structure, 'charset')){ |
|
| 778 | + } elseif (property_exists($structure, 'charset')){ |
|
| 779 | 779 | return EncodingAliases::get($structure->charset); |
| 780 | - }elseif (is_string($structure) === true){ |
|
| 780 | + } elseif (is_string($structure) === true){ |
|
| 781 | 781 | return mb_detect_encoding($structure); |
| 782 | 782 | } |
| 783 | 783 | |
@@ -971,13 +971,15 @@ discard block |
||
| 971 | 971 | */ |
| 972 | 972 | protected function fetchNewMail($folder, $next_uid, $event, $expunge) |
| 973 | 973 | { |
| 974 | - if($expunge) $this->client->expunge(); |
|
| 974 | + if($expunge) { |
|
| 975 | + $this->client->expunge(); |
|
| 976 | + } |
|
| 975 | 977 | |
| 976 | 978 | $this->client->openFolder($folder->path); |
| 977 | 979 | |
| 978 | 980 | if ($this->sequence === IMAP::ST_UID) { |
| 979 | 981 | $sequence_id = $next_uid; |
| 980 | - }else{ |
|
| 982 | + } else{ |
|
| 981 | 983 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
| 982 | 984 | } |
| 983 | 985 | |
@@ -1001,7 +1003,9 @@ discard block |
||
| 1001 | 1003 | public function delete($expunge = true) |
| 1002 | 1004 | { |
| 1003 | 1005 | $status = $this->setFlag("Deleted"); |
| 1004 | - if($expunge) $this->client->expunge(); |
|
| 1006 | + if($expunge) { |
|
| 1007 | + $this->client->expunge(); |
|
| 1008 | + } |
|
| 1005 | 1009 | |
| 1006 | 1010 | $event = $this->getEvent("message", "deleted"); |
| 1007 | 1011 | $event::dispatch($this); |
@@ -1022,7 +1026,9 @@ discard block |
||
| 1022 | 1026 | public function restore($expunge = true) |
| 1023 | 1027 | { |
| 1024 | 1028 | $status = $this->unsetFlag("Deleted"); |
| 1025 | - if($expunge) $this->client->expunge(); |
|
| 1029 | + if($expunge) { |
|
| 1030 | + $this->client->expunge(); |
|
| 1031 | + } |
|
| 1026 | 1032 | |
| 1027 | 1033 | $event = $this->getEvent("message", "restored"); |
| 1028 | 1034 | $event::dispatch($this); |
@@ -1484,7 +1490,7 @@ discard block |
||
| 1484 | 1490 | if ($this->getSequence() === IMAP::ST_UID) { |
| 1485 | 1491 | $this->setUid($uid); |
| 1486 | 1492 | $this->setMsglist($msglist); |
| 1487 | - }else{ |
|
| 1493 | + } else{ |
|
| 1488 | 1494 | $this->setMsgn($uid, $msglist); |
| 1489 | 1495 | } |
| 1490 | 1496 | } |
@@ -93,7 +93,9 @@ discard block |
||
| 93 | 93 | public function toDate() |
| 94 | 94 | { |
| 95 | 95 | $date = $this->first(); |
| 96 | - if ($date instanceof Carbon) return $date; |
|
| 96 | + if ($date instanceof Carbon) { |
|
| 97 | + return $date; |
|
| 98 | + } |
|
| 97 | 99 | |
| 98 | 100 | return Carbon::parse($date); |
| 99 | 101 | } |
@@ -158,7 +160,7 @@ discard block |
||
| 158 | 160 | { |
| 159 | 161 | if (is_array($value)) { |
| 160 | 162 | return $this->merge($value, $strict); |
| 161 | - }elseif ($value !== null) { |
|
| 163 | + } elseif ($value !== null) { |
|
| 162 | 164 | $this->attach($value, $strict); |
| 163 | 165 | } |
| 164 | 166 | |
@@ -210,7 +212,7 @@ discard block |
||
| 210 | 212 | if ($this->contains($value) === false) { |
| 211 | 213 | $this->values[] = $value; |
| 212 | 214 | } |
| 213 | - }else{ |
|
| 215 | + } else{ |
|
| 214 | 216 | $this->values[] = $value; |
| 215 | 217 | } |
| 216 | 218 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | foreach ($criteria as $key => $value) { |
| 143 | 143 | if (is_numeric($key)) { |
| 144 | 144 | $this->where($value); |
| 145 | - }else{ |
|
| 145 | + } else{ |
|
| 146 | 146 | $this->where($key, $value); |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -180,7 +180,9 @@ discard block |
||
| 180 | 180 | public function orWhere(Closure $closure = null) |
| 181 | 181 | { |
| 182 | 182 | $this->query->push(['OR']); |
| 183 | - if ($closure !== null) $closure($this); |
|
| 183 | + if ($closure !== null) { |
|
| 184 | + $closure($this); |
|
| 185 | + } |
|
| 184 | 186 | |
| 185 | 187 | return $this; |
| 186 | 188 | } |
@@ -193,7 +195,9 @@ discard block |
||
| 193 | 195 | public function andWhere(Closure $closure = null) |
| 194 | 196 | { |
| 195 | 197 | $this->query->push(['AND']); |
| 196 | - if ($closure !== null) $closure($this); |
|
| 198 | + if ($closure !== null) { |
|
| 199 | + $closure($this); |
|
| 200 | + } |
|
| 197 | 201 | |
| 198 | 202 | return $this; |
| 199 | 203 | } |
@@ -93,7 +93,9 @@ discard block |
||
| 93 | 93 | $this->setClient($client); |
| 94 | 94 | |
| 95 | 95 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
| 96 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 96 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
| 97 | + $this->leaveUnread(); |
|
| 98 | + } |
|
| 97 | 99 | |
| 98 | 100 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 99 | 101 | $this->fetch_order = 'desc'; |
@@ -142,7 +144,9 @@ discard block |
||
| 142 | 144 | */ |
| 143 | 145 | protected function parse_date($date) |
| 144 | 146 | { |
| 145 | - if ($date instanceof Carbon) return $date; |
|
| 147 | + if ($date instanceof Carbon) { |
|
| 148 | + return $date; |
|
| 149 | + } |
|
| 146 | 150 | |
| 147 | 151 | try { |
| 148 | 152 | $date = Carbon::parse($date); |
@@ -259,15 +263,15 @@ discard block |
||
| 259 | 263 | { |
| 260 | 264 | try { |
| 261 | 265 | return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence); |
| 262 | - }catch (MessageNotFoundException $e) { |
|
| 266 | + } catch (MessageNotFoundException $e) { |
|
| 263 | 267 | $this->setError($uid, $e); |
| 264 | - }catch (RuntimeException $e) { |
|
| 268 | + } catch (RuntimeException $e) { |
|
| 265 | 269 | $this->setError($uid, $e); |
| 266 | - }catch (MessageFlagException $e) { |
|
| 270 | + } catch (MessageFlagException $e) { |
|
| 267 | 271 | $this->setError($uid, $e); |
| 268 | - }catch (InvalidMessageDateException $e) { |
|
| 272 | + } catch (InvalidMessageDateException $e) { |
|
| 269 | 273 | $this->setError($uid, $e); |
| 270 | - }catch (MessageContentFetchingException $e) { |
|
| 274 | + } catch (MessageContentFetchingException $e) { |
|
| 271 | 275 | $this->setError($uid, $e); |
| 272 | 276 | } |
| 273 | 277 | |
@@ -533,7 +537,9 @@ discard block |
||
| 533 | 537 | */ |
| 534 | 538 | public function limit($limit, $page = 1) |
| 535 | 539 | { |
| 536 | - if ($page >= 1) $this->page = $page; |
|
| 540 | + if ($page >= 1) { |
|
| 541 | + $this->page = $page; |
|
| 542 | + } |
|
| 537 | 543 | $this->limit = $limit; |
| 538 | 544 | |
| 539 | 545 | return $this; |