| @@ -77,17 +77,17 @@ discard block | ||
| 77 | 77 |              foreach($criteria as $arguments){ | 
| 78 | 78 |                  if(count($arguments) == 1){ | 
| 79 | 79 | $this->where($arguments[0]); | 
| 80 | -                }elseif(count($arguments) == 2){ | |
| 80 | +                } elseif(count($arguments) == 2){ | |
| 81 | 81 | $this->where($arguments[0], $arguments[1]); | 
| 82 | 82 | } | 
| 83 | 83 | } | 
| 84 | -        }else{ | |
| 84 | +        } else{ | |
| 85 | 85 | $criteria = $this->validate_criteria($criteria); | 
| 86 | 86 | $value = $this->parse_value($value); | 
| 87 | 87 | |
| 88 | 88 |              if($value === null || $value === ''){ | 
| 89 | 89 | $this->query->push([$criteria]); | 
| 90 | -            }else{ | |
| 90 | +            } else{ | |
| 91 | 91 | $this->query->push([$criteria, $value]); | 
| 92 | 92 | } | 
| 93 | 93 | } | 
| @@ -102,7 +102,9 @@ discard block | ||
| 102 | 102 | */ | 
| 103 | 103 |      public function orWhere(\Closure $closure = null) { | 
| 104 | 104 | $this->query->push(['OR']); | 
| 105 | - if($closure !== null) $closure($this); | |
| 105 | +        if($closure !== null) { | |
| 106 | + $closure($this); | |
| 107 | + } | |
| 106 | 108 | |
| 107 | 109 | return $this; | 
| 108 | 110 | } | 
| @@ -114,7 +116,9 @@ discard block | ||
| 114 | 116 | */ | 
| 115 | 117 |      public function andWhere(\Closure $closure = null) { | 
| 116 | 118 | $this->query->push(['AND']); | 
| 117 | - if($closure !== null) $closure($this); | |
| 119 | +        if($closure !== null) { | |
| 120 | + $closure($this); | |
| 121 | + } | |
| 118 | 122 | |
| 119 | 123 | return $this; | 
| 120 | 124 | } | 
| @@ -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 | } | 
| @@ -355,14 +355,14 @@ | ||
| 355 | 355 | return $status; | 
| 356 | 356 | } | 
| 357 | 357 | |
| 358 | - /** | |
| 359 | - * Delete Folder | |
| 360 | - * @param string $name | |
| 361 | - * @param boolean $expunge | |
| 362 | - * | |
| 363 | - * @return bool | |
| 364 | - * @throws ConnectionFailedException | |
| 365 | - */ | |
| 358 | + /** | |
| 359 | + * Delete Folder | |
| 360 | + * @param string $name | |
| 361 | + * @param boolean $expunge | |
| 362 | + * | |
| 363 | + * @return bool | |
| 364 | + * @throws ConnectionFailedException | |
| 365 | + */ | |
| 366 | 366 |      public function deleteFolder($name, $expunge = true) { | 
| 367 | 367 | $this->checkConnection(); | 
| 368 | 368 | $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 | } | 
| @@ -373,7 +373,7 @@ discard block | ||
| 373 | 373 | } | 
| 374 | 374 | |
| 375 | 375 | return $folders; | 
| 376 | -        }else{ | |
| 376 | +        } else{ | |
| 377 | 377 | throw new MailboxFetchingException($this->getLastError()); | 
| 378 | 378 | } | 
| 379 | 379 | } | 
| @@ -407,7 +407,9 @@ discard block | ||
| 407 | 407 |      public function createFolder($name, $expunge = true) { | 
| 408 | 408 | $this->checkConnection(); | 
| 409 | 409 | $status = imap_createmailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name)); | 
| 410 | - if($expunge) $this->expunge(); | |
| 410 | +        if($expunge) { | |
| 411 | + $this->expunge(); | |
| 412 | + } | |
| 411 | 413 | |
| 412 | 414 | return $status; | 
| 413 | 415 | } | 
| @@ -424,7 +426,9 @@ discard block | ||
| 424 | 426 |      public function renameFolder($old_name, $new_name, $expunge = true) { | 
| 425 | 427 | $this->checkConnection(); | 
| 426 | 428 | $status = imap_renamemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name)); | 
| 427 | - if($expunge) $this->expunge(); | |
| 429 | +        if($expunge) { | |
| 430 | + $this->expunge(); | |
| 431 | + } | |
| 428 | 432 | |
| 429 | 433 | return $status; | 
| 430 | 434 | } | 
| @@ -440,7 +444,9 @@ discard block | ||
| 440 | 444 |      public function deleteFolder($name, $expunge = true) { | 
| 441 | 445 | $this->checkConnection(); | 
| 442 | 446 | $status = imap_deletemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name)); | 
| 443 | - if($expunge) $this->expunge(); | |
| 447 | +        if($expunge) { | |
| 448 | + $this->expunge(); | |
| 449 | + } | |
| 444 | 450 | |
| 445 | 451 | return $status; | 
| 446 | 452 | } | 
| @@ -370,7 +370,9 @@ discard block | ||
| 370 | 370 | */ | 
| 371 | 371 |      public function delete($expunge = true) { | 
| 372 | 372 | $status = imap_deletemailbox($this->client->getConnection(), $this->path); | 
| 373 | - if($expunge) $this->client->expunge(); | |
| 373 | +        if($expunge) { | |
| 374 | + $this->client->expunge(); | |
| 375 | + } | |
| 374 | 376 | |
| 375 | 377 | return $status; | 
| 376 | 378 | } | 
| @@ -387,7 +389,9 @@ discard block | ||
| 387 | 389 | */ | 
| 388 | 390 |      public function move($target_mailbox, $expunge = true) { | 
| 389 | 391 | $status = imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox); | 
| 390 | - if($expunge) $this->client->expunge(); | |
| 392 | +        if($expunge) { | |
| 393 | + $this->client->expunge(); | |
| 394 | + } | |
| 391 | 395 | |
| 392 | 396 | return $status; | 
| 393 | 397 | } | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | } | 
| 119 | 119 | |
| 120 | 120 | return null; | 
| 121 | -        }elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 121 | +        } elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 122 | 122 | $name = snake_case(substr($method, 3)); | 
| 123 | 123 | |
| 124 | 124 | $this->attributes[$name] = array_pop($arguments); | 
| @@ -257,7 +257,7 @@ discard block | ||
| 257 | 257 |      public function setName($name) { | 
| 258 | 258 |          if($this->config['decoder']['message']['subject'] === 'utf-8') { | 
| 259 | 259 | $this->name = imap_utf8($name); | 
| 260 | -        }else{ | |
| 260 | +        } else{ | |
| 261 | 261 | $this->name = mb_decode_mimeheader($name); | 
| 262 | 262 | } | 
| 263 | 263 | } | 
| @@ -60,7 +60,7 @@ | ||
| 60 | 60 | return $this->attributes[$name]; | 
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | -        }elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 63 | +        } elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 64 | 64 | $name = snake_case(substr($method, 3)); | 
| 65 | 65 | |
| 66 | 66 |              if(isset($this->attributes[$name])) { | 
| @@ -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 | }); | 
| @@ -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 | |
| @@ -243,7 +247,7 @@ discard block | ||
| 243 | 247 |              } else { | 
| 244 | 248 |                  if($statement[1] === null){ | 
| 245 | 249 | $query .= $statement[0]; | 
| 246 | -                }else{ | |
| 250 | +                } else{ | |
| 247 | 251 | $query .= $statement[0].' "'.$statement[1].'"'; | 
| 248 | 252 | } | 
| 249 | 253 | } | 
| @@ -273,7 +277,9 @@ discard block | ||
| 273 | 277 | * @return $this | 
| 274 | 278 | */ | 
| 275 | 279 |      public function limit($limit, $page = 1) { | 
| 276 | - if($page >= 1) $this->page = $page; | |
| 280 | +        if($page >= 1) { | |
| 281 | + $this->page = $page; | |
| 282 | + } | |
| 277 | 283 | $this->limit = $limit; | 
| 278 | 284 | |
| 279 | 285 | return $this; | 
| @@ -245,7 +245,7 @@ discard block | ||
| 245 | 245 | return $this->attributes[$name]; | 
| 246 | 246 | } | 
| 247 | 247 | |
| 248 | -        }elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 248 | +        } elseif (strtolower(substr($method, 0, 3)) === 'set') { | |
| 249 | 249 | $name = snake_case(substr($method, 3)); | 
| 250 | 250 | |
| 251 | 251 |              if(in_array($name, array_keys($this->attributes))) { | 
| @@ -365,9 +365,9 @@ discard block | ||
| 365 | 365 | /** @var Attachment $oAttachment */ | 
| 366 | 366 |                  if(is_callable($replaceImages)) { | 
| 367 | 367 | $body = $replaceImages($body, $oAttachment); | 
| 368 | -                }elseif(is_string($replaceImages)) { | |
| 368 | +                } elseif(is_string($replaceImages)) { | |
| 369 | 369 | call_user_func($replaceImages, [$body, $oAttachment]); | 
| 370 | -                }else{ | |
| 370 | +                } else{ | |
| 371 | 371 |                      if ($oAttachment->id && $oAttachment->getImgSrc() != null) { | 
| 372 | 372 |                          $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body); | 
| 373 | 373 | } | 
| @@ -398,7 +398,7 @@ discard block | ||
| 398 | 398 |          if (property_exists($header, 'subject')) { | 
| 399 | 399 |              if($this->config['decoder']['message']['subject'] === 'utf-8') { | 
| 400 | 400 | $this->subject = imap_utf8($header->subject); | 
| 401 | -            }else{ | |
| 401 | +            } else{ | |
| 402 | 402 | $this->subject = mb_decode_mimeheader($header->subject); | 
| 403 | 403 | } | 
| 404 | 404 | } | 
| @@ -909,7 +909,7 @@ discard block | ||
| 909 | 909 | return EncodingAliases::get($parameter->value); | 
| 910 | 910 | } | 
| 911 | 911 | } | 
| 912 | -        }elseif (is_string($structure) === true){ | |
| 912 | +        } elseif (is_string($structure) === true){ | |
| 913 | 913 | return mb_detect_encoding($structure); | 
| 914 | 914 | } | 
| 915 | 915 | |
| @@ -975,7 +975,9 @@ discard block | ||
| 975 | 975 | */ | 
| 976 | 976 |      public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) { | 
| 977 | 977 | |
| 978 | - if($create_folder) $this->client->createFolder($mailbox, true); | |
| 978 | +        if($create_folder) { | |
| 979 | + $this->client->createFolder($mailbox, true); | |
| 980 | + } | |
| 979 | 981 | |
| 980 | 982 | $target_folder = $this->client->getFolder($mailbox); | 
| 981 | 983 | $target_status = $target_folder->getStatus(IMAP::SA_ALL); | 
| @@ -984,7 +986,9 @@ discard block | ||
| 984 | 986 | $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID); | 
| 985 | 987 | |
| 986 | 988 |          if($status === true){ | 
| 987 | - if($expunge) $this->client->expunge(); | |
| 989 | +            if($expunge) { | |
| 990 | + $this->client->expunge(); | |
| 991 | + } | |
| 988 | 992 | $this->client->openFolder($target_folder->path); | 
| 989 | 993 | |
| 990 | 994 | return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags); | 
| @@ -1004,7 +1008,9 @@ discard block | ||
| 1004 | 1008 | $this->client->openFolder($this->folder_path); | 
| 1005 | 1009 | |
| 1006 | 1010 | $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID); | 
| 1007 | - if($expunge) $this->client->expunge(); | |
| 1011 | +        if($expunge) { | |
| 1012 | + $this->client->expunge(); | |
| 1013 | + } | |
| 1008 | 1014 | |
| 1009 | 1015 | return $status; | 
| 1010 | 1016 | } | 
| @@ -1020,7 +1026,9 @@ discard block | ||
| 1020 | 1026 | $this->client->openFolder($this->folder_path); | 
| 1021 | 1027 | |
| 1022 | 1028 | $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID); | 
| 1023 | - if($expunge) $this->client->expunge(); | |
| 1029 | +        if($expunge) { | |
| 1030 | + $this->client->expunge(); | |
| 1031 | + } | |
| 1024 | 1032 | |
| 1025 | 1033 | return $status; | 
| 1026 | 1034 | } |