Passed
Push — master ( 0d1074...eef78d )
by Malte
02:00
created
src/Client.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
      * @param array $config
195 195
      * @param array $default_config
196 196
      */
197
-    private function setAccountConfig($key, $config, $default_config){
197
+    private function setAccountConfig($key, $config, $default_config) {
198 198
         $value = $this->default_account_config[$key];
199
-        if(isset($config[$key])) {
199
+        if (isset($config[$key])) {
200 200
             $value = $config[$key];
201
-        }elseif(isset($default_config[$key])) {
201
+        }elseif (isset($default_config[$key])) {
202 202
             $value = $default_config[$key];
203 203
         }
204 204
         $this->$key = $value;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
      */
211 211
     protected function setEventsFromConfig($config) {
212 212
         $this->events = ClientManager::get("events");
213
-        if(isset($config['events'])){
214
-            if(isset($config['events'])) {
215
-                foreach($config['events'] as $section => $events) {
213
+        if (isset($config['events'])) {
214
+            if (isset($config['events'])) {
215
+                foreach ($config['events'] as $section => $events) {
216 216
                     $this->events[$section] = array_merge($this->events[$section], $events);
217 217
                 }
218 218
             }
@@ -226,45 +226,45 @@  discard block
 block discarded – undo
226 226
      * @throws MaskNotFoundException
227 227
      */
228 228
     protected function setMaskFromConfig($config) {
229
-        $default_config  = ClientManager::get("masks");
229
+        $default_config = ClientManager::get("masks");
230 230
 
231
-        if(isset($config['masks'])){
232
-            if(isset($config['masks']['message'])) {
233
-                if(class_exists($config['masks']['message'])) {
231
+        if (isset($config['masks'])) {
232
+            if (isset($config['masks']['message'])) {
233
+                if (class_exists($config['masks']['message'])) {
234 234
                     $this->default_message_mask = $config['masks']['message'];
235
-                }else{
235
+                }else {
236 236
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
237 237
                 }
238
-            }else{
239
-                if(class_exists($default_config['message'])) {
238
+            }else {
239
+                if (class_exists($default_config['message'])) {
240 240
                     $this->default_message_mask = $default_config['message'];
241
-                }else{
241
+                }else {
242 242
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
243 243
                 }
244 244
             }
245
-            if(isset($config['masks']['attachment'])) {
246
-                if(class_exists($config['masks']['attachment'])) {
245
+            if (isset($config['masks']['attachment'])) {
246
+                if (class_exists($config['masks']['attachment'])) {
247 247
                     $this->default_message_mask = $config['masks']['attachment'];
248
-                }else{
248
+                }else {
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
250 250
                 }
251
-            }else{
252
-                if(class_exists($default_config['attachment'])) {
251
+            }else {
252
+                if (class_exists($default_config['attachment'])) {
253 253
                     $this->default_message_mask = $default_config['attachment'];
254
-                }else{
254
+                }else {
255 255
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
256 256
                 }
257 257
             }
258
-        }else{
259
-            if(class_exists($default_config['message'])) {
258
+        }else {
259
+            if (class_exists($default_config['message'])) {
260 260
                 $this->default_message_mask = $default_config['message'];
261
-            }else{
261
+            }else {
262 262
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
263 263
             }
264 264
 
265
-            if(class_exists($default_config['attachment'])) {
265
+            if (class_exists($default_config['attachment'])) {
266 266
                 $this->default_message_mask = $default_config['attachment'];
267
-            }else{
267
+            }else {
268 268
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
269 269
             }
270 270
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
330 330
             $this->connection->setConnectionTimeout($timeout);
331 331
             $this->connection->setProxy($this->proxy);
332
-        }else{
332
+        }else {
333 333
             if (extension_loaded('imap') === false) {
334 334
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
335 335
             }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
443 443
         $items = $this->connection->folders('', $pattern);
444 444
 
445
-        if(is_array($items)){
445
+        if (is_array($items)) {
446 446
             foreach ($items as $folder_name => $item) {
447 447
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
448 448
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             }
458 458
 
459 459
             return $folders;
460
-        }else{
460
+        }else {
461 461
             throw new FolderFetchingException("failed to fetch any folders");
462 462
         }
463 463
     }
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
         $this->checkConnection();
494 494
         $status = $this->connection->createFolder($folder);
495 495
 
496
-        if($expunge) $this->expunge();
496
+        if ($expunge) $this->expunge();
497 497
 
498 498
         $folder = $this->getFolder($folder);
499
-        if($status && $folder) {
499
+        if ($status && $folder) {
500 500
             $event = $this->getEvent("folder", "new");
501 501
             $event::dispatch($folder);
502 502
         }
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      *
522 522
      * @return Folder
523 523
      */
524
-    public function getFolderPath(){
524
+    public function getFolderPath() {
525 525
         return $this->active_folder;
526 526
     }
527 527
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      *
576 576
      * @return int
577 577
      */
578
-    public function getTimeout($type){
578
+    public function getTimeout($type) {
579 579
         return $this->connection->getConnectionTimeout();
580 580
     }
581 581
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
      *
585 585
      * @return string
586 586
      */
587
-    public function getDefaultMessageMask(){
587
+    public function getDefaultMessageMask() {
588 588
         return $this->default_message_mask;
589 589
     }
590 590
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      *
595 595
      * @return array
596 596
      */
597
-    public function getDefaultEvents($section){
597
+    public function getDefaultEvents($section) {
598 598
         return $this->events[$section];
599 599
     }
600 600
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      * @throws MaskNotFoundException
607 607
      */
608 608
     public function setDefaultMessageMask($mask) {
609
-        if(class_exists($mask)) {
609
+        if (class_exists($mask)) {
610 610
             $this->default_message_mask = $mask;
611 611
 
612 612
             return $this;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      *
621 621
      * @return string
622 622
      */
623
-    public function getDefaultAttachmentMask(){
623
+    public function getDefaultAttachmentMask() {
624 624
         return $this->default_attachment_mask;
625 625
     }
626 626
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @throws MaskNotFoundException
633 633
      */
634 634
     public function setDefaultAttachmentMask($mask) {
635
-        if(class_exists($mask)) {
635
+        if (class_exists($mask)) {
636 636
             $this->default_attachment_mask = $mask;
637 637
 
638 638
             return $this;
Please login to merge, or discard this patch.
Braces   +15 added lines, -13 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $value = $this->default_account_config[$key];
199 199
         if(isset($config[$key])) {
200 200
             $value = $config[$key];
201
-        }elseif(isset($default_config[$key])) {
201
+        } elseif(isset($default_config[$key])) {
202 202
             $value = $default_config[$key];
203 203
         }
204 204
         $this->$key = $value;
@@ -232,39 +232,39 @@  discard block
 block discarded – undo
232 232
             if(isset($config['masks']['message'])) {
233 233
                 if(class_exists($config['masks']['message'])) {
234 234
                     $this->default_message_mask = $config['masks']['message'];
235
-                }else{
235
+                } else{
236 236
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
237 237
                 }
238
-            }else{
238
+            } else{
239 239
                 if(class_exists($default_config['message'])) {
240 240
                     $this->default_message_mask = $default_config['message'];
241
-                }else{
241
+                } else{
242 242
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
243 243
                 }
244 244
             }
245 245
             if(isset($config['masks']['attachment'])) {
246 246
                 if(class_exists($config['masks']['attachment'])) {
247 247
                     $this->default_message_mask = $config['masks']['attachment'];
248
-                }else{
248
+                } else{
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
250 250
                 }
251
-            }else{
251
+            } else{
252 252
                 if(class_exists($default_config['attachment'])) {
253 253
                     $this->default_message_mask = $default_config['attachment'];
254
-                }else{
254
+                } else{
255 255
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
256 256
                 }
257 257
             }
258
-        }else{
258
+        } else{
259 259
             if(class_exists($default_config['message'])) {
260 260
                 $this->default_message_mask = $default_config['message'];
261
-            }else{
261
+            } else{
262 262
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
263 263
             }
264 264
 
265 265
             if(class_exists($default_config['attachment'])) {
266 266
                 $this->default_message_mask = $default_config['attachment'];
267
-            }else{
267
+            } else{
268 268
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
269 269
             }
270 270
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
330 330
             $this->connection->setConnectionTimeout($timeout);
331 331
             $this->connection->setProxy($this->proxy);
332
-        }else{
332
+        } else{
333 333
             if (extension_loaded('imap') === false) {
334 334
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
335 335
             }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             }
458 458
 
459 459
             return $folders;
460
-        }else{
460
+        } else{
461 461
             throw new FolderFetchingException("failed to fetch any folders");
462 462
         }
463 463
     }
@@ -493,7 +493,9 @@  discard block
 block discarded – undo
493 493
         $this->checkConnection();
494 494
         $status = $this->connection->createFolder($folder);
495 495
 
496
-        if($expunge) $this->expunge();
496
+        if($expunge) {
497
+            $this->expunge();
498
+        }
497 499
 
498 500
         $folder = $this->getFolder($folder);
499 501
         if($status && $folder) {
Please login to merge, or discard this patch.