Passed
Push — master ( 133a7b...2b5dda )
by Malte
02:34
created
src/Client.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
      * @param array $config
204 204
      * @param array $default_config
205 205
      */
206
-    private function setAccountConfig($key, $config, $default_config){
206
+    private function setAccountConfig($key, $config, $default_config) {
207 207
         $value = $this->default_account_config[$key];
208
-        if(isset($config[$key])) {
208
+        if (isset($config[$key])) {
209 209
             $value = $config[$key];
210
-        }elseif(isset($default_config[$key])) {
210
+        }elseif (isset($default_config[$key])) {
211 211
             $value = $default_config[$key];
212 212
         }
213 213
         $this->$key = $value;
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
      */
220 220
     protected function setEventsFromConfig($config) {
221 221
         $this->events = ClientManager::get("events");
222
-        if(isset($config['events'])){
223
-            foreach($config['events'] as $section => $events) {
222
+        if (isset($config['events'])) {
223
+            foreach ($config['events'] as $section => $events) {
224 224
                 $this->events[$section] = array_merge($this->events[$section], $events);
225 225
             }
226 226
         }
@@ -233,45 +233,45 @@  discard block
 block discarded – undo
233 233
      * @throws MaskNotFoundException
234 234
      */
235 235
     protected function setMaskFromConfig($config) {
236
-        $default_config  = ClientManager::get("masks");
236
+        $default_config = ClientManager::get("masks");
237 237
 
238
-        if(isset($config['masks'])){
239
-            if(isset($config['masks']['message'])) {
240
-                if(class_exists($config['masks']['message'])) {
238
+        if (isset($config['masks'])) {
239
+            if (isset($config['masks']['message'])) {
240
+                if (class_exists($config['masks']['message'])) {
241 241
                     $this->default_message_mask = $config['masks']['message'];
242
-                }else{
242
+                }else {
243 243
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
244 244
                 }
245
-            }else{
246
-                if(class_exists($default_config['message'])) {
245
+            }else {
246
+                if (class_exists($default_config['message'])) {
247 247
                     $this->default_message_mask = $default_config['message'];
248
-                }else{
248
+                }else {
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
250 250
                 }
251 251
             }
252
-            if(isset($config['masks']['attachment'])) {
253
-                if(class_exists($config['masks']['attachment'])) {
252
+            if (isset($config['masks']['attachment'])) {
253
+                if (class_exists($config['masks']['attachment'])) {
254 254
                     $this->default_attachment_mask = $config['masks']['attachment'];
255
-                }else{
255
+                }else {
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
257 257
                 }
258
-            }else{
259
-                if(class_exists($default_config['attachment'])) {
258
+            }else {
259
+                if (class_exists($default_config['attachment'])) {
260 260
                     $this->default_attachment_mask = $default_config['attachment'];
261
-                }else{
261
+                }else {
262 262
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
263 263
                 }
264 264
             }
265
-        }else{
266
-            if(class_exists($default_config['message'])) {
265
+        }else {
266
+            if (class_exists($default_config['message'])) {
267 267
                 $this->default_message_mask = $default_config['message'];
268
-            }else{
268
+            }else {
269 269
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
270 270
             }
271 271
 
272
-            if(class_exists($default_config['attachment'])) {
272
+            if (class_exists($default_config['attachment'])) {
273 273
                 $this->default_attachment_mask = $default_config['attachment'];
274
-            }else{
274
+            }else {
275 275
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
276 276
             }
277 277
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
336 336
             $this->connection->setConnectionTimeout($this->timeout);
337 337
             $this->connection->setProxy($this->proxy);
338
-        }else{
338
+        }else {
339 339
             if (extension_loaded('imap') === false) {
340 340
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
341 341
             }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
         // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names)
410 410
         $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter;
411
-        if (strpos($folder_name, (string)$delimiter) !== false) {
411
+        if (strpos($folder_name, (string) $delimiter) !== false) {
412 412
             return $this->getFolderByPath($folder_name);
413 413
         }
414 414
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
461 461
         $items = $this->connection->folders('', $pattern);
462 462
 
463
-        if(is_array($items)){
463
+        if (is_array($items)) {
464 464
             foreach ($items as $folder_name => $item) {
465 465
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
466 466
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             }
476 476
 
477 477
             return $folders;
478
-        }else{
478
+        }else {
479 479
             throw new FolderFetchingException("failed to fetch any folders");
480 480
         }
481 481
     }
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
         $this->checkConnection();
514 514
         $status = $this->connection->createFolder($folder);
515 515
 
516
-        if($expunge) $this->expunge();
516
+        if ($expunge) $this->expunge();
517 517
 
518 518
         $folder = $this->getFolder($folder);
519
-        if($status && $folder) {
519
+        if ($status && $folder) {
520 520
             $event = $this->getEvent("folder", "new");
521 521
             $event::dispatch($folder);
522 522
         }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
      *
543 543
      * @return string
544 544
      */
545
-    public function getFolderPath(){
545
+    public function getFolderPath() {
546 546
         return $this->active_folder;
547 547
     }
548 548
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
      * @return int
601 601
      * @throws ConnectionFailedException
602 602
      */
603
-    public function getTimeout(){
603
+    public function getTimeout() {
604 604
         $this->checkConnection();
605 605
         return $this->connection->getConnectionTimeout();
606 606
     }
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
      *
611 611
      * @return string
612 612
      */
613
-    public function getDefaultMessageMask(){
613
+    public function getDefaultMessageMask() {
614 614
         return $this->default_message_mask;
615 615
     }
616 616
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      *
621 621
      * @return array
622 622
      */
623
-    public function getDefaultEvents($section){
623
+    public function getDefaultEvents($section) {
624 624
         return $this->events[$section];
625 625
     }
626 626
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @throws MaskNotFoundException
633 633
      */
634 634
     public function setDefaultMessageMask($mask) {
635
-        if(class_exists($mask)) {
635
+        if (class_exists($mask)) {
636 636
             $this->default_message_mask = $mask;
637 637
 
638 638
             return $this;
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
      *
647 647
      * @return string
648 648
      */
649
-    public function getDefaultAttachmentMask(){
649
+    public function getDefaultAttachmentMask() {
650 650
         return $this->default_attachment_mask;
651 651
     }
652 652
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
      * @throws MaskNotFoundException
659 659
      */
660 660
     public function setDefaultAttachmentMask($mask) {
661
-        if(class_exists($mask)) {
661
+        if (class_exists($mask)) {
662 662
             $this->default_attachment_mask = $mask;
663 663
 
664 664
             return $this;
Please login to merge, or discard this patch.
Braces   +15 added lines, -13 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $value = $this->default_account_config[$key];
208 208
         if(isset($config[$key])) {
209 209
             $value = $config[$key];
210
-        }elseif(isset($default_config[$key])) {
210
+        } elseif(isset($default_config[$key])) {
211 211
             $value = $default_config[$key];
212 212
         }
213 213
         $this->$key = $value;
@@ -239,39 +239,39 @@  discard block
 block discarded – undo
239 239
             if(isset($config['masks']['message'])) {
240 240
                 if(class_exists($config['masks']['message'])) {
241 241
                     $this->default_message_mask = $config['masks']['message'];
242
-                }else{
242
+                } else{
243 243
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
244 244
                 }
245
-            }else{
245
+            } else{
246 246
                 if(class_exists($default_config['message'])) {
247 247
                     $this->default_message_mask = $default_config['message'];
248
-                }else{
248
+                } else{
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
250 250
                 }
251 251
             }
252 252
             if(isset($config['masks']['attachment'])) {
253 253
                 if(class_exists($config['masks']['attachment'])) {
254 254
                     $this->default_attachment_mask = $config['masks']['attachment'];
255
-                }else{
255
+                } else{
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
257 257
                 }
258
-            }else{
258
+            } else{
259 259
                 if(class_exists($default_config['attachment'])) {
260 260
                     $this->default_attachment_mask = $default_config['attachment'];
261
-                }else{
261
+                } else{
262 262
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
263 263
                 }
264 264
             }
265
-        }else{
265
+        } else{
266 266
             if(class_exists($default_config['message'])) {
267 267
                 $this->default_message_mask = $default_config['message'];
268
-            }else{
268
+            } else{
269 269
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
270 270
             }
271 271
 
272 272
             if(class_exists($default_config['attachment'])) {
273 273
                 $this->default_attachment_mask = $default_config['attachment'];
274
-            }else{
274
+            } else{
275 275
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
276 276
             }
277 277
         }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
336 336
             $this->connection->setConnectionTimeout($this->timeout);
337 337
             $this->connection->setProxy($this->proxy);
338
-        }else{
338
+        } else{
339 339
             if (extension_loaded('imap') === false) {
340 340
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
341 341
             }
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
             }
476 476
 
477 477
             return $folders;
478
-        }else{
478
+        } else{
479 479
             throw new FolderFetchingException("failed to fetch any folders");
480 480
         }
481 481
     }
@@ -513,7 +513,9 @@  discard block
 block discarded – undo
513 513
         $this->checkConnection();
514 514
         $status = $this->connection->createFolder($folder);
515 515
 
516
-        if($expunge) $this->expunge();
516
+        if($expunge) {
517
+            $this->expunge();
518
+        }
517 519
 
518 520
         $folder = $this->getFolder($folder);
519 521
         if($status && $folder) {
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 2 patches
Spacing   +20 added lines, -20 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';
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @return bool
161 161
      */
162
-    public function connected(){
162
+    public function connected() {
163 163
         return boolval($this->stream);
164 164
     }
165 165
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @return array
233 233
      */
234
-    public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){
234
+    public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) {
235 235
         $result = [];
236 236
         $uids = is_array($uids) ? $uids : [$uids];
237 237
         foreach ($uids as $id) {
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      *
248 248
      * @return array
249 249
      */
250
-    public function flags($uids, $uid = IMAP::ST_UID){
250
+    public function flags($uids, $uid = IMAP::ST_UID) {
251 251
         $result = [];
252 252
         $uids = is_array($uids) ? $uids : [$uids];
253 253
         foreach ($uids as $id) {
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
             $flags = [];
256 256
             if (is_array($raw_flags) && isset($raw_flags[0])) {
257 257
                 $raw_flags = (array) $raw_flags[0];
258
-                foreach($raw_flags as $flag => $value) {
259
-                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){
258
+                foreach ($raw_flags as $flag => $value) {
259
+                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) {
260 260
                         $flags[] = "\\".ucfirst($flag);
261 261
                     }
262 262
                 }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         if ($id === null) {
278 278
             $overview = $this->overview("1:*");
279 279
             $uids = [];
280
-            foreach($overview as $set){
280
+            foreach ($overview as $set) {
281 281
                 $uids[$set->msgno] = $set->uid;
282 282
             }
283 283
             return $uids;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * @return array
304 304
      */
305 305
     public function overview($sequence, $uid = IMAP::ST_UID) {
306
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL);
306
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL);
307 307
     }
308 308
 
309 309
     /**
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
         $result = [];
319 319
 
320 320
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
321
-        if(is_array($items)){
321
+        if (is_array($items)) {
322 322
             foreach ($items as $item) {
323 323
                 $name = $this->decodeFolderName($item->name);
324 324
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
325 325
             }
326
-        }else{
326
+        }else {
327 327
             throw new RuntimeException(\imap_last_error());
328 328
         }
329 329
 
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID) {
346 346
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
347 347
 
348
-        if ($mode == "+"){
348
+        if ($mode == "+") {
349 349
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
350
-        }else{
350
+        }else {
351 351
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
352 352
         }
353 353
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
      */
370 370
     public function appendMessage($folder, $message, $flags = null, $date = null) {
371 371
         if ($date != null) {
372
-            if ($date instanceof \Carbon\Carbon){
372
+            if ($date instanceof \Carbon\Carbon) {
373 373
                 $date = $date->format('d-M-Y H:i:s O');
374 374
             }
375 375
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      * @return array|bool Tokens if operation successful, false if an error occurred
402 402
      */
403 403
     public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
404
-        foreach($messages as $msg) {
404
+        foreach ($messages as $msg) {
405 405
             if ($this->copyMessage($folder, $msg, null, $uid) == false) {
406 406
                 return false;
407 407
             }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
      * @return array|bool Tokens if operation successful, false if an error occurred
434 434
      */
435 435
     public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) {
436
-        foreach($messages as $msg) {
436
+        foreach ($messages as $msg) {
437 437
             if ($this->moveMessage($folder, $msg, null, $uid) == false) {
438 438
                 return false;
439 439
             }
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
     /**
557 557
      * Enable the debug mode
558 558
      */
559
-    public function enableDebug(){
559
+    public function enableDebug() {
560 560
         $this->debug = true;
561 561
     }
562 562
 
563 563
     /**
564 564
      * Disable the debug mode
565 565
      */
566
-    public function disableDebug(){
566
+    public function disableDebug() {
567 567
         $this->debug = false;
568 568
     }
569 569
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                 $name = $this->decodeFolderName($item->name);
324 324
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
325 325
             }
326
-        }else{
326
+        } else{
327 327
             throw new RuntimeException(\imap_last_error());
328 328
         }
329 329
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
         if ($mode == "+"){
349 349
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
350
-        }else{
350
+        } else{
351 351
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL);
352 352
         }
353 353
 
Please login to merge, or discard this patch.
src/Query/Query.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
         if (ClientManager::get('options.fetch_order') === 'desc') {
97 97
             $this->fetch_order = 'desc';
98
-        } else {
98
+        }else {
99 99
             $this->fetch_order = 'asc';
100 100
         }
101 101
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
                 break;
127 127
         }
128 128
 
129
-        return (string)$value;
129
+        return (string) $value;
130 130
     }
131 131
 
132 132
     /**
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
         $this->query->each(function($statement) use (&$query) {
159 159
             if (count($statement) == 1) {
160 160
                 $query .= $statement[0];
161
-            } else {
161
+            }else {
162 162
                 if ($statement[1] === null) {
163 163
                     $query .= $statement[0];
164
-                } else {
164
+                }else {
165 165
                     if (is_numeric($statement[1])) {
166
-                        $query .= $statement[0] . ' ' . $statement[1];
167
-                    } else {
168
-                        $query .= $statement[0] . ' "' . $statement[1] . '"';
166
+                        $query .= $statement[0].' '.$statement[1];
167
+                    }else {
168
+                        $query .= $statement[0].' "'.$statement[1].'"';
169 169
                     }
170 170
                 }
171 171
             }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                 $key = $message->getMessageId();
300 300
                 break;
301 301
         }
302
-        return (string)$key;
302
+        return (string) $key;
303 303
     }
304 304
 
305 305
     /**
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             $extensions = isset($raw_messages["extensions"][$uid]) ? $raw_messages["extensions"][$uid] : [];
330 330
 
331 331
             $message = $this->make($uid, $msglist, $header, $content, $flag);
332
-            foreach($extensions as $key => $extension) {
332
+            foreach ($extensions as $key => $extension) {
333 333
                 $message->getHeader()->set($key, $extension);
334 334
             }
335 335
             if ($message !== null) {
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,7 +91,9 @@  discard block
 block discarded – undo
91 91
         $this->setClient($client);
92 92
 
93 93
         $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN);
94
-        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
94
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) {
95
+            $this->leaveUnread();
96
+        }
95 97
 
96 98
         if (ClientManager::get('options.fetch_order') === 'desc') {
97 99
             $this->fetch_order = 'desc';
@@ -137,7 +139,9 @@  discard block
 block discarded – undo
137 139
      * @throws MessageSearchValidationException
138 140
      */
139 141
     protected function parse_date($date) {
140
-        if ($date instanceof Carbon) return $date;
142
+        if ($date instanceof Carbon) {
143
+            return $date;
144
+        }
141 145
 
142 146
         try {
143 147
             $date = Carbon::parse($date);
@@ -533,7 +537,9 @@  discard block
 block discarded – undo
533 537
      * @return $this
534 538
      */
535 539
     public function limit($limit, $page = 1) {
536
-        if ($page >= 1) $this->page = $page;
540
+        if ($page >= 1) {
541
+            $this->page = $page;
542
+        }
537 543
         $this->limit = $limit;
538 544
 
539 545
         return $this;
Please login to merge, or discard this patch.