Passed
Push — master ( 836369...33c22e )
by Malte
02:29
created
src/Client.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
      * @param array $config
211 211
      * @param array $default_config
212 212
      */
213
-    private function setAccountConfig(string $key, array $config, array $default_config){
213
+    private function setAccountConfig(string $key, array $config, array $default_config) {
214 214
         $value = $this->default_account_config[$key];
215
-        if(isset($config[$key])) {
215
+        if (isset($config[$key])) {
216 216
             $value = $config[$key];
217
-        }elseif(isset($default_config[$key])) {
217
+        }elseif (isset($default_config[$key])) {
218 218
             $value = $default_config[$key];
219 219
         }
220 220
         $this->$key = $value;
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
      */
227 227
     protected function setEventsFromConfig($config) {
228 228
         $this->events = ClientManager::get("events");
229
-        if(isset($config['events'])){
230
-            foreach($config['events'] as $section => $events) {
229
+        if (isset($config['events'])) {
230
+            foreach ($config['events'] as $section => $events) {
231 231
                 $this->events[$section] = array_merge($this->events[$section], $events);
232 232
             }
233 233
         }
@@ -240,45 +240,45 @@  discard block
 block discarded – undo
240 240
      * @throws MaskNotFoundException
241 241
      */
242 242
     protected function setMaskFromConfig($config) {
243
-        $default_config  = ClientManager::get("masks");
243
+        $default_config = ClientManager::get("masks");
244 244
 
245
-        if(isset($config['masks'])){
246
-            if(isset($config['masks']['message'])) {
247
-                if(class_exists($config['masks']['message'])) {
245
+        if (isset($config['masks'])) {
246
+            if (isset($config['masks']['message'])) {
247
+                if (class_exists($config['masks']['message'])) {
248 248
                     $this->default_message_mask = $config['masks']['message'];
249
-                }else{
249
+                }else {
250 250
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
251 251
                 }
252
-            }else{
253
-                if(class_exists($default_config['message'])) {
252
+            }else {
253
+                if (class_exists($default_config['message'])) {
254 254
                     $this->default_message_mask = $default_config['message'];
255
-                }else{
255
+                }else {
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
257 257
                 }
258 258
             }
259
-            if(isset($config['masks']['attachment'])) {
260
-                if(class_exists($config['masks']['attachment'])) {
259
+            if (isset($config['masks']['attachment'])) {
260
+                if (class_exists($config['masks']['attachment'])) {
261 261
                     $this->default_attachment_mask = $config['masks']['attachment'];
262
-                }else{
262
+                }else {
263 263
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
264 264
                 }
265
-            }else{
266
-                if(class_exists($default_config['attachment'])) {
265
+            }else {
266
+                if (class_exists($default_config['attachment'])) {
267 267
                     $this->default_attachment_mask = $default_config['attachment'];
268
-                }else{
268
+                }else {
269 269
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
270 270
                 }
271 271
             }
272
-        }else{
273
-            if(class_exists($default_config['message'])) {
272
+        }else {
273
+            if (class_exists($default_config['message'])) {
274 274
                 $this->default_message_mask = $default_config['message'];
275
-            }else{
275
+            }else {
276 276
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
277 277
             }
278 278
 
279
-            if(class_exists($default_config['attachment'])) {
279
+            if (class_exists($default_config['attachment'])) {
280 280
                 $this->default_attachment_mask = $default_config['attachment'];
281
-            }else{
281
+            }else {
282 282
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
283 283
             }
284 284
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
343 343
             $this->connection->setConnectionTimeout($this->timeout);
344 344
             $this->connection->setProxy($this->proxy);
345
-        }else{
345
+        }else {
346 346
             if (extension_loaded('imap') === false) {
347 347
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
348 348
             }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 
424 424
         // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names)
425 425
         $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter;
426
-        if (strpos($folder_name, (string)$delimiter) !== false) {
426
+        if (strpos($folder_name, (string) $delimiter) !== false) {
427 427
             return $this->getFolderByPath($folder_name);
428 428
         }
429 429
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
476 476
         $items = $this->connection->folders('', $pattern);
477 477
 
478
-        if(is_array($items)){
478
+        if (is_array($items)) {
479 479
             foreach ($items as $folder_name => $item) {
480 480
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
481 481
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
 
492 492
             return $folders;
493
-        }else{
493
+        }else {
494 494
             throw new FolderFetchingException("failed to fetch any folders");
495 495
         }
496 496
     }
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
515 515
         $items = $this->connection->folders('', $pattern);
516 516
 
517
-        if(is_array($items)){
517
+        if (is_array($items)) {
518 518
             foreach ($items as $folder_name => $item) {
519 519
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
520 520
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             }
531 531
 
532 532
             return $folders;
533
-        }else{
533
+        }else {
534 534
             throw new FolderFetchingException("failed to fetch any folders");
535 535
         }
536 536
     }
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
         $this->checkConnection();
569 569
         $status = $this->connection->createFolder($folder);
570 570
 
571
-        if($expunge) $this->expunge();
571
+        if ($expunge) $this->expunge();
572 572
 
573 573
         $folder = $this->getFolderByPath($folder);
574
-        if($status && $folder) {
574
+        if ($status && $folder) {
575 575
             $event = $this->getEvent("folder", "new");
576 576
             $event::dispatch($folder);
577 577
         }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
      *
598 598
      * @return string
599 599
      */
600
-    public function getFolderPath(){
600
+    public function getFolderPath() {
601 601
         return $this->active_folder;
602 602
     }
603 603
 
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
      * @throws MaskNotFoundException
710 710
      */
711 711
     public function setDefaultMessageMask(string $mask): Client {
712
-        if(class_exists($mask)) {
712
+        if (class_exists($mask)) {
713 713
             $this->default_message_mask = $mask;
714 714
 
715 715
             return $this;
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      * @throws MaskNotFoundException
736 736
      */
737 737
     public function setDefaultAttachmentMask(string $mask): Client {
738
-        if(class_exists($mask)) {
738
+        if (class_exists($mask)) {
739 739
             $this->default_attachment_mask = $mask;
740 740
 
741 741
             return $this;
Please login to merge, or discard this patch.
Braces   +16 added lines, -14 removed lines patch added patch discarded remove patch
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
         $value = $this->default_account_config[$key];
215 215
         if(isset($config[$key])) {
216 216
             $value = $config[$key];
217
-        }elseif(isset($default_config[$key])) {
217
+        } elseif(isset($default_config[$key])) {
218 218
             $value = $default_config[$key];
219 219
         }
220 220
         $this->$key = $value;
@@ -246,39 +246,39 @@  discard block
 block discarded – undo
246 246
             if(isset($config['masks']['message'])) {
247 247
                 if(class_exists($config['masks']['message'])) {
248 248
                     $this->default_message_mask = $config['masks']['message'];
249
-                }else{
249
+                } else{
250 250
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
251 251
                 }
252
-            }else{
252
+            } else{
253 253
                 if(class_exists($default_config['message'])) {
254 254
                     $this->default_message_mask = $default_config['message'];
255
-                }else{
255
+                } else{
256 256
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
257 257
                 }
258 258
             }
259 259
             if(isset($config['masks']['attachment'])) {
260 260
                 if(class_exists($config['masks']['attachment'])) {
261 261
                     $this->default_attachment_mask = $config['masks']['attachment'];
262
-                }else{
262
+                } else{
263 263
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
264 264
                 }
265
-            }else{
265
+            } else{
266 266
                 if(class_exists($default_config['attachment'])) {
267 267
                     $this->default_attachment_mask = $default_config['attachment'];
268
-                }else{
268
+                } else{
269 269
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
270 270
                 }
271 271
             }
272
-        }else{
272
+        } else{
273 273
             if(class_exists($default_config['message'])) {
274 274
                 $this->default_message_mask = $default_config['message'];
275
-            }else{
275
+            } else{
276 276
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
277 277
             }
278 278
 
279 279
             if(class_exists($default_config['attachment'])) {
280 280
                 $this->default_attachment_mask = $default_config['attachment'];
281
-            }else{
281
+            } else{
282 282
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
283 283
             }
284 284
         }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
343 343
             $this->connection->setConnectionTimeout($this->timeout);
344 344
             $this->connection->setProxy($this->proxy);
345
-        }else{
345
+        } else{
346 346
             if (extension_loaded('imap') === false) {
347 347
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
348 348
             }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             }
491 491
 
492 492
             return $folders;
493
-        }else{
493
+        } else{
494 494
             throw new FolderFetchingException("failed to fetch any folders");
495 495
         }
496 496
     }
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
             }
531 531
 
532 532
             return $folders;
533
-        }else{
533
+        } else{
534 534
             throw new FolderFetchingException("failed to fetch any folders");
535 535
         }
536 536
     }
@@ -568,7 +568,9 @@  discard block
 block discarded – undo
568 568
         $this->checkConnection();
569 569
         $status = $this->connection->createFolder($folder);
570 570
 
571
-        if($expunge) $this->expunge();
571
+        if($expunge) {
572
+            $this->expunge();
573
+        }
572 574
 
573 575
         $folder = $this->getFolderByPath($folder);
574 576
         if($status && $folder) {
Please login to merge, or discard this patch.