@@ -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; |
@@ -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 |
@@ -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 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | public function set($name, $value, $strict = false) { |
121 | 121 | if(isset($this->attributes[$name]) && $strict === false) { |
122 | 122 | $this->attributes[$name]->add($value, true); |
123 | - }else{ |
|
123 | + } else{ |
|
124 | 124 | $this->attributes[$name] = new Attribute($name, $value); |
125 | 125 | } |
126 | 126 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | if ($prev_header !== null) { |
208 | 208 | $headers[$prev_header][] = $line; |
209 | 209 | } |
210 | - }elseif (substr($line, 0, 1) === " ") { |
|
210 | + } elseif (substr($line, 0, 1) === " ") { |
|
211 | 211 | $line = substr($line, 1); |
212 | 212 | $line = trim(rtrim($line)); |
213 | 213 | if ($prev_header !== null) { |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | } |
217 | 217 | if (is_array($headers[$prev_header])) { |
218 | 218 | $headers[$prev_header][] = $line; |
219 | - }else{ |
|
219 | + } else{ |
|
220 | 220 | $headers[$prev_header] .= $line; |
221 | 221 | } |
222 | 222 | } |
223 | - }else{ |
|
223 | + } else{ |
|
224 | 224 | if (($pos = strpos($line, ":")) > 0) { |
225 | 225 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
226 | 226 | $key = str_replace("-", "_", $key); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $value = trim(rtrim(substr($line, $pos + 1))); |
229 | 229 | if (isset($headers[$key])) { |
230 | 230 | $headers[$key][] = $value; |
231 | - }else{ |
|
231 | + } else{ |
|
232 | 232 | $headers[$key] = [$value]; |
233 | 233 | } |
234 | 234 | $prev_header = $key; |
@@ -237,7 +237,9 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | foreach($headers as $key => $values) { |
240 | - if (isset($imap_headers[$key])) continue; |
|
240 | + if (isset($imap_headers[$key])) { |
|
241 | + continue; |
|
242 | + } |
|
241 | 243 | $value = null; |
242 | 244 | switch($key){ |
243 | 245 | case 'from': |
@@ -374,9 +376,9 @@ discard block |
||
374 | 376 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
375 | 377 | } |
376 | 378 | } |
377 | - }elseif (property_exists($structure, 'charset')) { |
|
379 | + } elseif (property_exists($structure, 'charset')) { |
|
378 | 380 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
379 | - }elseif (is_string($structure) === true){ |
|
381 | + } elseif (is_string($structure) === true){ |
|
380 | 382 | return mb_detect_encoding($structure); |
381 | 383 | } |
382 | 384 | |
@@ -410,9 +412,9 @@ discard block |
||
410 | 412 | } |
411 | 413 | } |
412 | 414 | } |
413 | - }elseif($decoder === 'iconv') { |
|
415 | + } elseif($decoder === 'iconv') { |
|
414 | 416 | $value = iconv_mime_decode($value); |
415 | - }else{ |
|
417 | + } else{ |
|
416 | 418 | $value = mb_decode_mimeheader($value); |
417 | 419 | } |
418 | 420 | |
@@ -445,7 +447,9 @@ discard block |
||
445 | 447 | * Try to extract the priority from a given raw header string |
446 | 448 | */ |
447 | 449 | private function findPriority() { |
448 | - if(($priority = $this->get("x_priority")) === null) return; |
|
450 | + if(($priority = $this->get("x_priority")) === null) { |
|
451 | + return; |
|
452 | + } |
|
449 | 453 | switch((int)"$priority"){ |
450 | 454 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
451 | 455 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | if ($this->sequence === IMAP::ST_UID) { |
228 | 228 | $this->uid = $uid; |
229 | 229 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
230 | - }else{ |
|
230 | + } else{ |
|
231 | 231 | $this->msgn = $uid; |
232 | 232 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
233 | 233 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | if ($instance->getSequence() === IMAP::ST_UID) { |
295 | 295 | $instance->setUid($uid); |
296 | 296 | $instance->setMsglist($msglist); |
297 | - }else{ |
|
297 | + } else{ |
|
298 | 298 | $instance->setMsgn($uid, $msglist); |
299 | 299 | } |
300 | 300 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | if(strtolower(substr($method, 0, 3)) === 'get') { |
319 | 319 | $name = Str::snake(substr($method, 3)); |
320 | 320 | return $this->get($name); |
321 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
321 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
322 | 322 | $name = Str::snake(substr($method, 3)); |
323 | 323 | |
324 | 324 | if(in_array($name, array_keys($this->attributes))) { |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | if ($this->getFlags()->get("seen") == null) { |
522 | 522 | $this->unsetFlag("Seen"); |
523 | 523 | } |
524 | - }elseif ($this->getFlags()->get("seen") != null) { |
|
524 | + } elseif ($this->getFlags()->get("seen") != null) { |
|
525 | 525 | $this->setFlag("Seen"); |
526 | 526 | } |
527 | 527 | } |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | private function fetchPart(Part $part) { |
564 | 564 | if ($part->isAttachment()) { |
565 | 565 | $this->fetchAttachment($part); |
566 | - }else{ |
|
566 | + } else{ |
|
567 | 567 | $encoding = $this->getEncoding($part); |
568 | 568 | |
569 | 569 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -755,9 +755,9 @@ discard block |
||
755 | 755 | return EncodingAliases::get($parameter->value); |
756 | 756 | } |
757 | 757 | } |
758 | - }elseif (property_exists($structure, 'charset')){ |
|
758 | + } elseif (property_exists($structure, 'charset')){ |
|
759 | 759 | return EncodingAliases::get($structure->charset); |
760 | - }elseif (is_string($structure) === true){ |
|
760 | + } elseif (is_string($structure) === true){ |
|
761 | 761 | return mb_detect_encoding($structure); |
762 | 762 | } |
763 | 763 | |
@@ -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 | |
@@ -965,7 +967,9 @@ discard block |
||
965 | 967 | */ |
966 | 968 | public function delete($expunge = true) { |
967 | 969 | $status = $this->setFlag("Deleted"); |
968 | - if($expunge) $this->client->expunge(); |
|
970 | + if($expunge) { |
|
971 | + $this->client->expunge(); |
|
972 | + } |
|
969 | 973 | |
970 | 974 | $event = $this->getEvent("message", "deleted"); |
971 | 975 | $event::dispatch($this); |
@@ -984,7 +988,9 @@ discard block |
||
984 | 988 | */ |
985 | 989 | public function restore($expunge = true) { |
986 | 990 | $status = $this->unsetFlag("Deleted"); |
987 | - if($expunge) $this->client->expunge(); |
|
991 | + if($expunge) { |
|
992 | + $this->client->expunge(); |
|
993 | + } |
|
988 | 994 | |
989 | 995 | $event = $this->getEvent("message", "restored"); |
990 | 996 | $event::dispatch($this); |