Passed
Push — master ( f565c3...6e76b3 )
by Malte
02:30
created
src/Folder.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 
124 124
         $this->setDelimiter($delimiter);
125 125
         $this->path      = $folder_name;
126
-        $this->full_name  = $this->decodeName($folder_name);
126
+        $this->full_name = $this->decodeName($folder_name);
127 127
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
128 128
 
129 129
         $this->parseAttributes($attributes);
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public function move(string $new_name, bool $expunge = true): bool {
241 241
         $this->client->checkConnection();
242 242
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
243
-        if($expunge) $this->client->expunge();
243
+        if ($expunge) $this->client->expunge();
244 244
 
245 245
         $folder = $this->client->getFolder($new_name);
246 246
         $event = $this->getEvent("folder", "moved");
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
          * date string that conforms to the rfc2060 specifications for a date_time value or be a Carbon object.
284 284
          */
285 285
 
286
-        if ($internal_date instanceof Carbon){
286
+        if ($internal_date instanceof Carbon) {
287 287
             $internal_date = $internal_date->format('d-M-Y H:i:s O');
288 288
         }
289 289
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      */
317 317
     public function delete(bool $expunge = true): bool {
318 318
         $status = $this->client->getConnection()->deleteFolder($this->path);
319
-        if($expunge) $this->client->expunge();
319
+        if ($expunge) $this->client->expunge();
320 320
 
321 321
         $event = $this->getEvent("folder", "deleted");
322 322
         $event::dispatch($this);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             try {
382 382
                 $line = $connection->nextLine();
383 383
                 if (($pos = strpos($line, "EXISTS")) !== false) {
384
-                    $msgn = (int) substr($line, 2, $pos -2);
384
+                    $msgn = (int) substr($line, 2, $pos - 2);
385 385
                     $connection->done();
386 386
 
387 387
                     $this->client->openFolder($this->path, true);
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 
395 395
                     $connection->idle();
396 396
                 }
397
-            }catch (Exceptions\RuntimeException $e) {
398
-                if(strpos($e->getMessage(), "connection closed") === false) {
397
+            } catch (Exceptions\RuntimeException $e) {
398
+                if (strpos($e->getMessage(), "connection closed") === false) {
399 399
                     throw $e;
400 400
                 }
401 401
                 if ($auto_reconnect === true) {
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
      * Set the delimiter
445 445
      * @param $delimiter
446 446
      */
447
-    public function setDelimiter($delimiter){
448
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
447
+    public function setDelimiter($delimiter) {
448
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
449 449
             $delimiter = ClientManager::get('options.delimiter', '/');
450 450
         }
451 451
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -240,7 +240,9 @@  discard block
 block discarded – undo
240 240
     public function move(string $new_name, bool $expunge = true): bool {
241 241
         $this->client->checkConnection();
242 242
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
243
-        if($expunge) $this->client->expunge();
243
+        if($expunge) {
244
+            $this->client->expunge();
245
+        }
244 246
 
245 247
         $folder = $this->client->getFolder($new_name);
246 248
         $event = $this->getEvent("folder", "moved");
@@ -316,7 +318,9 @@  discard block
 block discarded – undo
316 318
      */
317 319
     public function delete(bool $expunge = true): bool {
318 320
         $status = $this->client->getConnection()->deleteFolder($this->path);
319
-        if($expunge) $this->client->expunge();
321
+        if($expunge) {
322
+            $this->client->expunge();
323
+        }
320 324
 
321 325
         $event = $this->getEvent("folder", "deleted");
322 326
         $event::dispatch($this);
@@ -394,7 +398,7 @@  discard block
 block discarded – undo
394 398
 
395 399
                     $connection->idle();
396 400
                 }
397
-            }catch (Exceptions\RuntimeException $e) {
401
+            } catch (Exceptions\RuntimeException $e) {
398 402
                 if(strpos($e->getMessage(), "connection closed") === false) {
399 403
                     throw $e;
400 404
                 }
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
             throw new AuthFailedException($message);
90 90
         }
91 91
 
92
-        if(!$this->stream) {
92
+        if (!$this->stream) {
93 93
             $errors = \imap_errors();
94 94
             $message = implode("; ", (is_array($errors) ? $errors : array()));
95 95
             throw new AuthFailedException($message);
96 96
         }
97 97
 
98 98
         $errors = \imap_errors();
99
-        if(is_array($errors)) {
99
+        if (is_array($errors)) {
100 100
             $status = $this->examineFolder();
101
-            if($status['exists'] !== 0) {
101
+            if ($status['exists'] !== 0) {
102 102
                 $message = implode("; ", (is_array($errors) ? $errors : array()));
103 103
                 throw new RuntimeException($message);
104 104
             }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         if (!$this->cert_validation) {
130 130
             $address .= '/novalidate-cert';
131 131
         }
132
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
132
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
133 133
             $address .= '/'.$this->encryption;
134 134
         } elseif ($this->encryption === "starttls") {
135 135
             $address .= '/tls';
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
             $flags = [];
258 258
             if (is_array($raw_flags) && isset($raw_flags[0])) {
259 259
                 $raw_flags = (array) $raw_flags[0];
260
-                foreach($raw_flags as $flag => $value) {
261
-                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){
260
+                foreach ($raw_flags as $flag => $value) {
261
+                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) {
262 262
                         $flags[] = "\\".ucfirst($flag);
263 263
                     }
264 264
                 }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 
284 284
             $overview = $this->overview("1:*");
285 285
             $uids = [];
286
-            foreach($overview as $set){
286
+            foreach ($overview as $set) {
287 287
                 $uids[$set->msgno] = $set->uid;
288 288
             }
289 289
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      * @return array
313 313
      */
314 314
     public function overview(string $sequence, $uid = IMAP::ST_UID): array {
315
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL);
315
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL);
316 316
     }
317 317
 
318 318
     /**
@@ -327,12 +327,12 @@  discard block
 block discarded – undo
327 327
         $result = [];
328 328
 
329 329
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
330
-        if(is_array($items)){
330
+        if (is_array($items)) {
331 331
             foreach ($items as $item) {
332 332
                 $name = $this->decodeFolderName($item->name);
333 333
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
334 334
             }
335
-        }else{
335
+        }else {
336 336
             throw new RuntimeException(\imap_last_error());
337 337
         }
338 338
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
     public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) {
356 356
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
357 357
 
358
-        if ($mode == "+"){
358
+        if ($mode == "+") {
359 359
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
360
-        }else{
360
+        }else {
361 361
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
362 362
         }
363 363
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool {
381 381
         if ($date != null) {
382
-            if ($date instanceof \Carbon\Carbon){
382
+            if ($date instanceof \Carbon\Carbon) {
383 383
                 $date = $date->format('d-M-Y H:i:s O');
384 384
             }
385 385
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      * @return array|bool Tokens if operation successful, false if an error occurred
412 412
      */
413 413
     public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
414
-        foreach($messages as $msg) {
414
+        foreach ($messages as $msg) {
415 415
             if ($this->copyMessage($folder, $msg, null, $uid) == false) {
416 416
                 return false;
417 417
             }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      * @return array|bool Tokens if operation successful, false if an error occurred
444 444
      */
445 445
     public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
446
-        foreach($messages as $msg) {
446
+        foreach ($messages as $msg) {
447 447
             if ($this->moveMessage($folder, $msg, null, $uid) == false) {
448 448
                 return false;
449 449
             }
@@ -570,14 +570,14 @@  discard block
 block discarded – undo
570 570
     /**
571 571
      * Enable the debug mode
572 572
      */
573
-    public function enableDebug(){
573
+    public function enableDebug() {
574 574
         $this->debug = true;
575 575
     }
576 576
 
577 577
     /**
578 578
      * Disable the debug mode
579 579
      */
580
-    public function disableDebug(){
580
+    public function disableDebug() {
581 581
         $this->debug = false;
582 582
     }
583 583
 
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 2 patches
Spacing   +36 added lines, -36 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) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         $stack = [];
152 152
 
153 153
         //  replace any trailing <NL> including spaces with a single space
154
-        $line = rtrim($line) . ' ';
154
+        $line = rtrim($line).' ';
155 155
         while (($pos = strpos($line, ' ')) !== false) {
156 156
             $token = substr($line, 0, $pos);
157 157
             if (!strlen($token)) {
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
                     if (strlen($token) > $chars) {
182 182
                         $line = substr($token, $chars);
183 183
                         $token = substr($token, 0, $chars);
184
-                    } else {
184
+                    }else {
185 185
                         $line .= $this->nextLine();
186 186
                     }
187 187
                     $tokens[] = $token;
188
-                    $line = trim($line) . ' ';
188
+                    $line = trim($line).' ';
189 189
                     continue;
190 190
                 }
191 191
             }
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $line = $this->nextTaggedLine($tag); // get next tag
236 236
         if (!$dontParse) {
237 237
             $tokens = $this->decodeLine($line);
238
-        } else {
238
+        }else {
239 239
             $tokens = $line;
240 240
         }
241 241
         if ($this->debug) echo "<< ".$line."\n";
@@ -286,27 +286,27 @@  discard block
 block discarded – undo
286 286
     public function sendRequest(string $command, array $tokens = [], string &$tag = null) {
287 287
         if (!$tag) {
288 288
             $this->noun++;
289
-            $tag = 'TAG' . $this->noun;
289
+            $tag = 'TAG'.$this->noun;
290 290
         }
291 291
 
292
-        $line = $tag . ' ' . $command;
292
+        $line = $tag.' '.$command;
293 293
 
294 294
         foreach ($tokens as $token) {
295 295
             if (is_array($token)) {
296
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
296
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
297 297
                     throw new RuntimeException('failed to write - connection closed?');
298 298
                 }
299 299
                 if (!$this->assumedNextLine('+ ')) {
300 300
                     throw new RuntimeException('failed to send literal string');
301 301
                 }
302 302
                 $line = $token[1];
303
-            } else {
304
-                $line .= ' ' . $token;
303
+            }else {
304
+                $line .= ' '.$token;
305 305
             }
306 306
         }
307 307
         if ($this->debug) echo ">> ".$line."\n";
308 308
 
309
-        if (fwrite($this->stream, $line . "\r\n") === false) {
309
+        if (fwrite($this->stream, $line."\r\n") === false) {
310 310
             throw new RuntimeException('failed to write - connection closed?');
311 311
         }
312 312
     }
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
     public function escapeString($string) {
337 337
         if (func_num_args() < 2) {
338 338
             if (strpos($string, "\n") !== false) {
339
-                return ['{' . strlen($string) . '}', $string];
340
-            } else {
341
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
339
+                return ['{'.strlen($string).'}', $string];
340
+            }else {
341
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
342 342
             }
343 343
         }
344 344
         $result = [];
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
             }
364 364
             $result[] = $this->escapeList($v);
365 365
         }
366
-        return '(' . implode(' ', $result) . ')';
366
+        return '('.implode(' ', $result).')';
367 367
     }
368 368
 
369 369
     /**
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
                     error_log("got an extra server challenge: $response");
405 405
                     // respond with an empty response.
406 406
                     $this->sendRequest('');
407
-                } else {
407
+                }else {
408 408
                     if (preg_match('/^NO /i', $response) ||
409 409
                         preg_match('/^BAD /i', $response)) {
410 410
                         error_log("got failure response: $response");
411 411
                         return false;
412
-                    } else if (preg_match("/^OK /i", $response)) {
412
+                    }else if (preg_match("/^OK /i", $response)) {
413 413
                         return true;
414 414
                     }
415 415
                 }
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
                     $result[strtolower($tokens[1])] = $tokens[0];
491 491
                     break;
492 492
                 case '[UIDVALIDITY':
493
-                    $result['uidvalidity'] = (int)$tokens[2];
493
+                    $result['uidvalidity'] = (int) $tokens[2];
494 494
                     break;
495 495
                 case '[UIDNEXT':
496
-                    $result['uidnext'] = (int)$tokens[2];
496
+                    $result['uidnext'] = (int) $tokens[2];
497 497
                     break;
498 498
                 default:
499 499
                     // ignore
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
         if (is_array($from)) {
551 551
             $set = implode(',', $from);
552 552
         } elseif ($to === null) {
553
-            $set = (int)$from;
553
+            $set = (int) $from;
554 554
         } elseif ($to === INF) {
555
-            $set = (int)$from . ':*';
556
-        } else {
557
-            $set = (int)$from . ':' . (int)$to;
555
+            $set = (int) $from.':*';
556
+        }else {
557
+            $set = (int) $from.':'.(int) $to;
558 558
         }
559 559
 
560
-        $items = (array)$items;
560
+        $items = (array) $items;
561 561
         $itemList = $this->escapeList($items);
562 562
 
563 563
         $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag);
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
                 $count = count($tokens[2]);
575 575
                 if ($tokens[2][$count - 2] == 'UID') {
576 576
                     $uidKey = $count - 1;
577
-                } else if ($tokens[2][0] == 'UID') {
577
+                }else if ($tokens[2][0] == 'UID') {
578 578
                     $uidKey = 1;
579
-                } else {
579
+                }else {
580 580
                     $uidKey = array_search('UID', $tokens[2]) + 1;
581 581
                 }
582 582
             }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
                     $data = $tokens[2][1];
594 594
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
595 595
                     $data = $tokens[2][3];
596
-                } else {
596
+                }else {
597 597
                     // maybe the server send an other field we didn't wanted
598 598
                     $count = count($tokens[2]);
599 599
                     // we start with 2, because 0 was already checked
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
                         break;
606 606
                     }
607 607
                 }
608
-            } else {
608
+            }else {
609 609
                 $data = [];
610 610
                 while (key($tokens[2]) !== null) {
611 611
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             }
623 623
             if ($uid) {
624 624
                 $result[$tokens[2][$uidKey]] = $data;
625
-            }else{
625
+            }else {
626 626
                 $result[$tokens[0]] = $data;
627 627
             }
628 628
         }
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 
688 688
         if ($this->enable_uid_cache && $this->uid_cache) {
689 689
             $uids = $this->uid_cache;
690
-        } else {
690
+        }else {
691 691
             try {
692 692
                 $uids = $this->fetch('UID', 1, INF);
693 693
                 $this->setUidCache($uids); // set cache for this folder
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
782 782
 
783 783
         if ($silent) {
784
-            return (bool)$response;
784
+            return (bool) $response;
785 785
         }
786 786
 
787 787
         $result = [];
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
         $ids = [];
1083 1083
         foreach ($uids as $msgn => $v) {
1084 1084
             $id = $uid ? $v : $msgn;
1085
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1085
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1086 1086
                 $ids[] = $id;
1087 1087
             }
1088 1088
         }
@@ -1096,14 +1096,14 @@  discard block
 block discarded – undo
1096 1096
     /**
1097 1097
      * Enable the debug mode
1098 1098
      */
1099
-    public function enableDebug(){
1099
+    public function enableDebug() {
1100 1100
         $this->debug = true;
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104 1104
      * Disable the debug mode
1105 1105
      */
1106
-    public function disableDebug(){
1106
+    public function disableDebug() {
1107 1107
         $this->debug = false;
1108 1108
     }
1109 1109
 
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
      * @return int|string
1116 1116
      */
1117 1117
     public function buildSet($from, $to = null) {
1118
-        $set = (int)$from;
1118
+        $set = (int) $from;
1119 1119
         if ($to !== null) {
1120
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
1120
+            $set .= ':'.($to == INF ? '*' : (int) $to);
1121 1121
         }
1122 1122
         return $set;
1123 1123
     }
Please login to merge, or discard this patch.
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -238,7 +238,9 @@  discard block
 block discarded – undo
238 238
         } else {
239 239
             $tokens = $line;
240 240
         }
241
-        if ($this->debug) echo "<< ".$line."\n";
241
+        if ($this->debug) {
242
+            echo "<< ".$line."\n";
243
+        }
242 244
 
243 245
         // if tag is wanted tag we might be at the end of a multiline response
244 246
         return $tag == $wantedTag;
@@ -304,7 +306,9 @@  discard block
 block discarded – undo
304 306
                 $line .= ' ' . $token;
305 307
             }
306 308
         }
307
-        if ($this->debug) echo ">> ".$line."\n";
309
+        if ($this->debug) {
310
+            echo ">> ".$line."\n";
311
+        }
308 312
 
309 313
         if (fwrite($this->stream, $line . "\r\n") === false) {
310 314
             throw new RuntimeException('failed to write - connection closed?');
@@ -456,7 +460,9 @@  discard block
 block discarded – undo
456 460
     public function getCapabilities(): array {
457 461
         $response = $this->requestAndResponse('CAPABILITY');
458 462
 
459
-        if (!$response) return [];
463
+        if (!$response) {
464
+            return [];
465
+        }
460 466
 
461 467
         $capabilities = [];
462 468
         foreach ($response as $line) {
@@ -616,13 +622,14 @@  discard block
 block discarded – undo
616 622
             // if we want only one message we can ignore everything else and just return
617 623
             if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) {
618 624
                 // we still need to read all lines
619
-                while (!$this->readLine($tokens, $tag))
620
-
625
+                while (!$this->readLine($tokens, $tag)) {
626
+                
621 627
                     return $data;
628
+                }
622 629
             }
623 630
             if ($uid) {
624 631
                 $result[$tokens[2][$uidKey]] = $data;
625
-            }else{
632
+            } else{
626 633
                 $result[$tokens[0]] = $data;
627 634
             }
628 635
         }
Please login to merge, or discard this patch.
src/Message.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $this->boot();
192 192
 
193 193
         $default_mask = $client->getDefaultMessageMask();
194
-        if($default_mask != null) {
194
+        if ($default_mask != null) {
195 195
             $this->mask = $default_mask;
196 196
         }
197 197
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $instance->boot();
253 253
 
254 254
         $default_mask = $client->getDefaultMessageMask();
255
-        if($default_mask != null) {
255
+        if ($default_mask != null) {
256 256
             $instance->setMask($default_mask);
257 257
         }
258 258
         $instance->setEvents([
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     /**
278 278
      * Boot a new instance
279 279
      */
280
-    public function boot(){
280
+    public function boot() {
281 281
         $this->attributes = [];
282 282
 
283 283
         $this->config = ClientManager::get('options');
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
      * @throws MethodNotFoundException
297 297
      */
298 298
     public function __call(string $method, array $arguments) {
299
-        if(strtolower(substr($method, 0, 3)) === 'get') {
299
+        if (strtolower(substr($method, 0, 3)) === 'get') {
300 300
             $name = Str::snake(substr($method, 3));
301 301
             return $this->get($name);
302 302
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
303 303
             $name = Str::snake(substr($method, 3));
304 304
 
305
-            if(in_array($name, array_keys($this->attributes))) {
305
+            if (in_array($name, array_keys($this->attributes))) {
306 306
                 return $this->__set($name, array_pop($arguments));
307 307
             }
308 308
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      * @return Attribute|mixed|null
342 342
      */
343 343
     public function get($name) {
344
-        if(isset($this->attributes[$name])) {
344
+        if (isset($this->attributes[$name])) {
345 345
             return $this->attributes[$name];
346 346
         }
347 347
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
      *
416 416
      * @throws InvalidMessageDateException
417 417
      */
418
-    public function parseRawHeader(string $raw_header){
418
+    public function parseRawHeader(string $raw_header) {
419 419
         $this->header = new Header($raw_header);
420 420
     }
421 421
 
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
     public function parseRawFlags(array $raw_flags) {
427 427
         $this->flags = FlagCollection::make([]);
428 428
 
429
-        foreach($raw_flags as $flag) {
430
-            if (strpos($flag, "\\") === 0){
429
+        foreach ($raw_flags as $flag) {
430
+            if (strpos($flag, "\\") === 0) {
431 431
                 $flag = substr($flag, 1);
432 432
             }
433 433
             $flag_key = strtolower($flag);
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
      * @throws MessageFlagException
501 501
      * @throws Exceptions\RuntimeException
502 502
      */
503
-    public function peek(){
503
+    public function peek() {
504 504
         if ($this->fetch_options == IMAP::FT_PEEK) {
505 505
             if ($this->getFlags()->get("seen") == null) {
506 506
                 $this->unsetFlag("Seen");
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     private function fetchPart(Part $part) {
550 550
         if ($part->isAttachment()) {
551 551
             $this->fetchAttachment($part);
552
-        }else{
552
+        }else {
553 553
             $encoding = $this->getEncoding($part);
554 554
 
555 555
             $content = $this->decodeString($part->content, $part->encoding);
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
             if (isset($this->bodies[$subtype])) {
576 576
                 $this->bodies[$subtype] .= "\n".$content;
577
-            }else{
577
+            }else {
578 578
                 $this->bodies[$subtype] = $content;
579 579
             }
580 580
         }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
591 591
             if ($oAttachment->getId() !== null) {
592 592
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
593
-            } else {
593
+            }else {
594 594
                 $this->attachments->push($oAttachment);
595 595
             }
596 596
         }
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 
725 725
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
726 726
             return @iconv($from, $to.'//IGNORE', $str);
727
-        } else {
727
+        }else {
728 728
             if (!$from) {
729 729
                 return mb_convert_encoding($str, $to);
730 730
             }
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
                     return EncodingAliases::get($parameter->value, "ISO-8859-2");
746 746
                 }
747 747
             }
748
-        }elseif (property_exists($structure, 'charset')){
748
+        }elseif (property_exists($structure, 'charset')) {
749 749
             return EncodingAliases::get($structure->charset, "ISO-8859-2");
750
-        }elseif (is_string($structure) === true){
750
+        }elseif (is_string($structure) === true) {
751 751
             return mb_detect_encoding($structure);
752 752
         }
753 753
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
      * @throws Exceptions\FolderFetchingException
763 763
      * @throws Exceptions\RuntimeException
764 764
      */
765
-    public function getFolder(){
765
+    public function getFolder() {
766 766
         return $this->client->getFolderByPath($this->folder_path);
767 767
     }
768 768
 
@@ -780,11 +780,11 @@  discard block
 block discarded – undo
780 780
      */
781 781
     public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection {
782 782
         $thread = $thread ?: MessageCollection::make([]);
783
-        $folder = $folder ?:  $this->getFolder();
783
+        $folder = $folder ?: $this->getFolder();
784 784
         $sent_folder = $sent_folder ?: $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
785 785
 
786 786
         /** @var Message $message */
787
-        foreach($thread as $message) {
787
+        foreach ($thread as $message) {
788 788
             if ($message->message_id->first() == $this->message_id->first()) {
789 789
                 return $thread;
790 790
             }
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
796 796
 
797 797
         if (is_array($this->in_reply_to)) {
798
-            foreach($this->in_reply_to as $in_reply_to) {
798
+            foreach ($this->in_reply_to as $in_reply_to) {
799 799
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
800 800
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
801 801
             }
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
      * @throws Exceptions\RuntimeException
818 818
      * @throws Exceptions\FolderFetchingException
819 819
      */
820
-    protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){
820
+    protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) {
821 821
         $primary_folder->query()->inReplyTo($in_reply_to)
822 822
         ->setFetchBody($this->getFetchBodyOption())
823 823
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
      * @throws Exceptions\RuntimeException
840 840
      * @throws Exceptions\FolderFetchingException
841 841
      */
842
-    protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder){
842
+    protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder) {
843 843
         $primary_folder->query()->messageId($message_id)
844 844
         ->setFetchBody($this->getFetchBodyOption())
845 845
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
      * @throws MessageHeaderFetchingException
937 937
      */
938 938
     protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message {
939
-        if($expunge) $this->client->expunge();
939
+        if ($expunge) $this->client->expunge();
940 940
 
941 941
         $this->client->openFolder($folder->path);
942 942
 
943 943
         if ($this->sequence === IMAP::ST_UID) {
944 944
             $sequence_id = $next_uid;
945
-        }else{
945
+        }else {
946 946
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
947 947
         }
948 948
 
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
      */
973 973
     public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false) {
974 974
         $status = $this->setFlag("Deleted");
975
-        if($force_move) {
976
-            $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path;
975
+        if ($force_move) {
976
+            $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"] : $trash_path;
977 977
             $status = $this->move($trash_path);
978 978
         }
979
-        if($expunge) $this->client->expunge();
979
+        if ($expunge) $this->client->expunge();
980 980
 
981 981
         $event = $this->getEvent("message", "deleted");
982 982
         $event::dispatch($this);
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
      */
997 997
     public function restore(bool $expunge = true): bool {
998 998
         $status = $this->unsetFlag("Deleted");
999
-        if($expunge) $this->client->expunge();
999
+        if ($expunge) $this->client->expunge();
1000 1000
 
1001 1001
         $event = $this->getEvent("message", "restored");
1002 1002
         $event::dispatch($this);
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
      *
1209 1209
      * @return Structure|null
1210 1210
      */
1211
-    public function getStructure(){
1211
+    public function getStructure() {
1212 1212
         return $this->structure;
1213 1213
     }
1214 1214
 
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
      * @return $this
1246 1246
      */
1247 1247
     public function setMask($mask): Message {
1248
-        if(class_exists($mask)){
1248
+        if (class_exists($mask)) {
1249 1249
             $this->mask = $mask;
1250 1250
         }
1251 1251
 
@@ -1268,9 +1268,9 @@  discard block
 block discarded – undo
1268 1268
      * @return mixed
1269 1269
      * @throws MaskNotFoundException
1270 1270
      */
1271
-    public function mask($mask = null){
1271
+    public function mask($mask = null) {
1272 1272
         $mask = $mask !== null ? $mask : $this->mask;
1273
-        if(class_exists($mask)){
1273
+        if (class_exists($mask)) {
1274 1274
             return new $mask($this);
1275 1275
         }
1276 1276
 
@@ -1420,11 +1420,11 @@  discard block
 block discarded – undo
1420 1420
      * @throws Exceptions\ConnectionFailedException
1421 1421
      * @throws Exceptions\MessageNotFoundException
1422 1422
      */
1423
-    public function setSequenceId($uid, int $msglist = null){
1423
+    public function setSequenceId($uid, int $msglist = null) {
1424 1424
         if ($this->getSequence() === IMAP::ST_UID) {
1425 1425
             $this->setUid($uid);
1426 1426
             $this->setMsglist($msglist);
1427
-        }else{
1427
+        }else {
1428 1428
             $this->setMsgn($uid, $msglist);
1429 1429
         }
1430 1430
     }
Please login to merge, or discard this patch.
Braces   +17 added lines, -11 removed lines patch added patch discarded remove patch
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
         if(strtolower(substr($method, 0, 3)) === 'get') {
300 300
             $name = Str::snake(substr($method, 3));
301 301
             return $this->get($name);
302
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
302
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
303 303
             $name = Str::snake(substr($method, 3));
304 304
 
305 305
             if(in_array($name, array_keys($this->attributes))) {
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
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
     }
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
     private function fetchPart(Part $part) {
550 550
         if ($part->isAttachment()) {
551 551
             $this->fetchAttachment($part);
552
-        }else{
552
+        } else{
553 553
             $encoding = $this->getEncoding($part);
554 554
 
555 555
             $content = $this->decodeString($part->content, $part->encoding);
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 
575 575
             if (isset($this->bodies[$subtype])) {
576 576
                 $this->bodies[$subtype] .= "\n".$content;
577
-            }else{
577
+            } else{
578 578
                 $this->bodies[$subtype] = $content;
579 579
             }
580 580
         }
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
                     return EncodingAliases::get($parameter->value, "ISO-8859-2");
746 746
                 }
747 747
             }
748
-        }elseif (property_exists($structure, 'charset')){
748
+        } elseif (property_exists($structure, 'charset')){
749 749
             return EncodingAliases::get($structure->charset, "ISO-8859-2");
750
-        }elseif (is_string($structure) === true){
750
+        } elseif (is_string($structure) === true){
751 751
             return mb_detect_encoding($structure);
752 752
         }
753 753
 
@@ -936,13 +936,15 @@  discard block
 block discarded – undo
936 936
      * @throws MessageHeaderFetchingException
937 937
      */
938 938
     protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message {
939
-        if($expunge) $this->client->expunge();
939
+        if($expunge) {
940
+            $this->client->expunge();
941
+        }
940 942
 
941 943
         $this->client->openFolder($folder->path);
942 944
 
943 945
         if ($this->sequence === IMAP::ST_UID) {
944 946
             $sequence_id = $next_uid;
945
-        }else{
947
+        } else{
946 948
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
947 949
         }
948 950
 
@@ -976,7 +978,9 @@  discard block
 block discarded – undo
976 978
             $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path;
977 979
             $status = $this->move($trash_path);
978 980
         }
979
-        if($expunge) $this->client->expunge();
981
+        if($expunge) {
982
+            $this->client->expunge();
983
+        }
980 984
 
981 985
         $event = $this->getEvent("message", "deleted");
982 986
         $event::dispatch($this);
@@ -996,7 +1000,9 @@  discard block
 block discarded – undo
996 1000
      */
997 1001
     public function restore(bool $expunge = true): bool {
998 1002
         $status = $this->unsetFlag("Deleted");
999
-        if($expunge) $this->client->expunge();
1003
+        if($expunge) {
1004
+            $this->client->expunge();
1005
+        }
1000 1006
 
1001 1007
         $event = $this->getEvent("message", "restored");
1002 1008
         $event::dispatch($this);
@@ -1424,7 +1430,7 @@  discard block
 block discarded – undo
1424 1430
         if ($this->getSequence() === IMAP::ST_UID) {
1425 1431
             $this->setUid($uid);
1426 1432
             $this->setMsglist($msglist);
1427
-        }else{
1433
+        } else{
1428 1434
             $this->setMsgn($uid, $msglist);
1429 1435
         }
1430 1436
     }
Please login to merge, or discard this patch.
src/Support/Masks/Mask.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function __construct($parent) {
44 44
         $this->parent = $parent;
45 45
 
46
-        if(method_exists($this->parent, 'getAttributes')){
46
+        if (method_exists($this->parent, 'getAttributes')) {
47 47
             $this->attributes = array_merge($this->attributes, $this->parent->getAttributes());
48 48
         }
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     /**
54 54
      * Boot method made to be used by any custom mask
55 55
      */
56
-    protected function boot(){}
56
+    protected function boot() {}
57 57
 
58 58
     /**
59 59
      * Call dynamic attribute setter and getter methods and inherit the parent calls
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
      * @throws MethodNotFoundException
65 65
      */
66 66
     public function __call(string $method, array $arguments) {
67
-        if(strtolower(substr($method, 0, 3)) === 'get') {
67
+        if (strtolower(substr($method, 0, 3)) === 'get') {
68 68
             $name = Str::snake(substr($method, 3));
69 69
 
70
-            if(isset($this->attributes[$name])) {
70
+            if (isset($this->attributes[$name])) {
71 71
                 return $this->attributes[$name];
72 72
             }
73 73
 
74 74
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
75 75
             $name = Str::snake(substr($method, 3));
76 76
 
77
-            if(isset($this->attributes[$name])) {
77
+            if (isset($this->attributes[$name])) {
78 78
                 $this->attributes[$name] = array_pop($arguments);
79 79
 
80 80
                 return $this->attributes[$name];
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         }
84 84
 
85
-        if(method_exists($this->parent, $method) === true){
85
+        if (method_exists($this->parent, $method) === true) {
86 86
             return call_user_func_array([$this->parent, $method], $arguments);
87 87
         }
88 88
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @return mixed|null
110 110
      */
111 111
     public function __get($name) {
112
-        if(isset($this->attributes[$name])) {
112
+        if (isset($this->attributes[$name])) {
113 113
             return $this->attributes[$name];
114 114
         }
115 115
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @return object
123 123
      */
124
-    public function getParent(){
124
+    public function getParent() {
125 125
         return $this->parent;
126 126
     }
127 127
 
Please login to merge, or discard this patch.