Completed
Push — master ( d77b64...e60d4a )
by Malte
02:19
created
src/Folder.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -232,7 +232,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
                 }
Please login to merge, or discard this patch.
src/Client.php 1 patch
Braces   +15 added lines, -13 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Query/Query.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -258,9 +258,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Attribute.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Header.php 1 patch
Braces   +15 added lines, -11 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Message.php 1 patch
Braces   +16 added lines, -10 removed lines patch added patch discarded remove patch
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.