Passed
Push — master ( 1c981f...6990ab )
by Malte
03:43
created
src/IMAP/Client.php 1 patch
Spacing   +35 added lines, -35 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
     }
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
      */
407 407
     public function createFolder($name, $expunge = true) {
408 408
         $this->checkConnection();
409
-        $status = imap_createmailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
410
-        if($expunge) $this->expunge();
409
+        $status = imap_createmailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($name));
410
+        if ($expunge) $this->expunge();
411 411
 
412 412
         return $status;
413 413
     }
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
      */
424 424
     public function renameFolder($old_name, $new_name, $expunge = true) {
425 425
         $this->checkConnection();
426
-        $status = imap_renamemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name));
427
-        if($expunge) $this->expunge();
426
+        $status = imap_renamemailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($old_name), $this->getAddress().imap_utf7_encode($new_name));
427
+        if ($expunge) $this->expunge();
428 428
 
429 429
         return $status;
430 430
     }
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
      */
440 440
     public function deleteFolder($name, $expunge = true) {
441 441
         $this->checkConnection();
442
-        $status = imap_deletemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
443
-        if($expunge) $this->expunge();
442
+        $status = imap_deletemailbox($this->getConnection(), $this->getAddress().imap_utf7_encode($name));
443
+        if ($expunge) $this->expunge();
444 444
 
445 445
         return $status;
446 446
     }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
         if (!$this->validate_cert) {
535 535
             $address .= '/novalidate-cert';
536 536
         }
