@@ -16,7 +16,7 @@ |
||
| 16 | 16 | * New custom method which can be called through a mask |
| 17 | 17 | * @return string |
| 18 | 18 | */ |
| 19 | - public function my_token(){ |
|
| 19 | + public function my_token() { |
|
| 20 | 20 | return implode('-', [$this->message_id, $this->uid, $this->message_no]); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -69,7 +69,9 @@ discard block |
||
| 69 | 69 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 70 | 70 | $this->setClient($client); |
| 71 | 71 | |
| 72 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 72 | + if(config('imap.options.fetch') === IMAP::FT_PEEK) { |
|
| 73 | + $this->leaveUnread(); |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | $this->date_format = config('imap.date_format', 'd M y'); |
| 75 | 77 | |
@@ -107,7 +109,9 @@ discard block |
||
| 107 | 109 | * @throws MessageSearchValidationException |
| 108 | 110 | */ |
| 109 | 111 | protected function parse_date($date) { |
| 110 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 112 | + if($date instanceof \Carbon\Carbon) { |
|
| 113 | + return $date; |
|
| 114 | + } |
|
| 111 | 115 | |
| 112 | 116 | try { |
| 113 | 117 | $date = Carbon::parse($date); |
@@ -159,7 +163,7 @@ discard block |
||
| 159 | 163 | try { |
| 160 | 164 | if ($this->getCharset() == null) { |
| 161 | 165 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
| 162 | - }else{ |
|
| 166 | + } else{ |
|
| 163 | 167 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
| 164 | 168 | } |
| 165 | 169 | } catch (\Exception $e) { |
@@ -300,7 +304,7 @@ discard block |
||
| 300 | 304 | } else { |
| 301 | 305 | if($statement[1] === null){ |
| 302 | 306 | $query .= $statement[0]; |
| 303 | - }else{ |
|
| 307 | + } else{ |
|
| 304 | 308 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 305 | 309 | } |
| 306 | 310 | } |
@@ -330,7 +334,9 @@ discard block |
||
| 330 | 334 | * @return $this |
| 331 | 335 | */ |
| 332 | 336 | public function limit($limit, $page = 1) { |
| 333 | - if($page >= 1) $this->page = $page; |
|
| 337 | + if($page >= 1) { |
|
| 338 | + $this->page = $page; |
|
| 339 | + } |
|
| 334 | 340 | $this->limit = $limit; |
| 335 | 341 | |
| 336 | 342 | return $this; |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 70 | 70 | $this->setClient($client); |
| 71 | 71 | |
| 72 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 72 | + if (config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 73 | 73 | |
| 74 | 74 | $this->date_format = config('imap.date_format', 'd M y'); |
| 75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * Instance boot method for additional functionality |
| 83 | 83 | */ |
| 84 | - protected function boot(){} |
|
| 84 | + protected function boot() {} |
|
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | 87 | * Parse a given value |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | - protected function parse_value($value){ |
|
| 93 | - switch(true){ |
|
| 92 | + protected function parse_value($value) { |
|
| 93 | + switch (true) { |
|
| 94 | 94 | case $value instanceof \Carbon\Carbon: |
| 95 | 95 | $value = $value->format($this->date_format); |
| 96 | 96 | break; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @throws MessageSearchValidationException |
| 108 | 108 | */ |
| 109 | 109 | protected function parse_date($date) { |
| 110 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 110 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
| 111 | 111 | |
| 112 | 112 | try { |
| 113 | 113 | $date = Carbon::parse($date); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @return \Illuminate\Support\Collection |
| 147 | 147 | * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException |
| 148 | 148 | */ |
| 149 | - protected function search(){ |
|
| 149 | + protected function search() { |
|
| 150 | 150 | $this->generate_query(); |
| 151 | 151 | $available_messages = []; |
| 152 | 152 | |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | try { |
| 160 | 160 | if ($this->getCharset() == null) { |
| 161 | 161 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
| 162 | - }else{ |
|
| 162 | + } else { |
|
| 163 | 163 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
| 164 | 164 | } |
| 165 | 165 | } catch (\Exception $e) { |
| 166 | 166 | if (strpos($e, ' [BADCHARSET (')) { |
| 167 | 167 | preg_match('/ \[BADCHARSET \((.*)\)\]/', $e, $matches); |
| 168 | 168 | if (isset($matches[1])) { |
| 169 | - if ($matches[1] !== $this->getCharset()){ |
|
| 169 | + if ($matches[1] !== $this->getCharset()) { |
|
| 170 | 170 | $this->setCharset($matches[1]); |
| 171 | 171 | return $this->search(); |
| 172 | 172 | } |
@@ -210,15 +210,15 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | $options = config('imap.options'); |
| 212 | 212 | |
| 213 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
| 213 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
| 214 | 214 | $available_messages = $available_messages->reverse(); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - $query =& $this; |
|
| 217 | + $query = & $this; |
|
| 218 | 218 | |
| 219 | 219 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
| 220 | 220 | $oMessage = new Message($msgno, $msglist, $query->getClient(), $query->getFetchOptions(), $query->getFetchBody(), $query->getFetchAttachment(), $query->getFetchFlags()); |
| 221 | - switch ($options['message_key']){ |
|
| 221 | + switch ($options['message_key']) { |
|
| 222 | 222 | case 'number': |
| 223 | 223 | $message_key = $oMessage->getMessageNo(); |
| 224 | 224 | break; |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @return \Illuminate\Pagination\LengthAwarePaginator |
| 250 | 250 | * @throws GetMessagesFailedException |
| 251 | 251 | */ |
| 252 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
| 252 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
| 253 | 253 | $this->page = $page > $this->page ? $page : $this->page; |
| 254 | 254 | $this->limit = $per_page; |
| 255 | 255 | |
@@ -264,13 +264,13 @@ discard block |
||
| 264 | 264 | * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException |
| 265 | 265 | * @throws \Webklex\IMAP\Exceptions\InvalidMessageDateException |
| 266 | 266 | */ |
| 267 | - public function idle(callable $callback = null, $timeout = 10){ |
|
| 267 | + public function idle(callable $callback = null, $timeout = 10) { |
|
| 268 | 268 | $known_messages = []; |
| 269 | 269 | $this->getClient()->overview()->each(function($message) use(&$known_messages){ |
| 270 | 270 | /** @var object $message */ |
| 271 | 271 | $known_messages[] = $message->uid; |
| 272 | 272 | }); |
| 273 | - while ($this->getClient()->isConnected()){ |
|
| 273 | + while ($this->getClient()->isConnected()) { |
|
| 274 | 274 | $this->getClient()->expunge(); |
| 275 | 275 | $new_messages = []; |
| 276 | 276 | $this->getClient()->overview()->each(function($message) use(&$new_messages, &$known_messages){ |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | }); |
| 283 | 283 | |
| 284 | - foreach($new_messages as $msg) { |
|
| 284 | + foreach ($new_messages as $msg) { |
|
| 285 | 285 | $message = new Message($msg->uid, $msg->msgno, $this->getClient()); |
| 286 | 286 | MessageNewEvent::dispatch($message); |
| 287 | - if ($callback){ |
|
| 287 | + if ($callback) { |
|
| 288 | 288 | $callback($message); |
| 289 | 289 | } |
| 290 | 290 | } |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | if (count($statement) == 1) { |
| 305 | 305 | $query .= $statement[0]; |
| 306 | 306 | } else { |
| 307 | - if($statement[1] === null){ |
|
| 307 | + if ($statement[1] === null) { |
|
| 308 | 308 | $query .= $statement[0]; |
| 309 | - }else{ |
|
| 309 | + } else { |
|
| 310 | 310 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @return $this |
| 337 | 337 | */ |
| 338 | 338 | public function limit($limit, $page = 1) { |
| 339 | - if($page >= 1) $this->page = $page; |
|
| 339 | + if ($page >= 1) $this->page = $page; |
|
| 340 | 340 | $this->limit = $limit; |
| 341 | 341 | |
| 342 | 342 | return $this; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = null, $fetch_attachment = null, $fetch_flags = null) { |
| 201 | 201 | |
| 202 | 202 | $default_mask = $client->getDefaultMessageMask(); |
| 203 | - if($default_mask != null) { |
|
| 203 | + if ($default_mask != null) { |
|
| 204 | 204 | $this->mask = $default_mask; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $this->msglist = $msglist; |
| 220 | 220 | $this->client = $client; |
| 221 | 221 | |
| 222 | - $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid; |
|
| 222 | + $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid; |
|
| 223 | 223 | $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? \imap_msgno($this->client->getConnection(), $uid) : $uid; |
| 224 | 224 | |
| 225 | 225 | $this->parseHeader(); |
@@ -242,17 +242,17 @@ discard block |
||
| 242 | 242 | * @throws MethodNotFoundException |
| 243 | 243 | */ |
| 244 | 244 | public function __call($method, $arguments) { |
| 245 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 245 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 246 | 246 | $name = Str::snake(substr($method, 3)); |
| 247 | 247 | |
| 248 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 248 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 249 | 249 | return $this->attributes[$name]; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 253 | 253 | $name = Str::snake(substr($method, 3)); |
| 254 | 254 | |
| 255 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 255 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 256 | 256 | $this->attributes[$name] = array_pop($arguments); |
| 257 | 257 | |
| 258 | 258 | return $this->attributes[$name]; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * @return mixed|null |
| 282 | 282 | */ |
| 283 | 283 | public function __get($name) { |
| 284 | - if(isset($this->attributes[$name])) { |
|
| 284 | + if (isset($this->attributes[$name])) { |
|
| 285 | 285 | return $this->attributes[$name]; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -377,16 +377,16 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if (property_exists($header, 'subject')) { |
| 380 | - if($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 380 | + if ($this->config['decoder']['message']['subject'] === 'utf-8') { |
|
| 381 | 381 | $this->subject = \imap_utf8($header->subject); |
| 382 | - }elseif($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 382 | + }elseif ($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 383 | 383 | $this->subject = iconv_mime_decode($header->subject); |
| 384 | - }else{ |
|
| 384 | + } else { |
|
| 385 | 385 | $this->subject = mb_decode_mimeheader($header->subject); |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){ |
|
| 389 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) { |
|
| 390 | 390 | $this->extractHeaderAddressPart($header, $part); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -416,9 +416,9 @@ discard block |
||
| 416 | 416 | * @return int|null |
| 417 | 417 | */ |
| 418 | 418 | private function extractPriority($header) { |
| 419 | - if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){ |
|
| 419 | + if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) { |
|
| 420 | 420 | $priority = isset($priority[1]) ? (int) $priority[1] : 0; |
| 421 | - switch($priority){ |
|
| 421 | + switch ($priority) { |
|
| 422 | 422 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 423 | 423 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 424 | 424 | break; |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | if (property_exists($header, 'date')) { |
| 470 | 470 | $date = $header->date; |
| 471 | 471 | |
| 472 | - if(preg_match('/\+0580/', $date)) { |
|
| 472 | + if (preg_match('/\+0580/', $date)) { |
|
| 473 | 473 | $date = str_replace('+0580', '+0530', $date); |
| 474 | 474 | } |
| 475 | 475 | |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | $date = trim(array_pop($array)); |
| 493 | 493 | break; |
| 494 | 494 | } |
| 495 | - try{ |
|
| 495 | + try { |
|
| 496 | 496 | $parsed_date = Carbon::parse($date); |
| 497 | 497 | } catch (\Exception $_e) { |
| 498 | 498 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e); |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | $this->client->openFolder($this->folder_path); |
| 516 | 516 | $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 517 | 517 | if (is_array($flags) && isset($flags[0])) { |
| 518 | - foreach($this->available_flags as $flag) { |
|
| 518 | + foreach ($this->available_flags as $flag) { |
|
| 519 | 519 | $this->parseFlag($flags, $flag); |
| 520 | 520 | } |
| 521 | 521 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | } else { |
| 588 | 588 | $personalParts = \imap_mime_header_decode($address->personal); |
| 589 | 589 | |
| 590 | - if(is_array($personalParts)) { |
|
| 590 | + if (is_array($personalParts)) { |
|
| 591 | 591 | $address->personal = ''; |
| 592 | 592 | foreach ($personalParts as $p) { |
| 593 | 593 | $encoding = (property_exists($p, 'charset')) ? $p->charset : $this->getEncoding($p->text); |
@@ -615,12 +615,12 @@ discard block |
||
| 615 | 615 | $this->client->openFolder($this->folder_path); |
| 616 | 616 | $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 617 | 617 | |
| 618 | - if(property_exists($this->structure, 'parts')){ |
|
| 618 | + if (property_exists($this->structure, 'parts')) { |
|
| 619 | 619 | $parts = $this->structure->parts; |
| 620 | 620 | |
| 621 | - foreach ($parts as $part) { |
|
| 622 | - foreach ($part->parameters as $parameter) { |
|
| 623 | - if($parameter->attribute == "charset") { |
|
| 621 | + foreach ($parts as $part) { |
|
| 622 | + foreach ($part->parameters as $parameter) { |
|
| 623 | + if ($parameter->attribute == "charset") { |
|
| 624 | 624 | $encoding = $parameter->value; |
| 625 | 625 | |
| 626 | 626 | $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding); |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | return EncodingAliases::get($parameter->value); |
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | - }elseif (is_string($structure) === true){ |
|
| 902 | + }elseif (is_string($structure) === true) { |
|
| 903 | 903 | return mb_detect_encoding($structure); |
| 904 | 904 | } |
| 905 | 905 | |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | return null; |
| 950 | 950 | } |
| 951 | 951 | |
| 952 | - public function getFolder(){ |
|
| 952 | + public function getFolder() { |
|
| 953 | 953 | return $this->client->getFolder($this->folder_path); |
| 954 | 954 | } |
| 955 | 955 | |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | */ |
| 966 | 966 | public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { |
| 967 | 967 | |
| 968 | - if($create_folder) $this->client->createFolder($mailbox, true); |
|
| 968 | + if ($create_folder) $this->client->createFolder($mailbox, true); |
|
| 969 | 969 | |
| 970 | 970 | $target_folder = $this->client->getFolder($mailbox); |
| 971 | 971 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); |
@@ -973,8 +973,8 @@ discard block |
||
| 973 | 973 | $this->client->openFolder($this->folder_path); |
| 974 | 974 | $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); |
| 975 | 975 | |
| 976 | - if($status === true){ |
|
| 977 | - if($expunge) $this->client->expunge(); |
|
| 976 | + if ($status === true) { |
|
| 977 | + if ($expunge) $this->client->expunge(); |
|
| 978 | 978 | $this->client->openFolder($target_folder->path); |
| 979 | 979 | |
| 980 | 980 | $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); |
@@ -996,7 +996,7 @@ discard block |
||
| 996 | 996 | $this->client->openFolder($this->folder_path); |
| 997 | 997 | |
| 998 | 998 | $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 999 | - if($expunge) $this->client->expunge(); |
|
| 999 | + if ($expunge) $this->client->expunge(); |
|
| 1000 | 1000 | MessageDeletedEvent::dispatch($this); |
| 1001 | 1001 | |
| 1002 | 1002 | return $status; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $this->client->openFolder($this->folder_path); |
| 1014 | 1014 | |
| 1015 | 1015 | $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1016 | - if($expunge) $this->client->expunge(); |
|
| 1016 | + if ($expunge) $this->client->expunge(); |
|
| 1017 | 1017 | MessageRestoredEvent::dispatch($this); |
| 1018 | 1018 | |
| 1019 | 1019 | return $status; |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | * @return string |
| 1091 | 1091 | * @throws Exceptions\ConnectionFailedException |
| 1092 | 1092 | */ |
| 1093 | - public function getToken(){ |
|
| 1093 | + public function getToken() { |
|
| 1094 | 1094 | return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())])); |
| 1095 | 1095 | } |
| 1096 | 1096 | |
@@ -1153,7 +1153,7 @@ discard block |
||
| 1153 | 1153 | /** |
| 1154 | 1154 | * @return object|null |
| 1155 | 1155 | */ |
| 1156 | - public function getStructure(){ |
|
| 1156 | + public function getStructure() { |
|
| 1157 | 1157 | return $this->structure; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | /** |
| 1180 | 1180 | * @return array |
| 1181 | 1181 | */ |
| 1182 | - public function getAttributes(){ |
|
| 1182 | + public function getAttributes() { |
|
| 1183 | 1183 | return $this->attributes; |
| 1184 | 1184 | } |
| 1185 | 1185 | |
@@ -1187,8 +1187,8 @@ discard block |
||
| 1187 | 1187 | * @param $mask |
| 1188 | 1188 | * @return $this |
| 1189 | 1189 | */ |
| 1190 | - public function setMask($mask){ |
|
| 1191 | - if(class_exists($mask)){ |
|
| 1190 | + public function setMask($mask) { |
|
| 1191 | + if (class_exists($mask)) { |
|
| 1192 | 1192 | $this->mask = $mask; |
| 1193 | 1193 | } |
| 1194 | 1194 | |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | /** |
| 1199 | 1199 | * @return string |
| 1200 | 1200 | */ |
| 1201 | - public function getMask(){ |
|
| 1201 | + public function getMask() { |
|
| 1202 | 1202 | return $this->mask; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
@@ -1209,9 +1209,9 @@ discard block |
||
| 1209 | 1209 | * @return mixed |
| 1210 | 1210 | * @throws MaskNotFoundException |
| 1211 | 1211 | */ |
| 1212 | - public function mask($mask = null){ |
|
| 1212 | + public function mask($mask = null) { |
|
| 1213 | 1213 | $mask = $mask !== null ? $mask : $this->mask; |
| 1214 | - if(class_exists($mask)){ |
|
| 1214 | + if (class_exists($mask)) { |
|
| 1215 | 1215 | return new $mask($this); |
| 1216 | 1216 | } |
| 1217 | 1217 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | return $this->attributes[$name]; |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 252 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 253 | 253 | $name = Str::snake(substr($method, 3)); |
| 254 | 254 | |
| 255 | 255 | if(in_array($name, array_keys($this->attributes))) { |
@@ -379,9 +379,9 @@ discard block |
||
| 379 | 379 | if (property_exists($header, 'subject')) { |
| 380 | 380 | if($this->config['decoder']['message']['subject'] === 'utf-8') { |
| 381 | 381 | $this->subject = \imap_utf8($header->subject); |
| 382 | - }elseif($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 382 | + } elseif($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 383 | 383 | $this->subject = iconv_mime_decode($header->subject); |
| 384 | - }else{ |
|
| 384 | + } else{ |
|
| 385 | 385 | $this->subject = mb_decode_mimeheader($header->subject); |
| 386 | 386 | } |
| 387 | 387 | } |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | return EncodingAliases::get($parameter->value); |
| 900 | 900 | } |
| 901 | 901 | } |
| 902 | - }elseif (is_string($structure) === true){ |
|
| 902 | + } elseif (is_string($structure) === true){ |
|
| 903 | 903 | return mb_detect_encoding($structure); |
| 904 | 904 | } |
| 905 | 905 | |
@@ -965,7 +965,9 @@ discard block |
||
| 965 | 965 | */ |
| 966 | 966 | public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { |
| 967 | 967 | |
| 968 | - if($create_folder) $this->client->createFolder($mailbox, true); |
|
| 968 | + if($create_folder) { |
|
| 969 | + $this->client->createFolder($mailbox, true); |
|
| 970 | + } |
|
| 969 | 971 | |
| 970 | 972 | $target_folder = $this->client->getFolder($mailbox); |
| 971 | 973 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); |
@@ -974,7 +976,9 @@ discard block |
||
| 974 | 976 | $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); |
| 975 | 977 | |
| 976 | 978 | if($status === true){ |
| 977 | - if($expunge) $this->client->expunge(); |
|
| 979 | + if($expunge) { |
|
| 980 | + $this->client->expunge(); |
|
| 981 | + } |
|
| 978 | 982 | $this->client->openFolder($target_folder->path); |
| 979 | 983 | |
| 980 | 984 | $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); |
@@ -996,7 +1000,9 @@ discard block |
||
| 996 | 1000 | $this->client->openFolder($this->folder_path); |
| 997 | 1001 | |
| 998 | 1002 | $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 999 | - if($expunge) $this->client->expunge(); |
|
| 1003 | + if($expunge) { |
|
| 1004 | + $this->client->expunge(); |
|
| 1005 | + } |
|
| 1000 | 1006 | MessageDeletedEvent::dispatch($this); |
| 1001 | 1007 | |
| 1002 | 1008 | return $status; |
@@ -1013,7 +1019,9 @@ discard block |
||
| 1013 | 1019 | $this->client->openFolder($this->folder_path); |
| 1014 | 1020 | |
| 1015 | 1021 | $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1016 | - if($expunge) $this->client->expunge(); |
|
| 1022 | + if($expunge) { |
|
| 1023 | + $this->client->expunge(); |
|
| 1024 | + } |
|
| 1017 | 1025 | MessageRestoredEvent::dispatch($this); |
| 1018 | 1026 | |
| 1019 | 1027 | return $status; |