@@ -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; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | if ($this->sequence === IMAP::ST_UID) { |
225 | 225 | $this->uid = $uid; |
226 | 226 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
227 | - }else{ |
|
227 | + } else{ |
|
228 | 228 | $this->msgn = $uid; |
229 | 229 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
230 | 230 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | if ($instance->getSequence() === IMAP::ST_UID) { |
290 | 290 | $instance->setUid($uid); |
291 | 291 | $instance->setMsglist($msglist); |
292 | - }else{ |
|
292 | + } else{ |
|
293 | 293 | $instance->setMsgn($uid, $msglist); |
294 | 294 | } |
295 | 295 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | if(strtolower(substr($method, 0, 3)) === 'get') { |
321 | 321 | $name = Str::snake(substr($method, 3)); |
322 | 322 | return $this->get($name); |
323 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
323 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
324 | 324 | $name = Str::snake(substr($method, 3)); |
325 | 325 | |
326 | 326 | if(in_array($name, array_keys($this->attributes))) { |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | if ($this->getFlags()->get("seen") == null) { |
506 | 506 | $this->unsetFlag("Seen"); |
507 | 507 | } |
508 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
508 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
509 | 509 | $this->setFlag("Seen"); |
510 | 510 | } |
511 | 511 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | |
554 | 554 | if ($part->isAttachment()) { |
555 | 555 | $this->fetchAttachment($part); |
556 | - }else{ |
|
556 | + } else{ |
|
557 | 557 | $encoding = $this->getEncoding($part); |
558 | 558 | |
559 | 559 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | return EncodingAliases::get($parameter->value); |
747 | 747 | } |
748 | 748 | } |
749 | - }elseif (property_exists($structure, 'charset')){ |
|
749 | + } elseif (property_exists($structure, 'charset')){ |
|
750 | 750 | return EncodingAliases::get($structure->charset); |
751 | - }elseif (is_string($structure) === true){ |
|
751 | + } elseif (is_string($structure) === true){ |
|
752 | 752 | return mb_detect_encoding($structure); |
753 | 753 | } |
754 | 754 | |
@@ -849,13 +849,15 @@ discard block |
||
849 | 849 | |
850 | 850 | $this->client->openFolder($this->folder_path); |
851 | 851 | if ($this->client->getConnection()->copyMessage($folder->path, $this->getSequenceId(), null, $this->sequence === IMAP::ST_UID) == true) { |
852 | - if($expunge) $this->client->expunge(); |
|
852 | + if($expunge) { |
|
853 | + $this->client->expunge(); |
|
854 | + } |
|
853 | 855 | |
854 | 856 | $this->client->openFolder($folder->path); |
855 | 857 | |
856 | 858 | if ($this->sequence === IMAP::ST_UID) { |
857 | 859 | $sequence_id = $next_uid; |
858 | - }else{ |
|
860 | + } else{ |
|
859 | 861 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
860 | 862 | } |
861 | 863 | |
@@ -896,13 +898,15 @@ discard block |
||
896 | 898 | |
897 | 899 | $this->client->openFolder($this->folder_path); |
898 | 900 | if ($this->client->getConnection()->moveMessage($folder->path, $this->getSequenceId(), null, $this->sequence === IMAP::ST_UID) == true) { |
899 | - if($expunge) $this->client->expunge(); |
|
901 | + if($expunge) { |
|
902 | + $this->client->expunge(); |
|
903 | + } |
|
900 | 904 | |
901 | 905 | $this->client->openFolder($folder->path); |
902 | 906 | |
903 | 907 | if ($this->sequence === IMAP::ST_UID) { |
904 | 908 | $sequence_id = $next_uid; |
905 | - }else{ |
|
909 | + } else{ |
|
906 | 910 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
907 | 911 | } |
908 | 912 | |
@@ -928,7 +932,9 @@ discard block |
||
928 | 932 | */ |
929 | 933 | public function delete($expunge = true) { |
930 | 934 | $status = $this->setFlag("Deleted"); |
931 | - if($expunge) $this->client->expunge(); |
|
935 | + if($expunge) { |
|
936 | + $this->client->expunge(); |
|
937 | + } |
|
932 | 938 | |
933 | 939 | $event = $this->getEvent("message", "deleted"); |
934 | 940 | $event::dispatch($this); |
@@ -947,7 +953,9 @@ discard block |
||
947 | 953 | */ |
948 | 954 | public function restore($expunge = true) { |
949 | 955 | $status = $this->unsetFlag("Deleted"); |
950 | - if($expunge) $this->client->expunge(); |
|
956 | + if($expunge) { |
|
957 | + $this->client->expunge(); |
|
958 | + } |
|
951 | 959 | |
952 | 960 | $event = $this->getEvent("message", "restored"); |
953 | 961 | $event::dispatch($this); |
@@ -258,9 +258,13 @@ discard block |
||
258 | 258 | $tokens = [substr($tokens, 0, 2)]; |
259 | 259 | } |
260 | 260 | if (is_array($lines)){ |
261 | - if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
|
262 | - }else{ |
|
263 | - if ($this->debug) echo "<< ".$lines."\n"; |
|
261 | + if ($this->debug) { |
|
262 | + echo "<< ".json_encode($lines)."\n"; |
|
263 | + } |
|
264 | + } else{ |
|
265 | + if ($this->debug) { |
|
266 | + echo "<< ".$lines."\n"; |
|
267 | + } |
|
264 | 268 | } |
265 | 269 | |
266 | 270 | // last line has response code |
@@ -302,7 +306,9 @@ discard block |
||
302 | 306 | $line .= ' ' . $token; |
303 | 307 | } |
304 | 308 | } |
305 | - if ($this->debug) echo ">> ".$line."\n"; |
|
309 | + if ($this->debug) { |
|
310 | + echo ">> ".$line."\n"; |
|
311 | + } |
|
306 | 312 | |
307 | 313 | if (fwrite($this->stream, $line . "\r\n") === false) { |
308 | 314 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -452,7 +458,9 @@ discard block |
||
452 | 458 | public function getCapabilities() { |
453 | 459 | $response = $this->requestAndResponse('CAPABILITY'); |
454 | 460 | |
455 | - if (!$response) return []; |
|
461 | + if (!$response) { |
|
462 | + return []; |
|
463 | + } |
|
456 | 464 | |
457 | 465 | $capabilities = []; |
458 | 466 | foreach ($response as $line) { |
@@ -609,13 +617,14 @@ discard block |
||
609 | 617 | // if we want only one message we can ignore everything else and just return |
610 | 618 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
611 | 619 | // we still need to read all lines |
612 | - while (!$this->readLine($tokens, $tag)) |
|
613 | - |
|
620 | + while (!$this->readLine($tokens, $tag)) { |
|
621 | + |
|
614 | 622 | return $data; |
623 | + } |
|
615 | 624 | } |
616 | 625 | if ($uid) { |
617 | 626 | $result[$tokens[2][$uidKey]] = $data; |
618 | - }else{ |
|
627 | + } else{ |
|
619 | 628 | $result[$tokens[0]] = $data; |
620 | 629 | } |
621 | 630 | } |
@@ -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 |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | if ($prev_header !== null) { |
193 | 193 | $headers[$prev_header][] = $line; |
194 | 194 | } |
195 | - }elseif (substr($line, 0, 1) === " ") { |
|
195 | + } elseif (substr($line, 0, 1) === " ") { |
|
196 | 196 | $line = substr($line, 1); |
197 | 197 | $line = trim(rtrim($line)); |
198 | 198 | if ($prev_header !== null) { |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | if (is_array($headers[$prev_header])) { |
203 | 203 | $headers[$prev_header][] = $line; |
204 | - }else{ |
|
204 | + } else{ |
|
205 | 205 | $headers[$prev_header] .= $line; |
206 | 206 | } |
207 | 207 | } |
208 | - }else{ |
|
208 | + } else{ |
|
209 | 209 | if (($pos = strpos($line, ":")) > 0) { |
210 | 210 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
211 | 211 | $key = str_replace("-", "_", $key); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | $value = trim(rtrim(substr($line, $pos + 1))); |
214 | 214 | if (isset($headers[$key])) { |
215 | 215 | $headers[$key][] = $value; |
216 | - }else{ |
|
216 | + } else{ |
|
217 | 217 | $headers[$key] = [$value]; |
218 | 218 | } |
219 | 219 | $prev_header = $key; |
@@ -222,7 +222,9 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | foreach($headers as $key => $values) { |
225 | - if (isset($imap_headers[$key])) continue; |
|
225 | + if (isset($imap_headers[$key])) { |
|
226 | + continue; |
|
227 | + } |
|
226 | 228 | $value = null; |
227 | 229 | switch($key){ |
228 | 230 | case 'from': |
@@ -359,9 +361,9 @@ discard block |
||
359 | 361 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
360 | 362 | } |
361 | 363 | } |
362 | - }elseif (property_exists($structure, 'charset')) { |
|
364 | + } elseif (property_exists($structure, 'charset')) { |
|
363 | 365 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
364 | - }elseif (is_string($structure) === true){ |
|
366 | + } elseif (is_string($structure) === true){ |
|
365 | 367 | return mb_detect_encoding($structure); |
366 | 368 | } |
367 | 369 | |
@@ -395,9 +397,9 @@ discard block |
||
395 | 397 | } |
396 | 398 | } |
397 | 399 | } |
398 | - }elseif($decoder === 'iconv') { |
|
400 | + } elseif($decoder === 'iconv') { |
|
399 | 401 | $value = iconv_mime_decode($value); |
400 | - }else{ |
|
402 | + } else{ |
|
401 | 403 | $value = mb_decode_mimeheader($value); |
402 | 404 | } |
403 | 405 | |
@@ -430,7 +432,9 @@ discard block |
||
430 | 432 | * Try to extract the priority from a given raw header string |
431 | 433 | */ |
432 | 434 | private function findPriority() { |
433 | - if(($priority = $this->get("x_priority")) === null) return; |
|
435 | + if(($priority = $this->get("x_priority")) === null) { |
|
436 | + return; |
|
437 | + } |
|
434 | 438 | switch($priority){ |
435 | 439 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
436 | 440 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |