@@ -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])) { |
@@ -68,7 +68,9 @@ discard block |
||
| 68 | 68 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 69 | 69 | $this->setClient($client); |
| 70 | 70 | |
| 71 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 71 | + if(config('imap.options.fetch') === IMAP::FT_PEEK) { |
|
| 72 | + $this->leaveUnread(); |
|
| 73 | + } |
|
| 72 | 74 | |
| 73 | 75 | $this->date_format = config('imap.date_format', 'd M y'); |
| 74 | 76 | |
@@ -106,7 +108,9 @@ discard block |
||
| 106 | 108 | * @throws MessageSearchValidationException |
| 107 | 109 | */ |
| 108 | 110 | protected function parse_date($date) { |
| 109 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 111 | + if($date instanceof \Carbon\Carbon) { |
|
| 112 | + return $date; |
|
| 113 | + } |
|
| 110 | 114 | |
| 111 | 115 | try { |
| 112 | 116 | $date = Carbon::parse($date); |
@@ -154,7 +158,7 @@ discard block |
||
| 154 | 158 | */ |
| 155 | 159 | if($this->getCharset() === null){ |
| 156 | 160 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
| 157 | - }else{ |
|
| 161 | + } else{ |
|
| 158 | 162 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
| 159 | 163 | } |
| 160 | 164 | |
@@ -253,7 +257,7 @@ discard block |
||
| 253 | 257 | } else { |
| 254 | 258 | if($statement[1] === null){ |
| 255 | 259 | $query .= $statement[0]; |
| 256 | - }else{ |
|
| 260 | + } else{ |
|
| 257 | 261 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 258 | 262 | } |
| 259 | 263 | } |
@@ -283,7 +287,9 @@ discard block |
||
| 283 | 287 | * @return $this |
| 284 | 288 | */ |
| 285 | 289 | public function limit($limit, $page = 1) { |
| 286 | - if($page >= 1) $this->page = $page; |
|
| 290 | + if($page >= 1) { |
|
| 291 | + $this->page = $page; |
|
| 292 | + } |
|
| 287 | 293 | $this->limit = $limit; |
| 288 | 294 | |
| 289 | 295 | return $this; |
@@ -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 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | return $this->attributes[$name]; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 249 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 250 | 250 | $name = Str::snake(substr($method, 3)); |
| 251 | 251 | |
| 252 | 252 | if(in_array($name, array_keys($this->attributes))) { |
@@ -366,9 +366,9 @@ discard block |
||
| 366 | 366 | /** @var Attachment $oAttachment */ |
| 367 | 367 | if(is_callable($replaceImages)) { |
| 368 | 368 | $body = $replaceImages($body, $oAttachment); |
| 369 | - }elseif(is_string($replaceImages)) { |
|
| 369 | + } elseif(is_string($replaceImages)) { |
|
| 370 | 370 | call_user_func($replaceImages, [$body, $oAttachment]); |
| 371 | - }else{ |
|
| 371 | + } else{ |
|
| 372 | 372 | if ($oAttachment->id && $oAttachment->getImgSrc() != null) { |
| 373 | 373 | $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body); |
| 374 | 374 | } |
@@ -399,9 +399,9 @@ discard block |
||
| 399 | 399 | if (property_exists($header, 'subject')) { |
| 400 | 400 | if($this->config['decoder']['message']['subject'] === 'utf-8') { |
| 401 | 401 | $this->subject = \imap_utf8($header->subject); |
| 402 | - }elseif($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 402 | + } elseif($this->config['decoder']['message']['subject'] === 'iconv') { |
|
| 403 | 403 | $this->subject = iconv_mime_decode($header->subject); |
| 404 | - }else{ |
|
| 404 | + } else{ |
|
| 405 | 405 | $this->subject = mb_decode_mimeheader($header->subject); |
| 406 | 406 | } |
| 407 | 407 | } |
@@ -919,7 +919,7 @@ discard block |
||
| 919 | 919 | return EncodingAliases::get($parameter->value); |
| 920 | 920 | } |
| 921 | 921 | } |
| 922 | - }elseif (is_string($structure) === true){ |
|
| 922 | + } elseif (is_string($structure) === true){ |
|
| 923 | 923 | return mb_detect_encoding($structure); |
| 924 | 924 | } |
| 925 | 925 | |
@@ -985,7 +985,9 @@ discard block |
||
| 985 | 985 | */ |
| 986 | 986 | public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { |
| 987 | 987 | |
| 988 | - if($create_folder) $this->client->createFolder($mailbox, true); |
|
| 988 | + if($create_folder) { |
|
| 989 | + $this->client->createFolder($mailbox, true); |
|
| 990 | + } |
|
| 989 | 991 | |
| 990 | 992 | $target_folder = $this->client->getFolder($mailbox); |
| 991 | 993 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); |
@@ -994,7 +996,9 @@ discard block |
||
| 994 | 996 | $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); |
| 995 | 997 | |
| 996 | 998 | if($status === true){ |
| 997 | - if($expunge) $this->client->expunge(); |
|
| 999 | + if($expunge) { |
|
| 1000 | + $this->client->expunge(); |
|
| 1001 | + } |
|
| 998 | 1002 | $this->client->openFolder($target_folder->path); |
| 999 | 1003 | |
| 1000 | 1004 | return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); |
@@ -1014,7 +1018,9 @@ discard block |
||
| 1014 | 1018 | $this->client->openFolder($this->folder_path); |
| 1015 | 1019 | |
| 1016 | 1020 | $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1017 | - if($expunge) $this->client->expunge(); |
|
| 1021 | + if($expunge) { |
|
| 1022 | + $this->client->expunge(); |
|
| 1023 | + } |
|
| 1018 | 1024 | |
| 1019 | 1025 | return $status; |
| 1020 | 1026 | } |
@@ -1030,7 +1036,9 @@ discard block |
||
| 1030 | 1036 | $this->client->openFolder($this->folder_path); |
| 1031 | 1037 | |
| 1032 | 1038 | $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); |
| 1033 | - if($expunge) $this->client->expunge(); |
|
| 1039 | + if($expunge) { |
|
| 1040 | + $this->client->expunge(); |
|
| 1041 | + } |
|
| 1034 | 1042 | |
| 1035 | 1043 | return $status; |
| 1036 | 1044 | } |
@@ -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 | } |