Passed
Pull Request — master (#326)
by
unknown
02:22
created
src/Connection/Protocols/ImapProtocol.php 2 patches
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -111,7 +111,9 @@  discard block
 block discarded – undo
111 111
         if ($line === "" && $next_char === false) {
112 112
             throw new RuntimeException('empty response');
113 113
         }
114
-        if ($this->debug) echo "<< ".$line."\n";
114
+        if ($this->debug) {
115
+            echo "<< ".$line."\n";
116
+        }
115 117
         return $line . "\n";
116 118
     }
117 119
 
@@ -325,7 +327,9 @@  discard block
 block discarded – undo
325 327
      * @throws RuntimeException
326 328
      */
327 329
     public function write(string $data) {
328
-        if ($this->debug) echo ">> ".$data ."\n";
330
+        if ($this->debug) {
331
+            echo ">> ".$data ."\n";
332
+        }
329 333
 
330 334
         if (fwrite($this->stream, $data . "\r\n") === false) {
331 335
             throw new RuntimeException('failed to write - connection closed?');
@@ -477,7 +481,9 @@  discard block
 block discarded – undo
477 481
     public function getCapabilities(): array {
478 482
         $response = $this->requestAndResponse('CAPABILITY');
479 483
 
480
-        if (!$response) return [];
484
+        if (!$response) {
485
+            return [];
486
+        }
481 487
 
482 488
         $capabilities = [];
483 489
         foreach ($response as $line) {
@@ -644,13 +650,14 @@  discard block
 block discarded – undo
644 650
             // if we want only one message we can ignore everything else and just return
645 651
             if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) {
646 652
                 // we still need to read all lines
647
-                while (!$this->readLine($tokens, $tag))
648
-
653
+                while (!$this->readLine($tokens, $tag)) {
654
+                
649 655
                     return $data;
656
+                }
650 657
             }
651 658
             if ($uid) {
652 659
                 $result[$tokens[2][$uidKey]] = $data;
653
-            }else{
660
+            } else{
654 661
                 $result[$tokens[0]] = $data;
655 662
             }
656 663
         }
@@ -1080,7 +1087,9 @@  discard block
 block discarded – undo
1080 1087
     public function search(array $params, $uid = IMAP::ST_UID): array {
1081 1088
         $command = $this->buildUIDCommand("SEARCH", $uid);
1082 1089
         $response = $this->requestAndResponse($command, $params);
1083
-        if (!$response) return [];
1090
+        if (!$response) {
1091
+            return [];
1092
+        }
1084 1093
 
1085 1094
         foreach ($response as $ids) {
1086 1095
             if ($ids[0] == 'SEARCH') {
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      * @throws ConnectionFailedException
90 90
      * @throws RuntimeException
91 91
      */
92
-    protected function enableStartTls(){
92
+    protected function enableStartTls() {
93 93
         $response = $this->requestAndResponse('STARTTLS');
94 94
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
95 95
         if (!$result) {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             throw new RuntimeException('empty response');
113 113
         }
114 114
         if ($this->debug) echo "<< ".$line."\n";
115
-        return $line . "\n";
115
+        return $line."\n";
116 116
     }
117 117
 
118 118
     /**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         $stack = [];
166 166
 
167 167
         //  replace any trailing <NL> including spaces with a single space
168
-        $line = rtrim($line) . ' ';
168
+        $line = rtrim($line).' ';
169 169
         while (($pos = strpos($line, ' ')) !== false) {
170 170
             $token = substr($line, 0, $pos);
171 171
             if (!strlen($token)) {
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
                     if (strlen($token) > $chars) {
196 196
                         $line = substr($token, $chars);
197 197
                         $token = substr($token, 0, $chars);
198
-                    } else {
198
+                    }else {
199 199
                         $line .= $this->nextLine();
200 200
                     }
201 201
                     $tokens[] = $token;
202
-                    $line = trim($line) . ' ';
202
+                    $line = trim($line).' ';
203 203
                     continue;
204 204
                 }
205 205
             }
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
         $line = $this->nextTaggedLine($tag); // get next tag
250 250
         if (!$dontParse) {
251 251
             $tokens = $this->decodeLine($line);
252
-        } else {
252
+        }else {
253 253
             $tokens = $line;
254 254
         }
255 255
 
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
     public function sendRequest(string $command, array $tokens = [], string &$tag = null) {
300 300
         if (!$tag) {
301 301
             $this->noun++;
302
-            $tag = 'TAG' . $this->noun;
302
+            $tag = 'TAG'.$this->noun;
303 303
         }
304 304
 
305
-        $line = $tag . ' ' . $command;
305
+        $line = $tag.' '.$command;
306 306
 
307 307
         foreach ($tokens as $token) {
308 308
             if (is_array($token)) {
309
-                $this->write($line . ' ' . $token[0]);
309
+                $this->write($line.' '.$token[0]);
310 310
                 if (!$this->assumedNextLine('+ ')) {
311 311
                     throw new RuntimeException('failed to send literal string');
312 312
                 }
313 313
                 $line = $token[1];
314
-            } else {
315
-                $line .= ' ' . $token;
314
+            }else {
315
+                $line .= ' '.$token;
316 316
             }
317 317
         }
318 318
         $this->write($line);
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
      * @throws RuntimeException
326 326
      */
327 327
     public function write(string $data) {
328
-        if ($this->debug) echo ">> ".$data ."\n";
328
+        if ($this->debug) echo ">> ".$data."\n";
329 329
 
330
-        if (fwrite($this->stream, $data . "\r\n") === false) {
330
+        if (fwrite($this->stream, $data."\r\n") === false) {
331 331
             throw new RuntimeException('failed to write - connection closed?');
332 332
         }
333 333
     }
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
     public function escapeString($string) {
358 358
         if (func_num_args() < 2) {
359 359
             if (strpos($string, "\n") !== false) {
360
-                return ['{' . strlen($string) . '}', $string];
361
-            } else {
362
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
360
+                return ['{'.strlen($string).'}', $string];
361
+            }else {
362
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
363 363
             }
364 364
         }
365 365
         $result = [];
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
             }
385 385
             $result[] = $this->escapeList($v);
386 386
         }
387
-        return '(' . implode(' ', $result) . ')';
387
+        return '('.implode(' ', $result).')';
388 388
     }
389 389
 
390 390
     /**
@@ -425,12 +425,12 @@  discard block
 block discarded – undo
425 425
                     error_log("got an extra server challenge: $response");
426 426
                     // respond with an empty response.
427 427
                     $this->sendRequest('');
428
-                } else {
428
+                }else {
429 429
                     if (preg_match('/^NO /i', $response) ||
430 430
                         preg_match('/^BAD /i', $response)) {
431 431
                         error_log("got failure response: $response");
432 432
                         return false;
433
-                    } else if (preg_match("/^OK /i", $response)) {
433
+                    }else if (preg_match("/^OK /i", $response)) {
434 434
                         return true;
435 435
                     }
436 436
                 }
@@ -508,16 +508,16 @@  discard block
 block discarded – undo
508 508
             switch ($tokens[1]) {
509 509
                 case 'EXISTS':
510 510
                 case 'RECENT':
511
-                    $result[strtolower($tokens[1])] = (int)$tokens[0];
511
+                    $result[strtolower($tokens[1])] = (int) $tokens[0];
512 512
                     break;
513 513
                 case '[UIDVALIDITY':
514
-                    $result['uidvalidity'] = (int)$tokens[2];
514
+                    $result['uidvalidity'] = (int) $tokens[2];
515 515
                     break;
516 516
                 case '[UIDNEXT':
517
-                    $result['uidnext'] = (int)$tokens[2];
517
+                    $result['uidnext'] = (int) $tokens[2];
518 518
                     break;
519 519
                 case '[UNSEEN':
520
-                    $result['unseen'] = (int)$tokens[2];
520
+                    $result['unseen'] = (int) $tokens[2];
521 521
                     break;
522 522
                 case '[NONEXISTENT]':
523 523
                     throw new RuntimeException("folder doesn't exist");
@@ -576,14 +576,14 @@  discard block
 block discarded – undo
576 576
         if (is_array($from)) {
577 577
             $set = implode(',', $from);
578 578
         } elseif ($to === null) {
579
-            $set = (int)$from;
579
+            $set = (int) $from;
580 580
         } elseif ($to === INF) {
581
-            $set = (int)$from . ':*';
582
-        } else {
583
-            $set = (int)$from . ':' . (int)$to;
581
+            $set = (int) $from.':*';
582
+        }else {
583
+            $set = (int) $from.':'.(int) $to;
584 584
         }
585 585
 
586
-        $items = (array)$items;
586
+        $items = (array) $items;
587 587
         $itemList = $this->escapeList($items);
588 588
 
589 589
         $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag);
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
                 $count = count($tokens[2]);
601 601
                 if ($tokens[2][$count - 2] == 'UID') {
602 602
                     $uidKey = $count - 1;
603
-                } else if ($tokens[2][0] == 'UID') {
603
+                }else if ($tokens[2][0] == 'UID') {
604 604
                     $uidKey = 1;
605
-                } else {
605
+                }else {
606 606
                     $found = array_search('UID', $tokens[2]);
607 607
                     if ($found === false || $found === -1) {
608 608
                         continue;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
                     $data = $tokens[2][1];
624 624
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
625 625
                     $data = $tokens[2][3];
626
-                } else {
626
+                }else {
627 627
                     $expectedResponse = 0;
628 628
                     // maybe the server send an other field we didn't wanted
629 629
                     $count = count($tokens[2]);
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                         continue;
641 641
                     }
642 642
                 }
643
-            } else {
643
+            }else {
644 644
                 $data = [];
645 645
                 while (key($tokens[2]) !== null) {
646 646
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
             }
658 658
             if ($uid) {
659 659
                 $result[$tokens[2][$uidKey]] = $data;
660
-            }else{
660
+            }else {
661 661
                 $result[$tokens[0]] = $data;
662 662
             }
663 663
         }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         $ids = $this->getUid();
759 759
         foreach ($ids as $k => $v) {
760 760
             if ($v == $id) {
761
-                return (int)$k;
761
+                return (int) $k;
762 762
             }
763 763
         }
764 764
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
816 816
 
817 817
         if ($silent) {
818
-            return (bool)$response;
818
+            return (bool) $response;
819 819
         }
820 820
 
821 821
         $result = [];
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
     public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool {
869 869
         $set = $this->buildSet($from, $to);
870 870
         $command = $this->buildUIDCommand("COPY", $uid);
871
-        return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
871
+        return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
872 872
     }
873 873
 
874 874
     /**
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
         $set = $this->buildSet($from, $to);
908 908
         $command = $this->buildUIDCommand("MOVE", $uid);
909 909
 
910
-        return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
910
+        return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true);
911 911
     }
912 912
 
913 913
     /**
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
      * @throws RuntimeException
960 960
      */
961 961
     public function createFolder(string $folder): bool {
962
-        return (bool)$this->requestAndResponse('CREATE', [$this->escapeString($folder)], true);
962
+        return (bool) $this->requestAndResponse('CREATE', [$this->escapeString($folder)], true);
963 963
     }
964 964
 
965 965
     /**
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
      * @throws RuntimeException
972 972
      */
973 973
     public function renameFolder(string $old, string $new): bool {
974
-        return (bool)$this->requestAndResponse('RENAME', $this->escapeString($old, $new), true);
974
+        return (bool) $this->requestAndResponse('RENAME', $this->escapeString($old, $new), true);
975 975
     }
976 976
 
977 977
     /**
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
      * @throws RuntimeException
983 983
      */
984 984
     public function deleteFolder(string $folder): bool {
985
-        return (bool)$this->requestAndResponse('DELETE', [$this->escapeString($folder)], true);
985
+        return (bool) $this->requestAndResponse('DELETE', [$this->escapeString($folder)], true);
986 986
     }
987 987
 
988 988
     /**
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
      * @throws RuntimeException
994 994
      */
995 995
     public function subscribeFolder(string $folder): bool {
996
-        return (bool)$this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true);
996
+        return (bool) $this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true);
997 997
     }
998 998
 
999 999
     /**
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
      * @throws RuntimeException
1005 1005
      */
1006 1006
     public function unsubscribeFolder(string $folder): bool {
1007
-        return (bool)$this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true);
1007
+        return (bool) $this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true);
1008 1008
     }
1009 1009
 
1010 1010
     /**
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
      * @throws RuntimeException
1015 1015
      */
1016 1016
     public function expunge(): bool {
1017
-        return (bool)$this->requestAndResponse('EXPUNGE');
1017
+        return (bool) $this->requestAndResponse('EXPUNGE');
1018 1018
     }
1019 1019
 
1020 1020
     /**
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
      * @throws RuntimeException
1025 1025
      */
1026 1026
     public function noop(): bool {
1027
-        return (bool)$this->requestAndResponse('NOOP');
1027
+        return (bool) $this->requestAndResponse('NOOP');
1028 1028
     }
1029 1029
 
1030 1030
     /**
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
         $ids = [];
1118 1118
         foreach ($uids as $msgn => $v) {
1119 1119
             $id = $uid ? $v : $msgn;
1120
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1120
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1121 1121
                 $ids[] = $id;
1122 1122
             }
1123 1123
         }
@@ -1131,14 +1131,14 @@  discard block
 block discarded – undo
1131 1131
     /**
1132 1132
      * Enable the debug mode
1133 1133
      */
1134
-    public function enableDebug(){
1134
+    public function enableDebug() {
1135 1135
         $this->debug = true;
1136 1136
     }
1137 1137
 
1138 1138
     /**
1139 1139
      * Disable the debug mode
1140 1140
      */
1141
-    public function disableDebug(){
1141
+    public function disableDebug() {
1142 1142
         $this->debug = false;
1143 1143
     }
1144 1144
 
@@ -1150,9 +1150,9 @@  discard block
 block discarded – undo
1150 1150
      * @return int|string
1151 1151
      */
1152 1152
     public function buildSet($from, $to = null) {
1153
-        $set = (int)$from;
1153
+        $set = (int) $from;
1154 1154
         if ($to !== null) {
1155
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
1155
+            $set .= ':'.($to == INF ? '*' : (int) $to);
1156 1156
         }
1157 1157
         return $set;
1158 1158
     }
Please login to merge, or discard this patch.
src/Client.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
      * @param array $config
211 211
      * @param array $default_config
212 212
      */
213
-    private function setAccountConfig(string $key, array $config, array $default_config){
213
+    private function setAccountConfig(string $key, array $config, array $default_config) {
214 214
         $value = $this->default_account_config[$key];
215
-        if(isset($config[$key])) {
215
+        if (isset($config[$key])) {
216 216
             $value = $config[$key];
217
-        }elseif(isset($default_config[$key])) {
217
+        }elseif (isset($default_config[$key])) {
218 218
             $value = $default_config[$key];
219 219
         }
220 220
         $this->$key = $value;
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function setEventsFromConfig($config) {
228 228
         $this->events = ClientManager::get("events");
229
-        if(isset($config['events'])){
230
-            foreach($config['events'] as $section => $events) {
229
+        if (isset($config['events'])) {
230
+            foreach ($config['events'] as $section => $events) {
231 231
                 $this->events[$section] = array_merge($this->events[$section], $events);
232 232
             }
233 233
         }
@@ -240,45 +240,45 @@  discard block
 block discarded – undo
240 240
      * @throws MaskNotFoundException
241 241
      */
242 242
     protected function setMaskFromConfig($config) {
243
-        $default_config  = ClientManager::get("masks");
243
+        $default_config = ClientManager::get("masks");
244 244
 
245
-        if(isset($config['masks'])){
246
-            if(isset($config['masks']['message'])) {
247
-                if(class_exists($config['masks']['message'])) {
245
+        if (isset($config['masks'])) {
246
+            if (isset($config['masks']['message'])) {
247
+                if (class_exists($config['masks']['message'])) {
248 248
                     $this->default_message_mask = $config['masks']['message'];
249
-                }else{
249
+                }else {
250 250
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
251 251
                 }
252
-            }else{
253
-                if(class_exists($default_config['message'])) {
252
+            }else {
253
+                if (class_exists($default_config['message'])) {
254 254
                     $this->default_message_mask = $default_config['message'];
255
-                }else{
255
+                }else {
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
257 257
                 }
258 258
             }
259
-            if(isset($config['masks']['attachment'])) {
260
-                if(class_exists($config['masks']['attachment'])) {
259
+            if (isset($config['masks']['attachment'])) {
260
+                if (class_exists($config['masks']['attachment'])) {
261 261
                     $this->default_attachment_mask = $config['masks']['attachment'];
262
-                }else{
262
+                }else {
263 263
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
264 264
                 }
265
-            }else{
266
-                if(class_exists($default_config['attachment'])) {
265
+            }else {
266
+                if (class_exists($default_config['attachment'])) {
267 267
                     $this->default_attachment_mask = $default_config['attachment'];
268
-                }else{
268
+                }else {
269 269
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
270 270
                 }
271 271
             }
272
-        }else{
273
-            if(class_exists($default_config['message'])) {
272
+        }else {
273
+            if (class_exists($default_config['message'])) {
274 274
                 $this->default_message_mask = $default_config['message'];
275
-            }else{
275
+            }else {
276 276
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
277 277
             }
278 278
 
279
-            if(class_exists($default_config['attachment'])) {
279
+            if (class_exists($default_config['attachment'])) {
280 280
                 $this->default_attachment_mask = $default_config['attachment'];
281
-            }else{
281
+            }else {
282 282
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
283 283
             }
284 284
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
343 343
             $this->connection->setConnectionTimeout($this->timeout);
344 344
             $this->connection->setProxy($this->proxy);
345
-        }else{
345
+        }else {
346 346
             if (extension_loaded('imap') === false) {
347 347
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
348 348
             }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 
424 424
         // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names)
425 425
         $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter;
426
-        if (strpos($folder_name, (string)$delimiter) !== false) {
426
+        if (strpos($folder_name, (string) $delimiter) !== false) {
427 427
             return $this->getFolderByPath($folder_name);
428 428
         }
429 429
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
476 476
         $items = $this->connection->folders('', $pattern);
477 477
 
478
-        if(is_array($items)){
478
+        if (is_array($items)) {
479 479
             foreach ($items as $folder_name => $item) {
480 480
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
481 481
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
 
492 492
             return $folders;
493
-        }else{
493
+        }else {
494 494
             throw new FolderFetchingException("failed to fetch any folders");
495 495
         }
496 496
     }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
515 515
         $items = $this->connection->folders('', $pattern);
516 516
 
517
-        if(is_array($items)){
517
+        if (is_array($items)) {
518 518
             foreach ($items as $folder_name => $item) {
519 519
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
520 520
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             }
531 531
 
532 532
             return $folders;
533
-        }else{
533
+        }else {
534 534
             throw new FolderFetchingException("failed to fetch any folders");
535 535
         }
536 536
     }
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
         $this->checkConnection();
569 569
         $status = $this->connection->createFolder($folder);
570 570
 
571
-        if($expunge) $this->expunge();
571
+        if ($expunge) $this->expunge();
572 572
 
573 573
         $folder = $this->getFolder($folder);
574
-        if($status && $folder) {
574
+        if ($status && $folder) {
575 575
             $event = $this->getEvent("folder", "new");
576 576
             $event::dispatch($folder);
577 577
         }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
      *
598 598
      * @return string
599 599
      */
600
-    public function getFolderPath(){
600
+    public function getFolderPath() {
601 601
         return $this->active_folder;
602 602
     }
603 603
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
      * @throws MaskNotFoundException
710 710
      */
711 711
     public function setDefaultMessageMask(string $mask): Client {
712
-        if(class_exists($mask)) {
712
+        if (class_exists($mask)) {
713 713
             $this->default_message_mask = $mask;
714 714
 
715 715
             return $this;
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      * @throws MaskNotFoundException
736 736
      */
737 737
     public function setDefaultAttachmentMask(string $mask): Client {
738
-        if(class_exists($mask)) {
738
+        if (class_exists($mask)) {
739 739
             $this->default_attachment_mask = $mask;
740 740
 
741 741
             return $this;
Please login to merge, or discard this patch.
Braces   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $value = $this->default_account_config[$key];
215 215
         if(isset($config[$key])) {
216 216
             $value = $config[$key];
217
-        }elseif(isset($default_config[$key])) {
217
+        } elseif(isset($default_config[$key])) {
218 218
             $value = $default_config[$key];
219 219
         }
220 220
         $this->$key = $value;
@@ -246,39 +246,39 @@  discard block
 block discarded – undo
246 246
             if(isset($config['masks']['message'])) {
247 247
                 if(class_exists($config['masks']['message'])) {
248 248
                     $this->default_message_mask = $config['masks']['message'];
249
-                }else{
249
+                } else{
250 250
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
251 251
                 }
252
-            }else{
252
+            } else{
253 253
                 if(class_exists($default_config['message'])) {
254 254
                     $this->default_message_mask = $default_config['message'];
255
-                }else{
255
+                } else{
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
257 257
                 }
258 258
             }
259 259
             if(isset($config['masks']['attachment'])) {
260 260
                 if(class_exists($config['masks']['attachment'])) {
261 261
                     $this->default_attachment_mask = $config['masks']['attachment'];
262
-                }else{
262
+                } else{
263 263
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
264 264
                 }
265
-            }else{
265
+            } else{
266 266
                 if(class_exists($default_config['attachment'])) {
267 267
                     $this->default_attachment_mask = $default_config['attachment'];
268
-                }else{
268
+                } else{
269 269
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
270 270
                 }
271 271
             }
272
-        }else{
272
+        } else{
273 273
             if(class_exists($default_config['message'])) {
274 274
                 $this->default_message_mask = $default_config['message'];
275
-            }else{
275
+            } else{
276 276
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
277 277
             }
278 278
 
279 279
             if(class_exists($default_config['attachment'])) {
280 280
                 $this->default_attachment_mask = $default_config['attachment'];
281
-            }else{
281
+            } else{
282 282
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
283 283
             }
284 284
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
343 343
             $this->connection->setConnectionTimeout($this->timeout);
344 344
             $this->connection->setProxy($this->proxy);
345
-        }else{
345
+        } else{
346 346
             if (extension_loaded('imap') === false) {
347 347
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
348 348
             }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
 
492 492
             return $folders;
493
-        }else{
493
+        } else{
494 494
             throw new FolderFetchingException("failed to fetch any folders");
495 495
         }
496 496
     }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             }
531 531
 
532 532
             return $folders;
533
-        }else{
533
+        } else{
534 534
             throw new FolderFetchingException("failed to fetch any folders");
535 535
         }
536 536
     }
@@ -568,7 +568,9 @@  discard block
 block discarded – undo
568 568
         $this->checkConnection();
569 569
         $status = $this->connection->createFolder($folder);
570 570
 
571
-        if($expunge) $this->expunge();
571
+        if($expunge) {
572
+            $this->expunge();
573
+        }
572 574
 
573 575
         $folder = $this->getFolder($folder);
574 576
         if($status && $folder) {
Please login to merge, or discard this patch.