@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | if(isset($this->attributes[$name]) && $strict === false) { |
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - }else{ |
|
133 | + } else{ |
|
134 | 134 | if(isset($this->attributes[$name])) { |
135 | 135 | if (is_array($this->attributes[$name]) == false) { |
136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
137 | - }else{ |
|
137 | + } else{ |
|
138 | 138 | $this->attributes[$name][] = $value; |
139 | 139 | } |
140 | - }else{ |
|
140 | + } else{ |
|
141 | 141 | $this->attributes[$name] = $value; |
142 | 142 | } |
143 | 143 | } |
144 | - }elseif($this->attributize == false){ |
|
144 | + } elseif($this->attributize == false){ |
|
145 | 145 | $this->attributes[$name] = $value; |
146 | - }else{ |
|
146 | + } else{ |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | if ($prev_header !== null) { |
231 | 231 | $headers[$prev_header][] = $line; |
232 | 232 | } |
233 | - }elseif (substr($line, 0, 1) === " ") { |
|
233 | + } elseif (substr($line, 0, 1) === " ") { |
|
234 | 234 | $line = substr($line, 1); |
235 | 235 | $line = trim(rtrim($line)); |
236 | 236 | if ($prev_header !== null) { |
@@ -239,11 +239,11 @@ discard block |
||
239 | 239 | } |
240 | 240 | if (is_array($headers[$prev_header])) { |
241 | 241 | $headers[$prev_header][] = $line; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | $headers[$prev_header] .= $line; |
244 | 244 | } |
245 | 245 | } |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | if (($pos = strpos($line, ":")) > 0) { |
248 | 248 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
249 | 249 | $key = str_replace("-", "_", $key); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $value = trim(rtrim(substr($line, $pos + 1))); |
252 | 252 | if (isset($headers[$key])) { |
253 | 253 | $headers[$key][] = $value; |
254 | - }else{ |
|
254 | + } else{ |
|
255 | 255 | $headers[$key] = [$value]; |
256 | 256 | } |
257 | 257 | $prev_header = $key; |
@@ -260,7 +260,9 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | foreach($headers as $key => $values) { |
263 | - if (isset($imap_headers[$key])) continue; |
|
263 | + if (isset($imap_headers[$key])) { |
|
264 | + continue; |
|
265 | + } |
|
264 | 266 | $value = null; |
265 | 267 | switch($key){ |
266 | 268 | case 'from': |
@@ -397,9 +399,9 @@ discard block |
||
397 | 399 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
398 | 400 | } |
399 | 401 | } |
400 | - }elseif (property_exists($structure, 'charset')) { |
|
402 | + } elseif (property_exists($structure, 'charset')) { |
|
401 | 403 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
402 | - }elseif (is_string($structure) === true){ |
|
404 | + } elseif (is_string($structure) === true){ |
|
403 | 405 | return mb_detect_encoding($structure); |
404 | 406 | } |
405 | 407 | |
@@ -446,9 +448,9 @@ discard block |
||
446 | 448 | } |
447 | 449 | } |
448 | 450 | } |
449 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
451 | + } elseif($decoder === 'iconv' && $is_utf8_base) { |
|
450 | 452 | $value = iconv_mime_decode($value); |
451 | - }elseif($is_utf8_base){ |
|
453 | + } elseif($is_utf8_base){ |
|
452 | 454 | $value = mb_decode_mimeheader($value); |
453 | 455 | } |
454 | 456 | |
@@ -481,7 +483,9 @@ discard block |
||
481 | 483 | * Try to extract the priority from a given raw header string |
482 | 484 | */ |
483 | 485 | private function findPriority() { |
484 | - if(($priority = $this->get("x_priority")) === null) return; |
|
486 | + if(($priority = $this->get("x_priority")) === null) { |
|
487 | + return; |
|
488 | + } |
|
485 | 489 | switch((int)"$priority"){ |
486 | 490 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
487 | 491 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -604,7 +608,7 @@ discard block |
||
604 | 608 | foreach ($this->attributes as $key => $value) { |
605 | 609 | if (is_array($value)) { |
606 | 610 | $value = implode(", ", $value); |
607 | - }else{ |
|
611 | + } else{ |
|
608 | 612 | $value = (string)$value; |
609 | 613 | } |
610 | 614 | // Only parse strings and don't parse any attributes like the user-agent |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | if(strtolower(substr($method, 0, 3)) === 'get') { |
306 | 306 | $name = Str::snake(substr($method, 3)); |
307 | 307 | return $this->get($name); |
308 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
308 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
309 | 309 | $name = Str::snake(substr($method, 3)); |
310 | 310 | |
311 | 311 | if(in_array($name, array_keys($this->attributes))) { |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | if ($this->getFlags()->get("seen") == null) { |
512 | 512 | $this->unsetFlag("Seen"); |
513 | 513 | } |
514 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
514 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
515 | 515 | $this->setFlag("Seen"); |
516 | 516 | } |
517 | 517 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | private function fetchPart(Part $part) { |
556 | 556 | if ($part->isAttachment()) { |
557 | 557 | $this->fetchAttachment($part); |
558 | - }else{ |
|
558 | + } else{ |
|
559 | 559 | $encoding = $this->getEncoding($part); |
560 | 560 | |
561 | 561 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | if (isset($this->bodies[$subtype])) { |
582 | 582 | $this->bodies[$subtype] .= "\n".$content; |
583 | - }else{ |
|
583 | + } else{ |
|
584 | 584 | $this->bodies[$subtype] = $content; |
585 | 585 | } |
586 | 586 | } |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | return EncodingAliases::get($parameter->value); |
752 | 752 | } |
753 | 753 | } |
754 | - }elseif (property_exists($structure, 'charset')){ |
|
754 | + } elseif (property_exists($structure, 'charset')){ |
|
755 | 755 | return EncodingAliases::get($structure->charset); |
756 | - }elseif (is_string($structure) === true){ |
|
756 | + } elseif (is_string($structure) === true){ |
|
757 | 757 | return mb_detect_encoding($structure); |
758 | 758 | } |
759 | 759 | |
@@ -937,13 +937,15 @@ discard block |
||
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | 939 | protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
940 | - if($expunge) $this->client->expunge(); |
|
940 | + if($expunge) { |
|
941 | + $this->client->expunge(); |
|
942 | + } |
|
941 | 943 | |
942 | 944 | $this->client->openFolder($folder->path); |
943 | 945 | |
944 | 946 | if ($this->sequence === IMAP::ST_UID) { |
945 | 947 | $sequence_id = $next_uid; |
946 | - }else{ |
|
948 | + } else{ |
|
947 | 949 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 950 | } |
949 | 951 | |
@@ -966,7 +968,9 @@ discard block |
||
966 | 968 | */ |
967 | 969 | public function delete($expunge = true) { |
968 | 970 | $status = $this->setFlag("Deleted"); |
969 | - if($expunge) $this->client->expunge(); |
|
971 | + if($expunge) { |
|
972 | + $this->client->expunge(); |
|
973 | + } |
|
970 | 974 | |
971 | 975 | $event = $this->getEvent("message", "deleted"); |
972 | 976 | $event::dispatch($this); |
@@ -986,7 +990,9 @@ discard block |
||
986 | 990 | */ |
987 | 991 | public function restore($expunge = true) { |
988 | 992 | $status = $this->unsetFlag("Deleted"); |
989 | - if($expunge) $this->client->expunge(); |
|
993 | + if($expunge) { |
|
994 | + $this->client->expunge(); |
|
995 | + } |
|
990 | 996 | |
991 | 997 | $event = $this->getEvent("message", "restored"); |
992 | 998 | $event::dispatch($this); |
@@ -1405,7 +1411,7 @@ discard block |
||
1405 | 1411 | if ($this->getSequence() === IMAP::ST_UID) { |
1406 | 1412 | $this->setUid($uid); |
1407 | 1413 | $this->setMsglist($msglist); |
1408 | - }else{ |
|
1414 | + } else{ |
|
1409 | 1415 | $this->setMsgn($uid, $msglist); |
1410 | 1416 | } |
1411 | 1417 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
91 | 91 | if(stripos($content_type, 'multipart') === 0) { |
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
95 | 95 | } |
96 | 96 | } |
@@ -152,7 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function orWhere(Closure $closure = null) { |
154 | 154 | $this->query->push(['OR']); |
155 | - if ($closure !== null) $closure($this); |
|
155 | + if ($closure !== null) { |
|
156 | + $closure($this); |
|
157 | + } |
|
156 | 158 | |
157 | 159 | return $this; |
158 | 160 | } |
@@ -164,7 +166,9 @@ discard block |
||
164 | 166 | */ |
165 | 167 | public function andWhere(Closure $closure = null) { |
166 | 168 | $this->query->push(['AND']); |
167 | - if ($closure !== null) $closure($this); |
|
169 | + if ($closure !== null) { |
|
170 | + $closure($this); |
|
171 | + } |
|
168 | 172 | |
169 | 173 | return $this; |
170 | 174 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | return null; |
131 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
131 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
132 | 132 | $name = Str::snake(substr($method, 3)); |
133 | 133 | |
134 | 134 | $this->attributes[$name] = array_pop($arguments); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $this->setName($filename); |
223 | 223 | } elseif (($name = $this->part->name) !== null) { |
224 | 224 | $this->setName($name); |
225 | - }else { |
|
225 | + } else { |
|
226 | 226 | $this->setName("undefined"); |
227 | 227 | } |
228 | 228 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | if ($name !== null) { |
258 | 258 | if($decoder === 'utf-8' && extension_loaded('imap')) { |
259 | 259 | $this->name = \imap_utf8($name); |
260 | - }else{ |
|
260 | + } else{ |
|
261 | 261 | $this->name = mb_decode_mimeheader($name); |
262 | 262 | } |
263 | 263 | } |
@@ -91,7 +91,9 @@ discard block |
||
91 | 91 | $this->setClient($client); |
92 | 92 | |
93 | 93 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
94 | - if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
94 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
95 | + $this->leaveUnread(); |
|
96 | + } |
|
95 | 97 | |
96 | 98 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 99 | $this->fetch_order = 'desc'; |
@@ -137,7 +139,9 @@ discard block |
||
137 | 139 | * @throws MessageSearchValidationException |
138 | 140 | */ |
139 | 141 | protected function parse_date($date) { |
140 | - if ($date instanceof Carbon) return $date; |
|
142 | + if ($date instanceof Carbon) { |
|
143 | + return $date; |
|
144 | + } |
|
141 | 145 | |
142 | 146 | try { |
143 | 147 | $date = Carbon::parse($date); |
@@ -250,15 +254,15 @@ discard block |
||
250 | 254 | protected function make($uid, $msglist, $header, $content, $flags){ |
251 | 255 | try { |
252 | 256 | return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence); |
253 | - }catch (MessageNotFoundException $e) { |
|
257 | + } catch (MessageNotFoundException $e) { |
|
254 | 258 | $this->setError($uid, $e); |
255 | - }catch (RuntimeException $e) { |
|
259 | + } catch (RuntimeException $e) { |
|
256 | 260 | $this->setError($uid, $e); |
257 | - }catch (MessageFlagException $e) { |
|
261 | + } catch (MessageFlagException $e) { |
|
258 | 262 | $this->setError($uid, $e); |
259 | - }catch (InvalidMessageDateException $e) { |
|
263 | + } catch (InvalidMessageDateException $e) { |
|
260 | 264 | $this->setError($uid, $e); |
261 | - }catch (MessageContentFetchingException $e) { |
|
265 | + } catch (MessageContentFetchingException $e) { |
|
262 | 266 | $this->setError($uid, $e); |
263 | 267 | } |
264 | 268 | |
@@ -511,7 +515,9 @@ discard block |
||
511 | 515 | * @return $this |
512 | 516 | */ |
513 | 517 | public function limit($limit, $page = 1) { |
514 | - if ($page >= 1) $this->page = $page; |
|
518 | + if ($page >= 1) { |
|
519 | + $this->page = $page; |
|
520 | + } |
|
515 | 521 | $this->limit = $limit; |
516 | 522 | |
517 | 523 | return $this; |
@@ -86,7 +86,9 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function toDate(){ |
88 | 88 | $date = $this->first(); |
89 | - if ($date instanceof Carbon) return $date; |
|
89 | + if ($date instanceof Carbon) { |
|
90 | + return $date; |
|
91 | + } |
|
90 | 92 | |
91 | 93 | return Carbon::parse($date); |
92 | 94 | } |
@@ -146,7 +148,7 @@ discard block |
||
146 | 148 | public function add($value, $strict = false) { |
147 | 149 | if (is_array($value)) { |
148 | 150 | return $this->merge($value, $strict); |
149 | - }elseif ($value !== null) { |
|
151 | + } elseif ($value !== null) { |
|
150 | 152 | $this->attach($value, $strict); |
151 | 153 | } |
152 | 154 | |
@@ -195,7 +197,7 @@ discard block |
||
195 | 197 | if ($this->contains($value) === false) { |
196 | 198 | $this->values[] = $value; |
197 | 199 | } |
198 | - }else{ |
|
200 | + } else{ |
|
199 | 201 | $this->values[] = $value; |
200 | 202 | } |
201 | 203 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $value = $this->default_account_config[$key]; |
208 | 208 | if(isset($config[$key])) { |
209 | 209 | $value = $config[$key]; |
210 | - }elseif(isset($default_config[$key])) { |
|
210 | + } elseif(isset($default_config[$key])) { |
|
211 | 211 | $value = $default_config[$key]; |
212 | 212 | } |
213 | 213 | $this->$key = $value; |
@@ -239,39 +239,39 @@ discard block |
||
239 | 239 | if(isset($config['masks']['message'])) { |
240 | 240 | if(class_exists($config['masks']['message'])) { |
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + } else{ |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
245 | + } else{ |
|
246 | 246 | if(class_exists($default_config['message'])) { |
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | 252 | if(isset($config['masks']['attachment'])) { |
253 | 253 | if(class_exists($config['masks']['attachment'])) { |
254 | 254 | $this->default_attachment_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | if(class_exists($default_config['attachment'])) { |
260 | 260 | $this->default_attachment_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['message'])) { |
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | 272 | if(class_exists($default_config['attachment'])) { |
273 | 273 | $this->default_attachment_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + } else{ |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + } else{ |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | return $folders; |
478 | - }else{ |
|
478 | + } else{ |
|
479 | 479 | throw new FolderFetchingException("failed to fetch any folders"); |
480 | 480 | } |
481 | 481 | } |
@@ -513,7 +513,9 @@ discard block |
||
513 | 513 | $this->checkConnection(); |
514 | 514 | $status = $this->connection->createFolder($folder); |
515 | 515 | |
516 | - if($expunge) $this->expunge(); |
|
516 | + if($expunge) { |
|
517 | + $this->expunge(); |
|
518 | + } |
|
517 | 519 | |
518 | 520 | $folder = $this->getFolder($folder); |
519 | 521 | if($status && $folder) { |