Completed
Branch master (e1296d)
by Malte
02:30
created
src/Client.php 1 patch
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_message_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_message_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_message_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.