@@ -232,7 +232,9 @@ discard block |
||
232 | 232 | public function move($new_name, $expunge = true) { |
233 | 233 | $this->client->checkConnection(); |
234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
235 | - if($expunge) $this->client->expunge(); |
|
235 | + if($expunge) { |
|
236 | + $this->client->expunge(); |
|
237 | + } |
|
236 | 238 | |
237 | 239 | $folder = $this->client->getFolder($new_name); |
238 | 240 | $event = $this->getEvent("folder", "moved"); |
@@ -306,7 +308,9 @@ discard block |
||
306 | 308 | */ |
307 | 309 | public function delete($expunge = true) { |
308 | 310 | $status = $this->client->getConnection()->deleteFolder($this->path); |
309 | - if($expunge) $this->client->expunge(); |
|
311 | + if($expunge) { |
|
312 | + $this->client->expunge(); |
|
313 | + } |
|
310 | 314 | |
311 | 315 | $event = $this->getEvent("folder", "deleted"); |
312 | 316 | $event::dispatch($this); |
@@ -374,7 +378,7 @@ discard block |
||
374 | 378 | |
375 | 379 | $connection->idle(); |
376 | 380 | } |
377 | - }catch (Exceptions\RuntimeException $e) { |
|
381 | + } catch (Exceptions\RuntimeException $e) { |
|
378 | 382 | if(strpos($e->getMessage(), "connection closed") === false) { |
379 | 383 | throw $e; |
380 | 384 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $value = $this->default_account_config[$key]; |
199 | 199 | if(isset($config[$key])) { |
200 | 200 | $value = $config[$key]; |
201 | - }elseif(isset($default_config[$key])) { |
|
201 | + } elseif(isset($default_config[$key])) { |
|
202 | 202 | $value = $default_config[$key]; |
203 | 203 | } |
204 | 204 | $this->$key = $value; |
@@ -232,39 +232,39 @@ discard block |
||
232 | 232 | if(isset($config['masks']['message'])) { |
233 | 233 | if(class_exists($config['masks']['message'])) { |
234 | 234 | $this->default_message_mask = $config['masks']['message']; |
235 | - }else{ |
|
235 | + } else{ |
|
236 | 236 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
237 | 237 | } |
238 | - }else{ |
|
238 | + } else{ |
|
239 | 239 | if(class_exists($default_config['message'])) { |
240 | 240 | $this->default_message_mask = $default_config['message']; |
241 | - }else{ |
|
241 | + } else{ |
|
242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
243 | 243 | } |
244 | 244 | } |
245 | 245 | if(isset($config['masks']['attachment'])) { |
246 | 246 | if(class_exists($config['masks']['attachment'])) { |
247 | 247 | $this->default_message_mask = $config['masks']['attachment']; |
248 | - }else{ |
|
248 | + } else{ |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
250 | 250 | } |
251 | - }else{ |
|
251 | + } else{ |
|
252 | 252 | if(class_exists($default_config['attachment'])) { |
253 | 253 | $this->default_message_mask = $default_config['attachment']; |
254 | - }else{ |
|
254 | + } else{ |
|
255 | 255 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
256 | 256 | } |
257 | 257 | } |
258 | - }else{ |
|
258 | + } else{ |
|
259 | 259 | if(class_exists($default_config['message'])) { |
260 | 260 | $this->default_message_mask = $default_config['message']; |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
263 | 263 | } |
264 | 264 | |
265 | 265 | if(class_exists($default_config['attachment'])) { |
266 | 266 | $this->default_message_mask = $default_config['attachment']; |
267 | - }else{ |
|
267 | + } else{ |
|
268 | 268 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
269 | 269 | } |
270 | 270 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
330 | 330 | $this->connection->setConnectionTimeout($timeout); |
331 | 331 | $this->connection->setProxy($this->proxy); |
332 | - }else{ |
|
332 | + } else{ |
|
333 | 333 | if (extension_loaded('imap') === false) { |
334 | 334 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
335 | 335 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | return $folders; |
460 | - }else{ |
|
460 | + } else{ |
|
461 | 461 | throw new FolderFetchingException("failed to fetch any folders"); |
462 | 462 | } |
463 | 463 | } |
@@ -493,7 +493,9 @@ discard block |
||
493 | 493 | $this->checkConnection(); |
494 | 494 | $status = $this->connection->createFolder($folder); |
495 | 495 | |
496 | - if($expunge) $this->expunge(); |
|
496 | + if($expunge) { |
|
497 | + $this->expunge(); |
|
498 | + } |
|
497 | 499 | |
498 | 500 | $folder = $this->getFolder($folder); |
499 | 501 | if($status && $folder) { |
@@ -80,7 +80,9 @@ discard block |
||
80 | 80 | $this->setClient($client); |
81 | 81 | |
82 | 82 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
83 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
83 | + if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
84 | + $this->leaveUnread(); |
|
85 | + } |
|
84 | 86 | |
85 | 87 | if (ClientManager::get('options.fetch_order') === 'desc') { |
86 | 88 | $this->fetch_order = 'desc'; |
@@ -124,7 +126,9 @@ discard block |
||
124 | 126 | * @throws MessageSearchValidationException |
125 | 127 | */ |
126 | 128 | protected function parse_date($date) { |
127 | - if($date instanceof \Carbon\Carbon) return $date; |
|
129 | + if($date instanceof \Carbon\Carbon) { |
|
130 | + return $date; |
|
131 | + } |
|
128 | 132 | |
129 | 133 | try { |
130 | 134 | $date = Carbon::parse($date); |
@@ -322,7 +326,7 @@ discard block |
||
322 | 326 | } else { |
323 | 327 | if($statement[1] === null){ |
324 | 328 | $query .= $statement[0]; |
325 | - }else{ |
|
329 | + } else{ |
|
326 | 330 | $query .= $statement[0].' "'.$statement[1].'"'; |
327 | 331 | } |
328 | 332 | } |
@@ -352,7 +356,9 @@ discard block |
||
352 | 356 | * @return $this |
353 | 357 | */ |
354 | 358 | public function limit($limit, $page = 1) { |
355 | - if($page >= 1) $this->page = $page; |
|
359 | + if($page >= 1) { |
|
360 | + $this->page = $page; |
|
361 | + } |
|
356 | 362 | $this->limit = $limit; |
357 | 363 | |
358 | 364 | return $this; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $name = $this->decodeFolderName($item->name); |
311 | 311 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
312 | 312 | } |
313 | - }else{ |
|
313 | + } else{ |
|
314 | 314 | throw new RuntimeException(\imap_last_error()); |
315 | 315 | } |
316 | 316 | |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | |
335 | 335 | if ($mode == "+"){ |
336 | 336 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
337 | - }else{ |
|
337 | + } else{ |
|
338 | 338 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
339 | 339 | } |
340 | 340 |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | public function add($value, $strict = false) { |
75 | 75 | if (is_array($value)) { |
76 | 76 | return $this->merge($value, $strict); |
77 | - }elseif ($value !== null) { |
|
77 | + } elseif ($value !== null) { |
|
78 | 78 | $this->attach($value, $strict); |
79 | 79 | } |
80 | 80 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | if ($this->contains($value) === false) { |
124 | 124 | $this->values[] = $value; |
125 | 125 | } |
126 | - }else{ |
|
126 | + } else{ |
|
127 | 127 | $this->values[] = $value; |
128 | 128 | } |
129 | 129 | } |
@@ -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))) { |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | if ($this->getFlags()->get("seen") == null) { |
509 | 509 | $this->unsetFlag("Seen"); |
510 | 510 | } |
511 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
511 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
512 | 512 | $this->setFlag("Seen"); |
513 | 513 | } |
514 | 514 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | private function fetchPart(Part $part) { |
551 | 551 | if ($part->isAttachment()) { |
552 | 552 | $this->fetchAttachment($part); |
553 | - }else{ |
|
553 | + } else{ |
|
554 | 554 | $encoding = $this->getEncoding($part); |
555 | 555 | |
556 | 556 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -742,9 +742,9 @@ discard block |
||
742 | 742 | return EncodingAliases::get($parameter->value); |
743 | 743 | } |
744 | 744 | } |
745 | - }elseif (property_exists($structure, 'charset')){ |
|
745 | + } elseif (property_exists($structure, 'charset')){ |
|
746 | 746 | return EncodingAliases::get($structure->charset); |
747 | - }elseif (is_string($structure) === true){ |
|
747 | + } elseif (is_string($structure) === true){ |
|
748 | 748 | return mb_detect_encoding($structure); |
749 | 749 | } |
750 | 750 | |
@@ -924,13 +924,15 @@ discard block |
||
924 | 924 | * @throws MessageHeaderFetchingException |
925 | 925 | */ |
926 | 926 | protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
927 | - if($expunge) $this->client->expunge(); |
|
927 | + if($expunge) { |
|
928 | + $this->client->expunge(); |
|
929 | + } |
|
928 | 930 | |
929 | 931 | $this->client->openFolder($folder->path); |
930 | 932 | |
931 | 933 | if ($this->sequence === IMAP::ST_UID) { |
932 | 934 | $sequence_id = $next_uid; |
933 | - }else{ |
|
935 | + } else{ |
|
934 | 936 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
935 | 937 | } |
936 | 938 | |
@@ -952,7 +954,9 @@ discard block |
||
952 | 954 | */ |
953 | 955 | public function delete($expunge = true) { |
954 | 956 | $status = $this->setFlag("Deleted"); |
955 | - if($expunge) $this->client->expunge(); |
|
957 | + if($expunge) { |
|
958 | + $this->client->expunge(); |
|
959 | + } |
|
956 | 960 | |
957 | 961 | $event = $this->getEvent("message", "deleted"); |
958 | 962 | $event::dispatch($this); |
@@ -971,7 +975,9 @@ discard block |
||
971 | 975 | */ |
972 | 976 | public function restore($expunge = true) { |
973 | 977 | $status = $this->unsetFlag("Deleted"); |
974 | - if($expunge) $this->client->expunge(); |
|
978 | + if($expunge) { |
|
979 | + $this->client->expunge(); |
|
980 | + } |
|
975 | 981 | |
976 | 982 | $event = $this->getEvent("message", "restored"); |
977 | 983 | $event::dispatch($this); |
@@ -1384,7 +1390,7 @@ discard block |
||
1384 | 1390 | if ($this->getSequence() === IMAP::ST_UID) { |
1385 | 1391 | $this->setUid($uid); |
1386 | 1392 | $this->setMsglist($msglist); |
1387 | - }else{ |
|
1393 | + } else{ |
|
1388 | 1394 | $this->setMsgn($uid, $msglist); |
1389 | 1395 | } |
1390 | 1396 | } |
@@ -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 | |
@@ -433,9 +435,9 @@ discard block |
||
433 | 435 | } |
434 | 436 | } |
435 | 437 | } |
436 | - }elseif($decoder === 'iconv') { |
|
438 | + } elseif($decoder === 'iconv') { |
|
437 | 439 | $value = iconv_mime_decode($value); |
438 | - }else{ |
|
440 | + } else{ |
|
439 | 441 | $value = mb_decode_mimeheader($value); |
440 | 442 | } |
441 | 443 | |
@@ -468,7 +470,9 @@ discard block |
||
468 | 470 | * Try to extract the priority from a given raw header string |
469 | 471 | */ |
470 | 472 | private function findPriority() { |
471 | - if(($priority = $this->get("x_priority")) === null) return; |
|
473 | + if(($priority = $this->get("x_priority")) === null) { |
|
474 | + return; |
|
475 | + } |
|
472 | 476 | switch((int)"$priority"){ |
473 | 477 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
474 | 478 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -591,7 +595,7 @@ discard block |
||
591 | 595 | foreach ($this->attributes as $key => $value) { |
592 | 596 | if (is_array($value)) { |
593 | 597 | $value = implode(", ", $value); |
594 | - }else{ |
|
598 | + } else{ |
|
595 | 599 | $value = (string)$value; |
596 | 600 | } |
597 | 601 | // Only parse strings and don't parse any attributes like the user-agent |
@@ -233,7 +233,9 @@ discard block |
||
233 | 233 | } else { |
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | - if ($this->debug) echo "<< ".$line."\n"; |
|
236 | + if ($this->debug) { |
|
237 | + echo "<< ".$line."\n"; |
|
238 | + } |
|
237 | 239 | |
238 | 240 | // if tag is wanted tag we might be at the end of a multiline response |
239 | 241 | return $tag == $wantedTag; |
@@ -298,7 +300,9 @@ discard block |
||
298 | 300 | $line .= ' ' . $token; |
299 | 301 | } |
300 | 302 | } |
301 | - if ($this->debug) echo ">> ".$line."\n"; |
|
303 | + if ($this->debug) { |
|
304 | + echo ">> ".$line."\n"; |
|
305 | + } |
|
302 | 306 | |
303 | 307 | if (fwrite($this->stream, $line . "\r\n") === false) { |
304 | 308 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -448,7 +452,9 @@ discard block |
||
448 | 452 | public function getCapabilities() { |
449 | 453 | $response = $this->requestAndResponse('CAPABILITY'); |
450 | 454 | |
451 | - if (!$response) return []; |
|
455 | + if (!$response) { |
|
456 | + return []; |
|
457 | + } |
|
452 | 458 | |
453 | 459 | $capabilities = []; |
454 | 460 | foreach ($response as $line) { |
@@ -605,13 +611,14 @@ discard block |
||
605 | 611 | // if we want only one message we can ignore everything else and just return |
606 | 612 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
607 | 613 | // we still need to read all lines |
608 | - while (!$this->readLine($tokens, $tag)) |
|
609 | - |
|
614 | + while (!$this->readLine($tokens, $tag)) { |
|
615 | + |
|
610 | 616 | return $data; |
617 | + } |
|
611 | 618 | } |
612 | 619 | if ($uid) { |
613 | 620 | $result[$tokens[2][$uidKey]] = $data; |
614 | - }else{ |
|
621 | + } else{ |
|
615 | 622 | $result[$tokens[0]] = $data; |
616 | 623 | } |
617 | 624 | } |