Passed
Push — master ( 7eda73...e84ff4 )
by Malte
04:28
created
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
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                         $date .= 'C';
508 508
                         break;
509 509
                 }
510
-                try{
510
+                try {
511 511
                     $parsed_date = Carbon::parse($date);
512 512
                 } catch (\Exception $_e) {
513 513
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         $this->client->openFolder($this->folder_path);
531 531
         $flags = imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
532 532
         if (is_array($flags) && isset($flags[0])) {
533
-            foreach($this->available_flags as $flag) {
533
+            foreach ($this->available_flags as $flag) {
534 534
                 $this->parseFlag($flags, $flag);
535 535
             }
536 536
         }
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
         $this->client->openFolder($this->folder_path);
628 628
         $this->structure = imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
629 629
 
630
-        if(property_exists($this->structure, 'parts')){
630
+        if (property_exists($this->structure, 'parts')) {
631 631
             $parts = $this->structure->parts;
632 632
 
633
-            foreach ($parts as $part)  {
634
-                foreach ($part->parameters as $parameter)  {
635
-                    if($parameter->attribute == "charset")  {
633
+            foreach ($parts as $part) {
634
+                foreach ($part->parameters as $parameter) {
635
+                    if ($parameter->attribute == "charset") {
636 636
                         $encoding = $parameter->value;
637 637
 
638 638
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
                     return EncodingAliases::get($parameter->value);
910 910
                 }
911 911
             }
912
-        }elseif (is_string($structure) === true){
912
+        }elseif (is_string($structure) === true) {
913 913
             return mb_detect_encoding($structure);
914 914
         }
915 915
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         return null;
960 960
     }
961 961
 
962
-    public function getFolder(){
962
+    public function getFolder() {
963 963
         return $this->client->getFolder($this->folder_path);
964 964
     }
965 965
 
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
      */
976 976
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
977 977
 
978
-        if($create_folder) $this->client->createFolder($mailbox, true);
978
+        if ($create_folder) $this->client->createFolder($mailbox, true);
979 979
 
980 980
         $target_folder = $this->client->getFolder($mailbox);
981 981
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -983,8 +983,8 @@  discard block
 block discarded – undo
983 983
         $this->client->openFolder($this->folder_path);
984 984
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
985 985
 
986
-        if($status === true){
987
-            if($expunge) $this->client->expunge();
986
+        if ($status === true) {
987
+            if ($expunge) $this->client->expunge();
988 988
             $this->client->openFolder($target_folder->path);
989 989
 
990 990
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
         $this->client->openFolder($this->folder_path);
1005 1005
 
1006 1006
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1007
-        if($expunge) $this->client->expunge();
1007
+        if ($expunge) $this->client->expunge();
1008 1008
 
1009 1009
         return $status;
1010 1010
     }
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
         $this->client->openFolder($this->folder_path);
1021 1021
 
1022 1022
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1023
-        if($expunge) $this->client->expunge();
1023
+        if ($expunge) $this->client->expunge();
1024 1024
 
1025 1025
         return $status;
1026 1026
     }
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
     /**
1151 1151
      * @return object|null
1152 1152
      */
1153
-    public function getStructure(){
1153
+    public function getStructure() {
1154 1154
         return $this->structure;
1155 1155
     }
1156 1156
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     /**
1177 1177
      * @return array
1178 1178
      */
1179
-    public function getAttributes(){
1179
+    public function getAttributes() {
1180 1180
         return $this->attributes;
1181 1181
     }
1182 1182
 
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
      * @param $mask
1185 1185
      * @return $this
1186 1186
      */
1187
-    public function setMask($mask){
1188
-        if(class_exists($mask)){
1187
+    public function setMask($mask) {
1188
+        if (class_exists($mask)) {
1189 1189
             $this->mask = $mask;
1190 1190
         }
1191 1191
 
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
     /**
1196 1196
      * @return string
1197 1197
      */
1198
-    public function getMask(){
1198
+    public function getMask() {
1199 1199
         return $this->mask;
1200 1200
     }
1201 1201
 
@@ -1206,9 +1206,9 @@  discard block
 block discarded – undo
1206 1206
      * @return mixed
1207 1207
      * @throws MaskNotFoundException
1208 1208
      */
1209
-    public function mask($mask = null){
1209
+    public function mask($mask = null) {
1210 1210
         $mask = $mask !== null ? $mask : $this->mask;
1211
-        if(class_exists($mask)){
1211
+        if (class_exists($mask)) {
1212 1212
             return new $mask($this);
1213 1213
         }
1214 1214
 
Please login to merge, or discard this patch.
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.