@@ -114,11 +114,15 @@ discard block |
||
| 114 | 114 | $arrays = func_get_args(); |
| 115 | 115 | $base = array_shift($arrays); |
| 116 | 116 | |
| 117 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 117 | + if(!is_array($base)) { |
|
| 118 | + $base = empty($base) ? array() : array($base); |
|
| 119 | + } |
|
| 118 | 120 | |
| 119 | 121 | foreach($arrays as $append) { |
| 120 | 122 | |
| 121 | - if(!is_array($append)) $append = array($append); |
|
| 123 | + if(!is_array($append)) { |
|
| 124 | + $append = array($append); |
|
| 125 | + } |
|
| 122 | 126 | |
| 123 | 127 | foreach($append as $key => $value) { |
| 124 | 128 | |
@@ -130,7 +134,9 @@ discard block |
||
| 130 | 134 | if(is_array($value) or is_array($base[$key])) { |
| 131 | 135 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 132 | 136 | } else if(is_numeric($key)) { |
| 133 | - if(!in_array($value, $base)) $base[] = $value; |
|
| 137 | + if(!in_array($value, $base)) { |
|
| 138 | + $base[] = $value; |
|
| 139 | + } |
|
| 134 | 140 | } else { |
| 135 | 141 | $base[$key] = $value; |
| 136 | 142 | } |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function getCustomHTMLBody($callback = false) { |
| 47 | 47 | $body = $this->getHtmlBody(); |
| 48 | - if($body === null) return null; |
|
| 48 | + if($body === null) { |
|
| 49 | + return null; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | if ($callback !== false) { |
| 51 | 53 | $aAttachment = $this->parent->getAttachments(); |
@@ -53,7 +55,7 @@ discard block |
||
| 53 | 55 | /** @var Attachment $oAttachment */ |
| 54 | 56 | if(is_callable($callback)) { |
| 55 | 57 | $body = $callback($body, $oAttachment); |
| 56 | - }elseif(is_string($callback)) { |
|
| 58 | + } elseif(is_string($callback)) { |
|
| 57 | 59 | call_user_func($callback, [$body, $oAttachment]); |
| 58 | 60 | } |
| 59 | 61 | }); |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | return $this->attributes[$name]; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 70 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 71 | 71 | $name = Str::snake(substr($method, 3)); |
| 72 | 72 | |
| 73 | 73 | if(isset($this->attributes[$name])) { |
@@ -436,14 +436,14 @@ |
||
| 436 | 436 | return $status; |
| 437 | 437 | } |
| 438 | 438 | |
| 439 | - /** |
|
| 440 | - * Delete Folder |
|
| 441 | - * @param string $name |
|
| 442 | - * @param boolean $expunge |
|
| 443 | - * |
|
| 444 | - * @return bool |
|
| 445 | - * @throws ConnectionFailedException |
|
| 446 | - */ |
|
| 439 | + /** |
|
| 440 | + * Delete Folder |
|
| 441 | + * @param string $name |
|
| 442 | + * @param boolean $expunge |
|
| 443 | + * |
|
| 444 | + * @return bool |
|
| 445 | + * @throws ConnectionFailedException |
|
| 446 | + */ |
|
| 447 | 447 | public function deleteFolder($name, $expunge = true) { |
| 448 | 448 | $this->checkConnection(); |
| 449 | 449 | $status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
@@ -179,39 +179,39 @@ discard block |
||
| 179 | 179 | if(isset($config['masks']['message'])) { |
| 180 | 180 | if(class_exists($config['masks']['message'])) { |
| 181 | 181 | $this->default_message_mask = $config['masks']['message']; |
| 182 | - }else{ |
|
| 182 | + } else{ |
|
| 183 | 183 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 184 | 184 | } |
| 185 | - }else{ |
|
| 185 | + } else{ |
|
| 186 | 186 | if(class_exists($default_config['message'])) { |
| 187 | 187 | $this->default_message_mask = $default_config['message']; |
| 188 | - }else{ |
|
| 188 | + } else{ |
|
| 189 | 189 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | if(isset($config['masks']['attachment'])) { |
| 193 | 193 | if(class_exists($config['masks']['attachment'])) { |
| 194 | 194 | $this->default_message_mask = $config['masks']['attachment']; |
| 195 | - }else{ |
|
| 195 | + } else{ |
|
| 196 | 196 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 197 | 197 | } |
| 198 | - }else{ |
|
| 198 | + } else{ |
|
| 199 | 199 | if(class_exists($default_config['attachment'])) { |
| 200 | 200 | $this->default_message_mask = $default_config['attachment']; |
| 201 | - }else{ |
|
| 201 | + } else{ |
|
| 202 | 202 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | - }else{ |
|
| 205 | + } else{ |
|
| 206 | 206 | if(class_exists($default_config['message'])) { |
| 207 | 207 | $this->default_message_mask = $default_config['message']; |
| 208 | - }else{ |
|
| 208 | + } else{ |
|
| 209 | 209 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if(class_exists($default_config['attachment'])) { |
| 213 | 213 | $this->default_message_mask = $default_config['attachment']; |
| 214 | - }else{ |
|
| 214 | + } else{ |
|
| 215 | 215 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $folders; |
| 379 | - }else{ |
|
| 379 | + } else{ |
|
| 380 | 380 | throw new MailboxFetchingException($this->getLastError()); |
| 381 | 381 | } |
| 382 | 382 | } |
@@ -414,7 +414,9 @@ discard block |
||
| 414 | 414 | public function createFolder($name, $expunge = true) { |
| 415 | 415 | $this->checkConnection(); |
| 416 | 416 | $status = \imap_createmailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
| 417 | - if($expunge) $this->expunge(); |
|
| 417 | + if($expunge) { |
|
| 418 | + $this->expunge(); |
|
| 419 | + } |
|
| 418 | 420 | |
| 419 | 421 | return $status; |
| 420 | 422 | } |
@@ -431,7 +433,9 @@ discard block |
||
| 431 | 433 | public function renameFolder($old_name, $new_name, $expunge = true) { |
| 432 | 434 | $this->checkConnection(); |
| 433 | 435 | $status = \imap_renamemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($old_name), $this->getAddress() . \imap_utf7_encode($new_name)); |
| 434 | - if($expunge) $this->expunge(); |
|
| 436 | + if($expunge) { |
|
| 437 | + $this->expunge(); |
|
| 438 | + } |
|
| 435 | 439 | |
| 436 | 440 | return $status; |
| 437 | 441 | } |
@@ -447,7 +451,9 @@ discard block |
||
| 447 | 451 | public function deleteFolder($name, $expunge = true) { |
| 448 | 452 | $this->checkConnection(); |
| 449 | 453 | $status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name)); |
| 450 | - if($expunge) $this->expunge(); |
|
| 454 | + if($expunge) { |
|
| 455 | + $this->expunge(); |
|
| 456 | + } |
|
| 451 | 457 | |
| 452 | 458 | return $status; |
| 453 | 459 | } |
@@ -375,7 +375,9 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | public function delete($expunge = true) { |
| 377 | 377 | $status = \imap_deletemailbox($this->client->getConnection(), $this->path); |
| 378 | - if($expunge) $this->client->expunge(); |
|
| 378 | + if($expunge) { |
|
| 379 | + $this->client->expunge(); |
|
| 380 | + } |
|
| 379 | 381 | |
| 380 | 382 | return $status; |
| 381 | 383 | } |
@@ -392,7 +394,9 @@ discard block |
||
| 392 | 394 | */ |
| 393 | 395 | public function move($target_mailbox, $expunge = true) { |
| 394 | 396 | $status = \imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox); |
| 395 | - if($expunge) $this->client->expunge(); |
|
| 397 | + if($expunge) { |
|
| 398 | + $this->client->expunge(); |
|
| 399 | + } |
|
| 396 | 400 | |
| 397 | 401 | return $status; |
| 398 | 402 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if (strpos(strtolower($name), "where") === false){ |
| 85 | 85 | $method = 'where'.ucfirst($name); |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $method = lcfirst($name); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -129,13 +129,13 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | return $this->where($key, $value); |
| 131 | 131 | } |
| 132 | - }else{ |
|
| 132 | + } else{ |
|
| 133 | 133 | $criteria = $this->validate_criteria($criteria); |
| 134 | 134 | $value = $this->parse_value($value); |
| 135 | 135 | |
| 136 | 136 | if($value === null || $value === ''){ |
| 137 | 137 | $this->query->push([$criteria]); |
| 138 | - }else{ |
|
| 138 | + } else{ |
|
| 139 | 139 | $this->query->push([$criteria, $value]); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -150,7 +150,9 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public function orWhere(\Closure $closure = null) { |
| 152 | 152 | $this->query->push(['OR']); |
| 153 | - if($closure !== null) $closure($this); |
|
| 153 | + if($closure !== null) { |
|
| 154 | + $closure($this); |
|
| 155 | + } |
|
| 154 | 156 | |
| 155 | 157 | return $this; |
| 156 | 158 | } |
@@ -162,7 +164,9 @@ discard block |
||
| 162 | 164 | */ |
| 163 | 165 | public function andWhere(\Closure $closure = null) { |
| 164 | 166 | $this->query->push(['AND']); |
| 165 | - if($closure !== null) $closure($this); |
|
| 167 | + if($closure !== null) { |
|
| 168 | + $closure($this); |
|
| 169 | + } |
|
| 166 | 170 | |
| 167 | 171 | return $this; |
| 168 | 172 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | return null; |
| 125 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 125 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 126 | 126 | $name = Str::snake(substr($method, 3)); |
| 127 | 127 | |
| 128 | 128 | $this->attributes[$name] = array_pop($arguments); |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | public function setName($name) { |
| 266 | 266 | if($this->config['decoder']['attachment']['name'] === 'utf-8') { |
| 267 | 267 | $this->name = \imap_utf8($name); |
| 268 | - }elseif($this->config['decoder']['attachment']['name'] === 'iconv') { |
|
| 268 | + } elseif($this->config['decoder']['attachment']['name'] === 'iconv') { |
|
| 269 | 269 | $this->name = iconv_mime_decode($name); |
| 270 | - }else{ |
|
| 270 | + } else{ |
|
| 271 | 271 | $this->name = mb_decode_mimeheader($name); |
| 272 | 272 | } |
| 273 | 273 | } |
@@ -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; |
@@ -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; |