Passed
Pull Request — master (#242)
by
unknown
02:35
created
src/Address.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@
 block discarded – undo
33 33
      * @param object   $object
34 34
      */
35 35
     public function __construct($object) {
36
-        if (property_exists($object, "personal")){ $this->personal = $object->personal; }
37
-        if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; }
38
-        if (property_exists($object, "host")){ $this->host = $object->host; }
39
-        if (property_exists($object, "mail")){ $this->mail = $object->mail; }
40
-        if (property_exists($object, "full")){ $this->full = $object->full; }
36
+        if (property_exists($object, "personal")) { $this->personal = $object->personal; }
37
+        if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; }
38
+        if (property_exists($object, "host")) { $this->host = $object->host; }
39
+        if (property_exists($object, "mail")) { $this->mail = $object->mail; }
40
+        if (property_exists($object, "full")) { $this->full = $object->full; }
41 41
     }
42 42
 
43 43
 
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
      */
204 204
     private function setAccountConfig(string $key, array $config, array $default_config): void {
205 205
         $value = $this->default_account_config[$key];
206
-        if(isset($config[$key])) {
206
+        if (isset($config[$key])) {
207 207
             $value = $config[$key];
208
-        }elseif(isset($default_config[$key])) {
208
+        }elseif (isset($default_config[$key])) {
209 209
             $value = $default_config[$key];
210 210
         }
211 211
         $this->$key = $value;
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
      */
218 218
     protected function setEventsFromConfig($config): void {
219 219
         $events = ClientManager::get("events");
220
-        if(isset($config['events'])){
221
-            foreach($config['events'] as $section => $events) {
220
+        if (isset($config['events'])) {
221
+            foreach ($config['events'] as $section => $events) {
222 222
                 $events[$section] = array_merge($events[$section], $events);
223 223
             }
224 224
         }
@@ -232,45 +232,45 @@  discard block
 block discarded – undo
232 232
      * @throws MaskNotFoundException
233 233
      */
234 234
     protected function setMaskFromConfig($config): void {
235
-        $default_config  = ClientManager::get("masks");
235
+        $default_config = ClientManager::get("masks");
236 236
 
237
-        if(isset($config['masks'])){
238
-            if(isset($config['masks']['message'])) {
239
-                if(class_exists($config['masks']['message'])) {
237
+        if (isset($config['masks'])) {
238
+            if (isset($config['masks']['message'])) {
239
+                if (class_exists($config['masks']['message'])) {
240 240
                     $this->default_message_mask = $config['masks']['message'];
241
-                }else{
241
+                }else {
242 242
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
243 243
                 }
244
-            }else{
245
-                if(class_exists($default_config['message'])) {
244
+            }else {
245
+                if (class_exists($default_config['message'])) {
246 246
                     $this->default_message_mask = $default_config['message'];
247
-                }else{
247
+                }else {
248 248
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
249 249
                 }
250 250
             }
251
-            if(isset($config['masks']['attachment'])) {
252
-                if(class_exists($config['masks']['attachment'])) {
251
+            if (isset($config['masks']['attachment'])) {
252
+                if (class_exists($config['masks']['attachment'])) {
253 253
                     $this->default_attachment_mask = $config['masks']['attachment'];
254
-                }else{
254
+                }else {
255 255
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
256 256
                 }
257
-            }else{
258
-                if(class_exists($default_config['attachment'])) {
257
+            }else {
258
+                if (class_exists($default_config['attachment'])) {
259 259
                     $this->default_attachment_mask = $default_config['attachment'];
260
-                }else{
260
+                }else {
261 261
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
262 262
                 }
263 263
             }
264
-        }else{
265
-            if(class_exists($default_config['message'])) {
264
+        }else {
265
+            if (class_exists($default_config['message'])) {
266 266
                 $this->default_message_mask = $default_config['message'];
267
-            }else{
267
+            }else {
268 268
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
269 269
             }
270 270
 
271
-            if(class_exists($default_config['attachment'])) {
271
+            if (class_exists($default_config['attachment'])) {
272 272
                 $this->default_attachment_mask = $default_config['attachment'];
273
-            }else{
273
+            }else {
274 274
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
275 275
             }
276 276
         }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
335 335
             $this->connection->setConnectionTimeout($this->timeout);
336 336
             $this->connection->setProxy($this->proxy);
337
-        }else{
337
+        }else {
338 338
             if (extension_loaded('imap') === false) {
339 339
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
340 340
             }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
         try {
357 357
             $this->connection->connect($this->host, $this->port);
358
-        } catch (ErrorException|Exceptions\RuntimeException $e) {
358
+        } catch (ErrorException | Exceptions\RuntimeException $e) {
359 359
             throw new ConnectionFailedException("connection setup failed", 0, $e);
360 360
         }
361 361
         $this->authenticate();
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 
414 414
         // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names)
415 415
         $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter;
416
-        if (strpos($folder_name, (string)$delimiter) !== false) {
416
+        if (strpos($folder_name, (string) $delimiter) !== false) {
417 417
             return $this->getFolderByPath($folder_name);
418 418
         }
419 419
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
466 466
         $items = $this->connection->folders('', $pattern);
467 467
 
468
-        if(is_array($items)){
468
+        if (is_array($items)) {
469 469
             foreach ($items as $folder_name => $item) {
470 470
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
471 471
 
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
         $this->checkConnection();
518 518
         $status = $this->connection->createFolder($folder);
519 519
 
520
-        if($expunge) $this->expunge();
520
+        if ($expunge) $this->expunge();
521 521
 
522 522
         $folder = $this->getFolder($folder);
523
-        if($status && $folder) {
523
+        if ($status && $folder) {
524 524
             $event = $this->getEvent("folder", "new");
525 525
             $event::dispatch($folder);
526 526
         }
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
      * @throws MaskNotFoundException
649 649
      */
650 650
     public function setDefaultMessageMask(string $mask): self {
651
-        if(class_exists($mask)) {
651
+        if (class_exists($mask)) {
652 652
             $this->default_message_mask = $mask;
653 653
 
654 654
             return $this;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
      * @throws MaskNotFoundException
675 675
      */
676 676
     public function setDefaultAttachmentMask(string $mask): self {
677
-        if(class_exists($mask)) {
677
+        if (class_exists($mask)) {
678 678
             $this->default_attachment_mask = $mask;
679 679
 
680 680
             return $this;
Please login to merge, or discard this patch.
src/Traits/HasEvents.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@
 block discarded – undo
44 44
      * @param array<string, array<string, string>> $events
45 45
      */
46 46
     public function setEvents($events): void {
47
-        foreach($events as $section => $sectionEvents) {
47
+        foreach ($events as $section => $sectionEvents) {
48 48
             assert(is_string($section));
49
-            foreach($sectionEvents as $event => $class) {
49
+            foreach ($sectionEvents as $event => $class) {
50 50
                 assert(is_string($event));
51 51
                 assert(is_string($class) && is_a($class, Event::class, true));
52 52
             }
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
                     $expectedResponse = false;
600 600
                     // maybe the server send another field we didn't want
601 601
                     $count = is_countable($tokens[2]) ? count($tokens[2]) : 0;
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
                         continue;
613 613
                     }
614 614
                 }
615
-            } else {
615
+            }else {
616 616
                 $data = [];
617 617
                 while (key($tokens[2]) !== null) {
618 618
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
             }
630 630
             if ($uid) {
631 631
                 $result[$tokens[2][$uidKey]] = $data;
632
-            }else{
632
+            }else {
633 633
                 $result[$tokens[0]] = $data;
634 634
             }
635 635
         }
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 
696 696
         if ($this->enable_uid_cache && $this->uid_cache) {
697 697
             $uids = $this->uid_cache;
698
-        } else {
698
+        }else {
699 699
             try {
700 700
                 $uids = $this->fetch('UID', 1, INF);
701 701
                 $this->setUidCache($uids); // set cache for this folder
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
         $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent);
796 796
 
797 797
         if ($silent) {
798
-            return (bool)$response;
798
+            return (bool) $response;
799 799
         }
800 800
 
801 801
         $result = [];
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
         $ids = [];
1100 1100
         foreach ($uids as $msgn => $v) {
1101 1101
             $id = $uid ? $v : $msgn;
1102
-            if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){
1102
+            if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) {
1103 1103
                 $ids[] = $id;
1104 1104
             }
1105 1105
         }
@@ -1132,10 +1132,10 @@  discard block
 block discarded – undo
1132 1132
      * @return int|string
1133 1133
      */
1134 1134
     public function buildSet($from, $to = null) {
1135
-        $set = (int)$from;
1135
+        $set = (int) $from;
1136 1136
         if ($to === null) {
1137 1137
             return $set;
1138 1138
         }
1139
-        return $set . ':' . ($to == INF ? '*' : (int)$to);
1139
+        return $set.':'.($to == INF ? '*' : (int) $to);
1140 1140
     }
1141 1141
 }
Please login to merge, or discard this patch.