Passed
Pull Request — master (#242)
by
unknown
08:12
created
rector.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@
 block discarded – undo
5 5
 use Rector\Config\RectorConfig;
6 6
 use Rector\Set\ValueObject\SetList;
7 7
 
8
-return static function (RectorConfig $containerConfigurator): void {
9
-    $containerConfigurator->paths([__DIR__ . '/src', __DIR__ . '/tests']);
8
+return static function(RectorConfig $containerConfigurator): void {
9
+    $containerConfigurator->paths([__DIR__.'/src', __DIR__.'/tests']);
10 10
 
11 11
     $containerConfigurator->import(SetList::PHP_54);
12 12
     $containerConfigurator->import(SetList::PHP_55);
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         }
97 97
 
98
-        throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported');
98
+        throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported');
99 99
     }
100 100
 
101 101
     /**
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
         if (isset($this->attributes[$name]) && $strict === false) {
131 131
             if ($this->attributize) {
132 132
                 $this->attributes[$name]->add($value, true);
133
-            } else {
133
+            }else {
134 134
                 if (isset($this->attributes[$name])) {
135 135
                     if (!is_array($this->attributes[$name])) {
136 136
                         $this->attributes[$name] = [$this->attributes[$name], $value];
137
-                    } else {
137
+                    }else {
138 138
                         $this->attributes[$name][] = $value;
139 139
                     }
140
-                } else {
140
+                }else {
141 141
                     $this->attributes[$name] = $value;
142 142
                 }
143 143
             }
144 144
         } elseif (!$this->attributize) {
145 145
             $this->attributes[$name] = $value;
146
-        } else {
146
+        }else {
147 147
             $this->attributes[$name] = new Attribute($name, $value);
148 148
         }
149 149
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         $headers = [];
236 236
         $imap_headers = [];
237 237
         if (extension_loaded('imap') && $this->config["rfc822"]) {
238
-            $raw_imap_headers = (array)imap_rfc822_parse_headers($this->raw);
238
+            $raw_imap_headers = (array) imap_rfc822_parse_headers($this->raw);
239 239
             foreach ($raw_imap_headers as $key => $values) {
240 240
                 $key = str_replace("-", "_", $key);
241 241
                 $imap_headers[$key] = $values;
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
                     }
264 264
                     if (is_array($headers[$prev_header])) {
265 265
                         $headers[$prev_header][] = $line;
266
-                    } else {
266
+                    }else {
267 267
                         $headers[$prev_header] .= $line;
268 268
                     }
269 269
                 }
270
-            } else {
270
+            }else {
271 271
                 if (($pos = strpos($line, ":")) > 0) {
272 272
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
273 273
                     $key = str_replace("-", "_", $key);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                     $value = trim(rtrim(substr($line, $pos + 1)));
276 276
                     if (isset($headers[$key])) {
277 277
                         $headers[$key][] = $value;
278
-                    } else {
278
+                    }else {
279 279
                         $headers[$key] = [$value];
280 280
                     }
281 281
                     $prev_header = $key;
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
                 case 'reply_to':
295 295
                 case 'sender':
296 296
                     $value = $this->decodeAddresses($values);
297
-                    $headers[$key . "address"] = implode(", ", $values);
297
+                    $headers[$key."address"] = implode(", ", $values);
298 298
                     break;
299 299
                 case 'subject':
300 300
                     $value = implode(" ", $values);
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                             $value = implode(" ", $values);
314 314
                         } elseif ($available_values > 2) {
315 315
                             $value = array_values($values);
316
-                        } else {
316
+                        }else {
317 317
                             $value = "";
318 318
                         }
319 319
                     }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
             $headers[$key] = $value;
323 323
         }
324 324
 
325
-        return (object)array_merge($headers, $imap_headers);
325
+        return (object) array_merge($headers, $imap_headers);
326 326
     }
327 327
 
328 328
     /**
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
             return imap_mime_header_decode($text);
339 339
         }
340 340
         $charset = $this->getEncoding($text);
341
-        return [(object)[
341
+        return [(object) [
342 342
             "charset" => $charset,
343 343
             "text"    => $this->convertEncoding($text, $charset)
344 344
         ]];
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      */
502 502
     private function findPriority(): void {
503 503
         if (($priority = $this->get("x_priority")) === null) return;
504
-        switch ((int)"$priority") {
504
+        switch ((int) "$priority") {
505 505
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
506 506
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
507 507
                 break;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
                     if (isset($parsed_address['address'])) {
541 541
                         $mail_address = explode('@', $parsed_address['address']);
542 542
                         if (count($mail_address) == 2) {
543
-                            $addresses[] = (object)[
543
+                            $addresses[] = (object) [
544 544
                                 "personal" => $parsed_address['display'] ?? '',
545 545
                                 "mailbox"  => $mail_address[0],
546 546
                                 "host"     => $mail_address[1],
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
                     $name = trim(rtrim($matches["name"]));
569 569
                     $email = trim(rtrim($matches["email"]));
570 570
                     [$mailbox, $host] = array_pad(explode("@", $email), 2, null);
571
-                    $addresses[] = (object)[
571
+                    $addresses[] = (object) [
572 572
                         "personal" => $name,
573 573
                         "mailbox"  => $mailbox,
574 574
                         "host"     => $host,
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
         }
606 606
 
607 607
         foreach ($list as $item) {
608
-            $address = (object)$item;
608
+            $address = (object) $item;
609 609
 
610 610
             if (!property_exists($address, 'mailbox')) {
611 611
                 $address->mailbox = false;
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
             }
616 616
             if (!property_exists($address, 'personal')) {
617 617
                 $address->personal = false;
618
-            } else {
618
+            }else {
619 619
                 $personalParts = $this->mime_header_decode($address->personal);
620 620
 
621 621
                 if (is_array($personalParts)) {
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
                 }
631 631
             }
632 632
 
633
-            $address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false;
634
-            $address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail;
633
+            $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false;
634
+            $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail;
635 635
 
636 636
             $addresses[] = new Address($address);
637 637
         }
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
         foreach ($this->attributes as $key => $value) {
647 647
             if (is_array($value)) {
648 648
                 $value = implode(", ", $value);
649
-            } else {
650
-                $value = (string)$value;
649
+            }else {
650
+                $value = (string) $value;
651 651
             }
652 652
             // Only parse strings and don't parse any attributes like the user-agent
653 653
             if (($key == "user_agent") === false) {
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
                     $parsed_date = Carbon::parse($date);
727 727
                 } catch (Exception $_e) {
728 728
                     if (!isset($this->config["fallback_date"])) {
729
-                        throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e);
729
+                        throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date, 1100, $e);
730 730
                     }
731 731
                     $parsed_date = Carbon::parse($this->config["fallback_date"]);
732 732
                 }
Please login to merge, or discard this patch.
src/Structure.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
     public function findContentType(): void{
80 80
         $content_type = $this->header->get("content_type");
81 81
         $content_type = is_array($content_type) ? implode(' ', $content_type) : $content_type;
82
-        if(stripos($content_type, 'multipart') === 0) {
82
+        if (stripos($content_type, 'multipart') === 0) {
83 83
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
84
-        }else{
84
+        }else {
85 85
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
86 86
         }
87 87
     }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @throws InvalidMessageDateException
119 119
      */
120 120
     private function detectParts(string $boundary, string $context, int $part_number = 0): array {
121
-        $base_parts = explode( $boundary, $context);
121
+        $base_parts = explode($boundary, $context);
122 122
         $final_parts = [];
123
-        foreach($base_parts as $ctx) {
123
+        foreach ($base_parts as $ctx) {
124 124
             $ctx = substr($ctx, 2);
125 125
             if ($ctx !== "--" && $ctx != "") {
126 126
                 $parts = $this->parsePart($ctx, $part_number);
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
      * @throws InvalidMessageDateException
143 143
      */
144 144
     public function find_parts(): array {
145
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
146
-            if (($boundary = $this->header->getBoundary()) === null)  {
145
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
146
+            if (($boundary = $this->header->getBoundary()) === null) {
147 147
                 throw new MessageContentFetchingException("no content found", 0);
148 148
             }
149 149
 
Please login to merge, or discard this patch.
src/ClientManager.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
     public static function get(string $key, $default = null) {
77 77
         $parts = explode('.', $key);
78 78
         $value = null;
79
-        foreach($parts as $part) {
80
-            if($value === null) {
81
-                if(isset(self::$config[$part])) {
79
+        foreach ($parts as $part) {
80
+            if ($value === null) {
81
+                if (isset(self::$config[$part])) {
82 82
                     $value = self::$config[$part];
83
-                }else{
83
+                }else {
84 84
                     break;
85 85
                 }
86
-            }else{
87
-                if(isset($value[$part])) {
86
+            }else {
87
+                if (isset($value[$part])) {
88 88
                     $value = $value[$part];
89
-                }else{
89
+                }else {
90 90
                     break;
91 91
                 }
92 92
             }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
      */
175 175
     public function setConfig($config): self {
176 176
 
177
-        if(is_array($config) === false) {
177
+        if (is_array($config) === false) {
178 178
             $config = require $config;
179 179
         }
180 180
 
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
         $vendor_config = require $path;
185 185
         $config = $this->array_merge_recursive_distinct($vendor_config, $config);
186 186
 
187
-        if(is_array($config)){
188
-            if(isset($config['default'])){
189
-                if(isset($config['accounts']) && $config['default'] != false){
187
+        if (is_array($config)) {
188
+            if (isset($config['default'])) {
189
+                if (isset($config['accounts']) && $config['default'] != false) {
190 190
 
191 191
                     $default_config = $vendor_config['accounts']['default'];
192
-                    if(isset($config['accounts'][$config['default']])){
192
+                    if (isset($config['accounts'][$config['default']])) {
193 193
                         $default_config = array_merge($default_config, $config['accounts'][$config['default']]);
194 194
                     }
195 195
 
196
-                    if(is_array($config['accounts'])){
197
-                        foreach($config['accounts'] as $account_key => $account){
196
+                    if (is_array($config['accounts'])) {
197
+                        foreach ($config['accounts'] as $account_key => $account) {
198 198
                             $config['accounts'][$account_key] = array_merge($default_config, $account);
199 199
                         }
200 200
                     }
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
             return array_keys($arr) !== range(0, count($arr) - 1);
234 234
         };
235 235
 
236
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
236
+        if (!is_array($base)) $base = empty($base) ? array() : array($base);
237 237
 
238
-        foreach($arrays as $append) {
238
+        foreach ($arrays as $append) {
239 239
 
240
-            if(!is_array($append)) $append = array($append);
240
+            if (!is_array($append)) $append = array($append);
241 241
 
242
-            foreach($append as $key => $value) {
242
+            foreach ($append as $key => $value) {
243 243
 
244
-                if(!array_key_exists($key, $base) and !is_numeric($key)) {
244
+                if (!array_key_exists($key, $base) and !is_numeric($key)) {
245 245
                     $base[$key] = $value;
246 246
                     continue;
247 247
                 }
248 248
 
249
-                if(
249
+                if (
250 250
                     (
251 251
                         is_array($value)
252 252
                         && $isAssoc($value)
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                     // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment']
261 261
                     // results in $resultConfig['dispositions'] = ['attachment', 'inline']
262 262
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value);
263
-                } else if(is_numeric($key)) {
264
-                    if(!in_array($value, $base)) $base[] = $value;
265
-                } else {
263
+                }else if (is_numeric($key)) {
264
+                    if (!in_array($value, $base)) $base[] = $value;
265
+                }else {
266 266
                     $base[$key] = $value;
267 267
                 }
268 268
 
Please login to merge, or discard this patch.
src/Connection/Protocols/Protocol.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@
 block discarded – undo
246 246
         if (is_numeric($uid)) {
247 247
             return "";
248 248
         }
249
-        return (string)$uid;
249
+        return (string) $uid;
250 250
     }
251 251
 
252 252
     public function buildUIDCommand($command, $uid) : string {
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
             throw new AuthFailedException($message);
89 89
         }
90 90
 
91
-        if(!$this->stream) {
91
+        if (!$this->stream) {
92 92
             $errors = \imap_errors();
93 93
             $message = implode("; ", (is_array($errors) ? $errors : array()));
94 94
             throw new AuthFailedException($message);
95 95
         }
96 96
 
97 97
         $errors = \imap_errors();
98
-        if(is_array($errors)) {
98
+        if (is_array($errors)) {
99 99
             $status = $this->examineFolder();
100
-            if($status['exists'] !== 0) {
100
+            if ($status['exists'] !== 0) {
101 101
                 $message = implode("; ", (is_array($errors) ? $errors : array()));
102 102
                 throw new RuntimeException($message);
103 103
             }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         if (!$this->cert_validation) {
129 129
             $address .= '/novalidate-cert';
130 130
         }
131
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
131
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
132 132
             $address .= '/'.$this->encryption;
133 133
         } elseif ($this->encryption === "starttls") {
134 134
             $address .= '/tls';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
             $overview = $this->overview("1:*");
288 288
             $uids = [];
289
-            foreach($overview as $set){
289
+            foreach ($overview as $set) {
290 290
                 $uids[$set->msgno] = $set->uid;
291 291
             }
292 292
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      * @return array
316 316
      */
317 317
     public function overview(string $sequence, $uid = IMAP::ST_UID): array {
318
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL);
318
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL);
319 319
     }
320 320
 
321 321
     /**
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
         $result = [];
331 331
 
332 332
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
333
-        if(is_array($items)){
333
+        if (is_array($items)) {
334 334
             foreach ($items as $item) {
335 335
                 $name = $this->decodeFolderName($item->name);
336 336
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
337 337
             }
338
-        }else{
338
+        }else {
339 339
             throw new RuntimeException(\imap_last_error());
340 340
         }
341 341
 
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
     public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) {
359 359
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
360 360
 
361
-        if ($mode == "+"){
361
+        if ($mode == "+") {
362 362
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
363
-        }else{
363
+        }else {
364 364
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
365 365
         }
366 366
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
      */
383 383
     public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool {
384 384
         if ($date != null) {
385
-            if ($date instanceof \Carbon\Carbon){
385
+            if ($date instanceof \Carbon\Carbon) {
386 386
                 $date = $date->format('d-M-Y H:i:s O');
387 387
             }
388 388
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
      * @return array|bool Tokens if operation successful, false if an error occurred
415 415
      */
416 416
     public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
417
-        foreach($messages as $msg) {
417
+        foreach ($messages as $msg) {
418 418
             if ($this->copyMessage($folder, $msg, null, $uid) == false) {
419 419
                 return false;
420 420
             }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
      * @return array|bool Tokens if operation successful, false if an error occurred
447 447
      */
448 448
     public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) {
449
-        foreach($messages as $msg) {
449
+        foreach ($messages as $msg) {
450 450
             if ($this->moveMessage($folder, $msg, null, $uid) == false) {
451 451
                 return false;
452 452
             }
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -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";
@@ -287,27 +287,27 @@  discard block
 block discarded – undo
287 287
     public function sendRequest(string $command, array $tokens = [], ?string &$tag = null): void {
288 288
         if (!$tag) {
289 289
             $this->noun++;
290
-            $tag = 'TAG' . $this->noun;
290
+            $tag = 'TAG'.$this->noun;
291 291
         }
292 292
 
293
-        $line = $tag . ' ' . $command;
293
+        $line = $tag.' '.$command;
294 294
 
295 295
         foreach ($tokens as $token) {
296 296
             if (is_array($token)) {
297
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
297
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
298 298
                     throw new RuntimeException('failed to write - connection closed?');
299 299
                 }
300 300
                 if (!$this->assumedNextLine('+ ')) {
301 301
                     throw new RuntimeException('failed to send literal string');
302 302
                 }
303 303
                 $line = $token[1];
304
-            } else {
305
-                $line .= ' ' . $token;
304
+            }else {
305
+                $line .= ' '.$token;
306 306
             }
307 307
         }
308 308
         if ($this->debug) echo ">> ".$line."\n";
309 309
 
310
-        if (fwrite($this->stream, $line . "\r\n") === false) {
310
+        if (fwrite($this->stream, $line."\r\n") === false) {
311 311
             throw new RuntimeException('failed to write - connection closed?');
312 312
         }
313 313
     }
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
     public function escapeString($string) {
338 338
         if (func_num_args() < 2) {
339 339
             if (strpos($string, "\n") !== false) {
340
-                return ['{' . strlen($string) . '}', $string];
340
+                return ['{'.strlen($string).'}', $string];
341 341
             }
342
-            return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
342
+            return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
343 343
         }
344 344
         $result = [];
345 345
         foreach (func_get_args() as $string) {
@@ -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,7 +404,7 @@  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");
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
                     $result[strtolower($tokens[1])] = $tokens[0];
492 492
                     break;
493 493
                 case '[UIDVALIDITY':
494
-                    $result['uidvalidity'] = (int)$tokens[2];
494
+                    $result['uidvalidity'] = (int) $tokens[2];
495 495
                     break;
496 496
                 case '[UIDNEXT':
497
-                    $result['uidnext'] = (int)$tokens[2];
497
+                    $result['uidnext'] = (int) $tokens[2];
498 498
                     break;
499 499
                 default:
500 500
                     // ignore
@@ -551,14 +551,14 @@  discard block
 block discarded – undo
551 551
         if (is_array($from)) {
552 552
             $set = implode(',', $from);
553 553
         } elseif ($to === null) {
554
-            $set = (int)$from;
554
+            $set = (int) $from;
555 555
         } elseif ($to === INF) {
556
-            $set = (int)$from . ':*';
557
-        } else {
558
-            $set = (int)$from . ':' . (int)$to;
556
+            $set = (int) $from.':*';
557
+        }else {
558
+            $set = (int) $from.':'.(int) $to;
559 559
         }
560 560
 
561
-        $items = (array)$items;
561
+        $items = (array) $items;
562 562
         $itemList = $this->escapeList($items);
563 563
 
564 564
         $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag);
@@ -576,9 +576,9 @@  discard block
 block discarded – undo
576 576
                 $count = is_countable($tokens[2]) ? count($tokens[2]) : 0;
577 577
                 if ($tokens[2][$count - 2] == 'UID') {
578 578
                     $uidKey = $count - 1;
579
-                } else if ($tokens[2][0] == 'UID') {
579
+                }else if ($tokens[2][0] == 'UID') {
580 580
                     $uidKey = 1;
581
-                } else {
581
+                }else {
582 582
                     $uidKey = array_search('UID', $tokens[2]) + 1;
583 583
                 }
584 584
             }
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
                     $data = $tokens[2][1];
596 596
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
597 597
                     $data = $tokens[2][3];
598
-                } else {
598
+                }else {
599 599
                     // maybe the server send an other field we didn't wanted
600 600
                     $count = is_countable($tokens[2]) ? count($tokens[2]) : 0;
601 601
                     // we start with 2, because 0 was already checked
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
                         break;
608 608
                     }
609 609
                 }
610
-            } else {
610
+            }else {
611 611
                 $data = [];
612 612
                 while (key($tokens[2]) !== null) {
613 613
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
             }
625 625
             if ($uid) {
626 626
                 $result[$tokens[2][$uidKey]] = $data;
627
-            }else{
627
+            }else {
628 628
                 $result[$tokens[0]] = $data;
629 629
             }
630 630
         }
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 
691 691
         if ($this->enable_uid_cache && $this->uid_cache) {
692 692
             $uids = $this->uid_cache;
693
-        } else {
693
+        }else {
694 694
             try {
695 695
                 $uids = $this->fetch('UID', 1, INF);
696 696
                 $this->setUidCache($uids); // set cache for this folder
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
791 791
 
792 792
         if ($silent) {
793
-            return (bool)$response;
793
+            return (bool) $response;
794 794
         }
795 795
 
796 796
         $result = [];
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
         $ids = [];
1095 1095
         foreach ($uids as $msgn => $v) {
1096 1096
             $id = $uid ? $v : $msgn;
1097
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1097
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1098 1098
                 $ids[] = $id;
1099 1099
             }
1100 1100
         }
@@ -1127,10 +1127,10 @@  discard block
 block discarded – undo
1127 1127
      * @return int|string
1128 1128
      */
1129 1129
     public function buildSet($from, $to = null) {
1130
-        $set = (int)$from;
1130
+        $set = (int) $from;
1131 1131
         if ($to === null) {
1132 1132
             return $set;
1133 1133
         }
1134
-        return $set . ':' . ($to == INF ? '*' : (int)$to);
1134
+        return $set.':'.($to == INF ? '*' : (int) $to);
1135 1135
     }
1136 1136
 }
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     protected function parse(): void {
160 160
         if ($this->header === null) {
161 161
             $body = $this->findHeaders();
162
-        }else{
162
+        }else {
163 163
             $body = $this->raw;
164 164
         }
165 165
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
         $this->name = $this->header->get("name");
172 172
         $this->filename = $this->header->get("filename");
173 173
 
174
-        if(!empty($this->header->get("id"))) {
174
+        if (!empty($this->header->get("id"))) {
175 175
             $this->id = $this->header->get("id");
176
-        } else if(!empty($this->header->get("x_attachment_id"))){
176
+        }else if (!empty($this->header->get("x_attachment_id"))) {
177 177
             $this->id = $this->header->get("x_attachment_id");
178
-        } else if(!empty($this->header->get("content_id"))){
178
+        }else if (!empty($this->header->get("content_id"))) {
179 179
             $this->id = strtr($this->header->get("content_id"), [
180 180
                 '<' => '',
181 181
                 '>' => ''
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         }
184 184
 
185 185
         $content_types = $this->header->get("content_type");
186
-        if(!empty($content_types)){
186
+        if (!empty($content_types)) {
187 187
             $this->subtype = $this->parseSubtype($content_types);
188 188
             $content_type = $content_types;
189 189
             if (is_array($content_types)) {
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
      *
224 224
      * @return string
225 225
      */
226
-    private function parseSubtype($content_type){
226
+    private function parseSubtype($content_type) {
227 227
         if (is_array($content_type)) {
228
-            foreach ($content_type as $part){
229
-                if ((strpos($part, "/")) !== false){
228
+            foreach ($content_type as $part) {
229
+                if ((strpos($part, "/")) !== false) {
230 230
                     return $this->parseSubtype($part);
231 231
                 }
232 232
             }
233 233
             return null;
234 234
         }
235
-        if (($pos = strpos($content_type, "/")) !== false){
235
+        if (($pos = strpos($content_type, "/")) !== false) {
236 236
             return substr($content_type, $pos + 1);
237 237
         }
238 238
         return null;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      */
244 244
     private function parseDisposition(): void {
245 245
         $content_disposition = $this->header->get("content_disposition");
246
-        if($content_disposition !== null) {
246
+        if ($content_disposition !== null) {
247 247
             $this->ifdisposition = true;
248 248
             $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition;
249 249
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
      */
255 255
     private function parseDescription(): void {
256 256
         $content_description = $this->header->get("content_description");
257
-        if($content_description !== null) {
257
+        if ($content_description !== null) {
258 258
             $this->ifdescription = true;
259 259
             $this->description = $content_description;
260 260
         }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     private function parseEncoding(): void {
267 267
         $encoding = $this->header->get("content_transfer_encoding");
268
-        if($encoding !== null) {
268
+        if ($encoding !== null) {
269 269
             switch (strtolower($encoding)) {
270 270
                 case "quoted-printable":
271 271
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         $this->boot();
169 169
 
170 170
         $default_mask = $client->getDefaultMessageMask();
171
-        if($default_mask != null) {
171
+        if ($default_mask != null) {
172 172
             $this->mask = $default_mask;
173 173
         }
174 174
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $instance->boot();
227 227
 
228 228
         $default_mask = $client->getDefaultMessageMask();
229
-        if($default_mask != null) {
229
+        if ($default_mask != null) {
230 230
             $instance->setMask($default_mask);
231 231
         }
232 232
         $instance->setEvents([
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
         if (strtolower(substr($method, 0, 3)) === 'set') {
278 278
             $name = Str::snake(substr($method, 3));
279
-            if(in_array($name, array_keys($this->attributes))) {
279
+            if (in_array($name, array_keys($this->attributes))) {
280 280
                 return $this->__set($name, array_pop($arguments));
281 281
             }
282 282
         }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * @return Attribute|mixed|null
315 315
      */
316 316
     public function get($name) {
317
-        if(isset($this->attributes[$name])) {
317
+        if (isset($this->attributes[$name])) {
318 318
             return $this->attributes[$name];
319 319
         }
320 320
 
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
     public function parseRawFlags(array $raw_flags): void {
400 400
         $this->flags = FlagCollection::make([]);
401 401
 
402
-        foreach($raw_flags as $flag) {
403
-            if (strpos($flag, "\\") === 0){
402
+        foreach ($raw_flags as $flag) {
403
+            if (strpos($flag, "\\") === 0) {
404 404
                 $flag = substr($flag, 1);
405 405
             }
406 406
             $flag_key = strtolower($flag);
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
     private function fetchPart(Part $part): void {
522 522
         if ($part->isAttachment()) {
523 523
             $this->fetchAttachment($part);
524
-        }else{
524
+        }else {
525 525
             $encoding = $this->getEncoding($part);
526 526
 
527 527
             $content = $this->decodeString($part->content, $part->encoding);
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 
547 547
             if (isset($this->bodies[$subtype])) {
548 548
                 $this->bodies[$subtype] .= "\n".$content;
549
-            }else{
549
+            }else {
550 550
                 $this->bodies[$subtype] = $content;
551 551
             }
552 552
         }
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
         }
567 567
         if ($oAttachment->getId() !== null) {
568 568
             $this->attachments->put($oAttachment->getId(), $oAttachment);
569
-        } else {
569
+        }else {
570 570
             $this->attachments->push($oAttachment);
571 571
         }
572 572
     }
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
                     return EncodingAliases::get($parameter->value, "ISO-8859-2");
713 713
                 }
714 714
             }
715
-        }elseif (property_exists($structure, 'charset')){
715
+        }elseif (property_exists($structure, 'charset')) {
716 716
             return EncodingAliases::get($structure->charset, "ISO-8859-2");
717
-        }elseif (is_string($structure) === true){
717
+        }elseif (is_string($structure) === true) {
718 718
             return mb_detect_encoding($structure);
719 719
         }
720 720
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
      * @throws Exceptions\FolderFetchingException
730 730
      * @throws Exceptions\RuntimeException
731 731
      */
732
-    public function getFolder(){
732
+    public function getFolder() {
733 733
         return $this->client->getFolderByPath($this->folder_path);
734 734
     }
735 735
 
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
      * @throws Exceptions\GetMessagesFailedException
746 746
      * @throws Exceptions\RuntimeException
747 747
      */
748
-    public function thread(Folder $sent_folder = null, MessageCollection &$thread = null, Folder $folder = null): MessageCollection {
748
+    public function thread(Folder $sent_folder = null, MessageCollection & $thread = null, Folder $folder = null): MessageCollection {
749 749
         $thread = $thread ?: MessageCollection::make([]);
750
-        $folder = $folder ?:  $this->getFolder();
750
+        $folder = $folder ?: $this->getFolder();
751 751
         $sent_folder = $sent_folder ?: $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
752 752
 
753 753
         /** @var Message $message */
754
-        foreach($thread as $message) {
754
+        foreach ($thread as $message) {
755 755
             if ($message->message_id->first() == $this->message_id->first()) {
756 756
                 return $thread;
757 757
             }
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
763 763
 
764 764
         if (is_array($this->in_reply_to)) {
765
-            foreach($this->in_reply_to as $in_reply_to) {
765
+            foreach ($this->in_reply_to as $in_reply_to) {
766 766
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
767 767
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
768 768
             }
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
      * @throws Exceptions\RuntimeException
785 785
      * @throws Exceptions\FolderFetchingException
786 786
      */
787
-    protected function fetchThreadByInReplyTo(MessageCollection &$thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder): void{
787
+    protected function fetchThreadByInReplyTo(MessageCollection & $thread, string $in_reply_to, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder): void{
788 788
         $primary_folder->query()->inReplyTo($in_reply_to)
789 789
         ->setFetchBody($this->getFetchBodyOption())
790 790
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder): void{
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
      * @throws Exceptions\RuntimeException
807 807
      * @throws Exceptions\FolderFetchingException
808 808
      */
809
-    protected function fetchThreadByMessageId(MessageCollection &$thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder): void{
809
+    protected function fetchThreadByMessageId(MessageCollection & $thread, string $message_id, Folder $primary_folder, Folder $secondary_folder, Folder $sent_folder): void{
810 810
         $primary_folder->query()->messageId($message_id)
811 811
         ->setFetchBody($this->getFetchBodyOption())
812 812
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder): void{
@@ -901,13 +901,13 @@  discard block
 block discarded – undo
901 901
      * @throws MessageHeaderFetchingException
902 902
      */
903 903
     protected function fetchNewMail(Folder $folder, int $next_uid, string $event, bool $expunge): Message {
904
-        if($expunge) $this->client->expunge();
904
+        if ($expunge) $this->client->expunge();
905 905
 
906 906
         $this->client->openFolder($folder->path);
907 907
 
908 908
         if ($this->sequence === IMAP::ST_UID) {
909 909
             $sequence_id = $next_uid;
910
-        }else{
910
+        }else {
911 911
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
912 912
         }
913 913
 
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
      */
938 938
     public function delete(bool $expunge = true, string $trash_path = null, bool $force_move = false) {
939 939
         $status = $this->setFlag("Deleted");
940
-        if($force_move) {
940
+        if ($force_move) {
941 941
             $trash_path ??= $this->config["common_folders"]["trash"];
942 942
             $status = $this->move($trash_path);
943 943
         }
944
-        if($expunge) $this->client->expunge();
944
+        if ($expunge) $this->client->expunge();
945 945
 
946 946
         $event = $this->getEvent("message", "deleted");
947 947
         $event::dispatch($this);
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
      */
962 962
     public function restore(bool $expunge = true): bool {
963 963
         $status = $this->unsetFlag("Deleted");
964
-        if($expunge) $this->client->expunge();
964
+        if ($expunge) $this->client->expunge();
965 965
 
966 966
         $event = $this->getEvent("message", "restored");
967 967
         $event::dispatch($this);
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
      * @return $this
1205 1205
      */
1206 1206
     public function setMask(string $mask): self {
1207
-        if(class_exists($mask)){
1207
+        if (class_exists($mask)) {
1208 1208
             $this->mask = $mask;
1209 1209
         }
1210 1210
 
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
      */
1230 1230
     public function mask($mask = null): object {
1231 1231
         $mask ??= $this->mask;
1232
-        if(class_exists($mask)){
1232
+        if (class_exists($mask)) {
1233 1233
             return new $mask($this);
1234 1234
         }
1235 1235
 
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
         if ($this->getSequence() === IMAP::ST_UID) {
1382 1382
             $this->setUid($uid);
1383 1383
             $this->setMsglist($msglist);
1384
-        }else{
1384
+        }else {
1385 1385
             $this->setMsgn($uid, $msglist);
1386 1386
         }
1387 1387
     }
Please login to merge, or discard this patch.