Passed
Push — master ( abc37e...cf81b9 )
by Malte
05:39
created
src/IMAP/Support/PaginatedCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
      * @return int|null
70 70
      */
71 71
     public function total($total = null) {
72
-        if($total === null) {
72
+        if ($total === null) {
73 73
             return $this->total;
74 74
         }
75 75
 
Please login to merge, or discard this patch.
src/IMAP/Client.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -173,45 +173,45 @@  discard block
 block discarded – undo
173 173
      * @throws MaskNotFoundException
174 174
      */
175 175
     protected function setMaskFromConfig($config) {
176
-        $default_config  = config("imap.masks");
176
+        $default_config = config("imap.masks");
177 177
 
178
-        if(isset($config['masks'])){
179
-            if(isset($config['masks']['message'])) {
180
-                if(class_exists($config['masks']['message'])) {
178
+        if (isset($config['masks'])) {
179
+            if (isset($config['masks']['message'])) {
180
+                if (class_exists($config['masks']['message'])) {
181 181
                     $this->default_message_mask = $config['masks']['message'];
182
-                }else{
182
+                } else {
183 183
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
184 184
                 }
185
-            }else{
186
-                if(class_exists($default_config['message'])) {
185
+            } else {
186
+                if (class_exists($default_config['message'])) {
187 187
                     $this->default_message_mask = $default_config['message'];
188
-                }else{
188
+                } else {
189 189
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
190 190
                 }
191 191
             }
192
-            if(isset($config['masks']['attachment'])) {
193
-                if(class_exists($config['masks']['attachment'])) {
192
+            if (isset($config['masks']['attachment'])) {
193
+                if (class_exists($config['masks']['attachment'])) {
194 194
                     $this->default_message_mask = $config['masks']['attachment'];
195
-                }else{
195
+                } else {
196 196
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
197 197
                 }
198
-            }else{
199
-                if(class_exists($default_config['attachment'])) {
198
+            } else {
199
+                if (class_exists($default_config['attachment'])) {
200 200
                     $this->default_message_mask = $default_config['attachment'];
201
-                }else{
201
+                } else {
202 202
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
203 203
                 }
204 204
             }
205
-        }else{
206
-            if(class_exists($default_config['message'])) {
205
+        } else {
206
+            if (class_exists($default_config['message'])) {
207 207
                 $this->default_message_mask = $default_config['message'];
208
-            }else{
208
+            } else {
209 209
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
210 210
             }
211 211
 
212
-            if(class_exists($default_config['attachment'])) {
212
+            if (class_exists($default_config['attachment'])) {
213 213
                 $this->default_message_mask = $default_config['attachment'];
214
-            }else{
214
+            } else {
215 215
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
216 216
             }
217 217
         }
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
359 359
 
360 360
         $items = imap_getmailboxes($this->connection, $this->getAddress(), $pattern);
361
-        if(is_array($items)){
361
+        if (is_array($items)) {
362 362
             foreach ($items as $item) {
363 363
                 $folder = new Folder($this, $item);
364 364
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             }
374 374
 
375 375
             return $folders;
376
-        }else{
376
+        } else {
377 377
             throw new MailboxFetchingException($this->getLastError());
378 378
         }
379 379
     }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     public function openFolder($folder_path, $attempts = 3) {
390 390
         $this->checkConnection();
391 391
 
392
-        if(property_exists($folder_path, 'path')) {
392
+        if (property_exists($folder_path, 'path')) {
393 393
             $folder_path = $folder_path->path;
394 394
         }
395 395
 
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
      */
411 411
     public function createFolder($name, $expunge = true) {
412 412
         $this->checkConnection();
413
-        $status = imap_createmailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
414
-        if($expunge) $this->expunge();
413
+        $status = imap_createmailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($name));
414
+        if ($expunge) $this->expunge();
415 415
 
416 416
         return $status;
417 417
     }
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
      */
428 428
     public function renameFolder($old_name, $new_name, $expunge = true) {
429 429
         $this->checkConnection();
430
-        $status = imap_renamemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name));
431
-        if($expunge) $this->expunge();
430
+        $status = imap_renamemailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($old_name), $this->getAddress().imap_utf7_encode($new_name));
431
+        if ($expunge) $this->expunge();
432 432
 
433 433
         return $status;
434 434
     }
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
      */
444 444
     public function deleteFolder($name, $expunge = true) {
445 445
         $this->checkConnection();
446
-        $status = imap_deletemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
447
-        if($expunge) $this->expunge();
446
+        $status = imap_deletemailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($name));
447
+        if ($expunge) $this->expunge();
448 448
 
449 449
         return $status;
450 450
     }
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
         if (!$this->validate_cert) {
539 539
             $address .= '/novalidate-cert';
540 540
         }
541
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
541
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
542 542
             $address .= '/'.$this->encryption;
543 543
         } elseif ($this->encryption === "starttls") {
544 544
             $address .= '/tls';
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
      * @throws InvalidImapTimeoutTypeException
662 662
      */
663 663
     public function setTimeout($type, $timeout) {
664
-        if(0 <= $type && $type <= 4) {
664
+        if (0 <= $type && $type <= 4) {
665 665
             return imap_timeout($type, $timeout);
666 666
         }
667 667
 
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
      * @return mixed
676 676
      * @throws InvalidImapTimeoutTypeException
677 677
      */
678
-    public function getTimeout($type){
679
-        if(0 <= $type && $type <= 4) {
678
+    public function getTimeout($type) {
679
+        if (0 <= $type && $type <= 4) {
680 680
             return imap_timeout($type);
681 681
         }
682 682
 
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
     /**
687 687
      * @return string
688 688
      */
689
-    public function getDefaultMessageMask(){
689
+    public function getDefaultMessageMask() {
690 690
         return $this->default_message_mask;
691 691
     }
692 692
 
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
      * @throws MaskNotFoundException
698 698
      */
699 699
     public function setDefaultMessageMask($mask) {
700
-        if(class_exists($mask)) {
700
+        if (class_exists($mask)) {
701 701
             $this->default_message_mask = $mask;
702 702
 
703 703
             return $this;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     /**
710 710
      * @return string
711 711
      */
712
-    public function getDefaultAttachmentMask(){
712
+    public function getDefaultAttachmentMask() {
713 713
         return $this->default_attachment_mask;
714 714
     }
715 715
 
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      * @throws MaskNotFoundException
721 721
      */
722 722
     public function setDefaultAttachmentMask($mask) {
723
-        if(class_exists($mask)) {
723
+        if (class_exists($mask)) {
724 724
             $this->default_attachment_mask = $mask;
725 725
 
726 726
             return $this;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
      *
735 735
      * @return Folder
736 736
      */
737
-    public function getFolderPath(){
737
+    public function getFolderPath() {
738 738
         return $this->active_folder;
739 739
     }
740 740
 }
Please login to merge, or discard this patch.
src/IMAP/Message.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
197 197
 
198 198
         $default_mask = $client->getDefaultMessageMask();
199
-        if($default_mask != null) {
199
+        if ($default_mask != null) {
200 200
             $this->mask = $default_mask;
201 201
         }
202 202
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $this->msglist = $msglist;
216 216
         $this->client = $client;
217 217
 
218
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
218
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
219 219
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? imap_msgno($this->client->getConnection(), $uid) : $uid;
220 220
 
221 221
         $this->parseHeader();
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
      * @throws MethodNotFoundException
239 239
      */
240 240
     public function __call($method, $arguments) {
241
-        if(strtolower(substr($method, 0, 3)) === 'get') {
241
+        if (strtolower(substr($method, 0, 3)) === 'get') {
242 242
             $name = snake_case(substr($method, 3));
243 243
 
244
-            if(in_array($name, array_keys($this->attributes))) {
244
+            if (in_array($name, array_keys($this->attributes))) {
245 245
                 return $this->attributes[$name];
246 246
             }
247 247
 
248 248
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
249 249
             $name = snake_case(substr($method, 3));
250 250
 
251
-            if(in_array($name, array_keys($this->attributes))) {
251
+            if (in_array($name, array_keys($this->attributes))) {
252 252
                 $this->attributes[$name] = array_pop($arguments);
253 253
 
254 254
                 return $this->attributes[$name];
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      * @return mixed|null
278 278
      */
279 279
     public function __get($name) {
280
-        if(isset($this->attributes[$name])) {
280
+        if (isset($this->attributes[$name])) {
281 281
             return $this->attributes[$name];
282 282
         }
283 283
 
@@ -363,11 +363,11 @@  discard block
 block discarded – undo
363 363
         if ($replaceImages !== false) {
364 364
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
365 365
                 /** @var Attachment $oAttachment */
366
-                if(is_callable($replaceImages)) {
366
+                if (is_callable($replaceImages)) {
367 367
                     $body = $replaceImages($body, $oAttachment);
368
-                }elseif(is_string($replaceImages)) {
368
+                }elseif (is_string($replaceImages)) {
369 369
                     call_user_func($replaceImages, [$body, $oAttachment]);
370
-                }else{
370
+                } else {
371 371
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
372 372
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
373 373
                     }
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
         }
397 397
 
398 398
         if (property_exists($header, 'subject')) {
399
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
399
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
400 400
                 $this->subject = imap_utf8($header->subject);
401
-            }else{
401
+            } else {
402 402
                 $this->subject = mb_decode_mimeheader($header->subject);
403 403
             }
404 404
         }
405 405
 
406
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
406
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
407 407
             $this->extractHeaderAddressPart($header, $part);
408 408
         }
409 409
 
@@ -433,9 +433,9 @@  discard block
 block discarded – undo
433 433
      * @return int|null
434 434
      */
435 435
     private function extractPriority($header) {
436
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
436
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
437 437
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
438
-            switch($priority){
438
+            switch ($priority) {
439 439
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
440 440
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
441 441
                     break;
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
         if (property_exists($header, 'date')) {
487 487
             $date = $header->date;
488 488
 
489
-            if(preg_match('/\+0580/', $date)) {
489
+            if (preg_match('/\+0580/', $date)) {
490 490
                 $date = str_replace('+0580', '+0530', $date);
491 491
             }
492 492
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
                         $date = trim(array_pop($array));
509 509
                         break;
510 510
                 }
511
-                try{
511
+                try {
512 512
                     $parsed_date = Carbon::parse($date);
513 513
                 } catch (\Exception $_e) {
514 514
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
         $this->client->openFolder($this->folder_path);
532 532
         $flags = imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
533 533
         if (is_array($flags) && isset($flags[0])) {
534
-            foreach($this->available_flags as $flag) {
534
+            foreach ($this->available_flags as $flag) {
535 535
                 $this->parseFlag($flags, $flag);
536 536
             }
537 537
         }
@@ -628,12 +628,12 @@  discard block
 block discarded – undo
628 628
         $this->client->openFolder($this->folder_path);
629 629
         $this->structure = imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
630 630
 
631
-        if(property_exists($this->structure, 'parts')){
631
+        if (property_exists($this->structure, 'parts')) {
632 632
             $parts = $this->structure->parts;
633 633
 
634
-            foreach ($parts as $part)  {
635
-                foreach ($part->parameters as $parameter)  {
636
-                    if($parameter->attribute == "charset")  {
634
+            foreach ($parts as $part) {
635
+                foreach ($part->parameters as $parameter) {
636
+                    if ($parameter->attribute == "charset") {
637 637
                         $encoding = $parameter->value;
638 638
 
639 639
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                     return EncodingAliases::get($parameter->value);
911 911
                 }
912 912
             }
913
-        }elseif (is_string($structure) === true){
913
+        }elseif (is_string($structure) === true) {
914 914
             return mb_detect_encoding($structure);
915 915
         }
916 916
 
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
         return null;
961 961
     }
962 962
 
963
-    public function getFolder(){
963
+    public function getFolder() {
964 964
         return $this->client->getFolder($this->folder_path);
965 965
     }
966 966
 
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
      */
977 977
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
978 978
 
979
-        if($create_folder) $this->client->createFolder($mailbox, true);
979
+        if ($create_folder) $this->client->createFolder($mailbox, true);
980 980
 
981 981
         $target_folder = $this->client->getFolder($mailbox);
982 982
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
         $this->client->openFolder($this->folder_path);
985 985
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
986 986
 
987
-        if($status === true){
988
-            if($expunge) $this->client->expunge();
987
+        if ($status === true) {
988
+            if ($expunge) $this->client->expunge();
989 989
             $this->client->openFolder($target_folder->path);
990 990
 
991 991
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
         $this->client->openFolder($this->folder_path);
1006 1006
 
1007 1007
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1008
-        if($expunge) $this->client->expunge();
1008
+        if ($expunge) $this->client->expunge();
1009 1009
 
1010 1010
         return $status;
1011 1011
     }
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
         $this->client->openFolder($this->folder_path);
1022 1022
 
1023 1023
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1024
-        if($expunge) $this->client->expunge();
1024
+        if ($expunge) $this->client->expunge();
1025 1025
 
1026 1026
         return $status;
1027 1027
     }
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
     /**
1152 1152
      * @return object|null
1153 1153
      */
1154
-    public function getStructure(){
1154
+    public function getStructure() {
1155 1155
         return $this->structure;
1156 1156
     }
1157 1157
 
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
     /**
1178 1178
      * @return array
1179 1179
      */
1180
-    public function getAttributes(){
1180
+    public function getAttributes() {
1181 1181
         return $this->attributes;
1182 1182
     }
1183 1183
 
@@ -1185,8 +1185,8 @@  discard block
 block discarded – undo
1185 1185
      * @param $mask
1186 1186
      * @return $this
1187 1187
      */
1188
-    public function setMask($mask){
1189
-        if(class_exists($mask)){
1188
+    public function setMask($mask) {
1189
+        if (class_exists($mask)) {
1190 1190
             $this->mask = $mask;
1191 1191
         }
1192 1192
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     /**
1197 1197
      * @return string
1198 1198
      */
1199
-    public function getMask(){
1199
+    public function getMask() {
1200 1200
         return $this->mask;
1201 1201
     }
1202 1202
 
@@ -1207,9 +1207,9 @@  discard block
 block discarded – undo
1207 1207
      * @return mixed
1208 1208
      * @throws MaskNotFoundException
1209 1209
      */
1210
-    public function mask($mask = null){
1210
+    public function mask($mask = null) {
1211 1211
         $mask = $mask !== null ? $mask : $this->mask;
1212
-        if(class_exists($mask)){
1212
+        if (class_exists($mask)) {
1213 1213
             return new $mask($this);
1214 1214
         }
1215 1215
 
Please login to merge, or discard this patch.