537
-        if (in_array($this->encryption,['tls','ssl'])) {
537
+        if (in_array($this->encryption, ['tls', 'ssl'])) {
538 538
             $address .= '/'.$this->encryption;
539 539
         }
540 540
 
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
      * @throws InvalidImapTimeoutTypeException
656 656
      */
657 657
     public function setTimeout($type, $timeout) {
658
-        if(0 <= $type && $type <= 4) {
658
+        if (0 <= $type && $type <= 4) {
659 659
             return imap_timeout($type, $timeout);
660 660
         }
661 661
 
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
      * @return mixed
670 670
      * @throws InvalidImapTimeoutTypeException
671 671
      */
672
-    public function getTimeout($type){
673
-        if(0 <= $type && $type <= 4) {
672
+    public function getTimeout($type) {
673
+        if (0 <= $type && $type <= 4) {
674 674
             return imap_timeout($type);
675 675
         }
676 676
 
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
     /**
681 681
      * @return string
682 682
      */
683
-    public function getDefaultMessageMask(){
683
+    public function getDefaultMessageMask() {
684 684
         return $this->default_message_mask;
685 685
     }
686 686
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
      * @throws MaskNotFoundException
692 692
      */
693 693
     public function setDefaultMessageMask($mask) {
694
-        if(class_exists($mask)) {
694
+        if (class_exists($mask)) {
695 695
             $this->default_message_mask = $mask;
696 696
 
697 697
             return $this;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
     /**
704 704
      * @return string
705 705
      */
706
-    public function getDefaultAttachmentMask(){
706
+    public function getDefaultAttachmentMask() {
707 707
         return $this->default_attachment_mask;
708 708
     }
709 709
 
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
      * @throws MaskNotFoundException
715 715
      */
716 716
     public function setDefaultAttachmentMask($mask) {
717
-        if(class_exists($mask)) {
717
+        if (class_exists($mask)) {
718 718
             $this->default_attachment_mask = $mask;
719 719
 
720 720
             return $this;
Please login to merge, or discard this patch.
src/IMAP/Message.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
190 190
 
191 191
         $default_mask = $client->getDefaultMessageMask();
192
-        if($default_mask != null) {
192
+        if ($default_mask != null) {
193 193
             $this->mask = $default_mask;
194 194
         }
195 195
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
         $this->msglist = $msglist;
207 207
         $this->client = $client;
208 208
 
209
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
209
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
210 210
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? imap_msgno($this->client->getConnection(), $uid) : $uid;
211 211
 
212 212
         $this->parseHeader();
@@ -229,17 +229,17 @@  discard block
 block discarded – undo
229 229
      * @throws MethodNotFoundException
230 230
      */
231 231
     public function __call($method, $arguments) {
232
-        if(strtolower(substr($method, 0, 3)) === 'get') {
232
+        if (strtolower(substr($method, 0, 3)) === 'get') {
233 233
             $name = snake_case(substr($method, 3));
234 234
 
235
-            if(isset($this->attributes[$name])) {
235
+            if (isset($this->attributes[$name])) {
236 236
                 return $this->attributes[$name];
237 237
             }
238 238
 
239 239
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
240 240
             $name = snake_case(substr($method, 3));
241 241
 
242
-            if(isset($this->attributes[$name])) {
242
+            if (isset($this->attributes[$name])) {
243 243
                 $this->attributes[$name] = array_pop($arguments);
244 244
 
245 245
                 return $this->attributes[$name];
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      * @return mixed|null
269 269
      */
270 270
     public function __get($name) {
271
-        if(isset($this->attributes[$name])) {
271
+        if (isset($this->attributes[$name])) {
272 272
             return $this->attributes[$name];
273 273
         }
274 274
 
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
         if ($replaceImages !== false) {
353 353
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
354 354
                 /** @var Attachment $oAttachment */
355
-                if(is_callable($replaceImages)) {
355
+                if (is_callable($replaceImages)) {
356 356
                     $body = $replaceImages($body, $oAttachment);
357
-                }elseif(is_string($replaceImages)) {
357
+                }elseif (is_string($replaceImages)) {
358 358
                     call_user_func($replaceImages, [$body, $oAttachment]);
359
-                }else{
359
+                } else {
360 360
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
361 361
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
362 362
                     }
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
         }
385 385
 
386 386
         if (property_exists($header, 'subject')) {
387
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
387
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
388 388
                 $this->subject = imap_utf8($header->subject);
389
-            }else{
389
+            } else {
390 390
                 $this->subject = mb_decode_mimeheader($header->subject);
391 391
             }
392 392
         }
393 393
 
394
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
394
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
395 395
             $this->extractHeaderAddressPart($header, $part);
396 396
         }
397 397
 
@@ -421,9 +421,9 @@  discard block
 block discarded – undo
421 421
      * @return int|null
422 422
      */
423 423
     private function extractPriority($header) {
424
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
424
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
425 425
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
426
-            switch($priority){
426
+            switch ($priority) {
427 427
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
428 428
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
429 429
                     break;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         if (property_exists($header, 'date')) {
475 475
             $date = $header->date;
476 476
 
477
-            if(preg_match('/\+0580/', $date)) {
477
+            if (preg_match('/\+0580/', $date)) {
478 478
                 $date = str_replace('+0580', '+0530', $date);
479 479
             }
480 480
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
                         $date .= 'C';
496 496
                         break;
497 497
                 }
498
-                try{
498
+                try {
499 499
                     $parsed_date = Carbon::parse($date);
500 500
                 } catch (\Exception $_e) {
501 501
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 
518 518
         $flags = imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
519 519
         if (is_array($flags) && isset($flags[0])) {
520
-            foreach($this->available_flags as $flag) {
520
+            foreach ($this->available_flags as $flag) {
521 521
                 $this->parseFlag($flags, $flag);
522 522
             }
523 523
         }
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
     public function parseBody() {
615 615
         $this->structure = imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
616 616
 
617
-        if(property_exists($this->structure, 'parts')){
617
+        if (property_exists($this->structure, 'parts')) {
618 618
             $parts = $this->structure->parts;
619 619
 
620
-            foreach ($parts as $part)  {
621
-                foreach ($part->parameters as $parameter)  {
622
-                    if($parameter->attribute == "charset")  {
620
+            foreach ($parts as $part) {
621
+                foreach ($part->parameters as $parameter) {
622
+                    if ($parameter->attribute == "charset") {
623 623
                         $encoding = $parameter->value;
624 624
 
625 625
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
                     return EncodingAliases::get($parameter->value);
895 895
                 }
896 896
             }
897
-        }elseif (is_string($structure) === true){
897
+        }elseif (is_string($structure) === true) {
898 898
             return mb_detect_encoding($structure);
899 899
         }
900 900
 
@@ -956,14 +956,14 @@  discard block
 block discarded – undo
956 956
      */
957 957
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
958 958
 
959
-        if($create_folder) $this->client->createFolder($mailbox, true);
959
+        if ($create_folder) $this->client->createFolder($mailbox, true);
960 960
 
961 961
         $target_folder = $this->client->getFolder($mailbox);
962 962
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
963 963
 
964 964
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
965
-        if($status === true){
966
-            if($expunge) $this->client->expunge();
965
+        if ($status === true) {
966
+            if ($expunge) $this->client->expunge();
967 967
 
968 968
             return $target_folder->getMessage($target_status->uidnext);
969 969
         }
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
      */
981 981
     public function delete($expunge = true) {
982 982
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
983
-        if($expunge) $this->client->expunge();
983
+        if ($expunge) $this->client->expunge();
984 984
 
985 985
         return $status;
986 986
     }
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
      */
995 995
     public function restore($expunge = true) {
996 996
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
997
-        if($expunge) $this->client->expunge();
997
+        if ($expunge) $this->client->expunge();
998 998
 
999 999
         return $status;
1000 1000
     }
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
     /**
1119 1119
      * @return object|null
1120 1120
      */
1121
-    public function getStructure(){
1121
+    public function getStructure() {
1122 1122
         return $this->structure;
1123 1123
     }
1124 1124
 
@@ -1144,7 +1144,7 @@  discard block
 block discarded – undo
1144 1144
     /**
1145 1145
      * @return array
1146 1146
      */
1147
-    public function getAttributes(){
1147
+    public function getAttributes() {
1148 1148
         return $this->attributes;
1149 1149
     }
1150 1150
 
@@ -1152,8 +1152,8 @@  discard block
 block discarded – undo
1152 1152
      * @param $mask
1153 1153
      * @return $this
1154 1154
      */
1155
-    public function setMask($mask){
1156
-        if(class_exists($mask)){
1155
+    public function setMask($mask) {
1156
+        if (class_exists($mask)) {
1157 1157
             $this->mask = $mask;
1158 1158
         }
1159 1159
 
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
     /**
1164 1164
      * @return string
1165 1165
      */
1166
-    public function getMask(){
1166
+    public function getMask() {
1167 1167
         return $this->mask;
1168 1168
     }
1169 1169
 
@@ -1174,9 +1174,9 @@  discard block
 block discarded – undo
1174 1174
      * @return mixed
1175 1175
      * @throws MaskNotFoundException
1176 1176
      */
1177
-    public function mask($mask = null){
1177
+    public function mask($mask = null) {
1178 1178
         $mask = $mask !== null ? $mask : $this->mask;
1179
-        if(class_exists($mask)){
1179
+        if (class_exists($mask)) {
1180 1180
             return new $mask($this);
1181 1181
         }
1182 1182
 
Please login to merge, or discard this patch.