Passed
Pull Request — master (#219)
by
unknown
04:23
created
examples/replace_images_with_url.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 /** @var \Webklex\IMAP\Message $message */
21 21
 $message = $folder->query()->limit(1)->get()->first();
22 22
 
23
-$html = $message->getHTMLBody(function($body, $oAttachment){
23
+$html = $message->getHTMLBody(function($body, $oAttachment) {
24 24
     /** @var \Webklex\IMAP\Attachment $oAttachment */
25 25
     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
26 26
         $oMessage = $oAttachment->getMessage();
Please login to merge, or discard this patch.
src/IMAP/Message.php 2 patches
Spacing   +34 added lines, -34 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
 
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
      */
972 972
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
973 973
 
974
-        if($create_folder) $this->client->createFolder($mailbox, true);
974
+        if ($create_folder) $this->client->createFolder($mailbox, true);
975 975
 
976 976
         $target_folder = $this->client->getFolder($mailbox);
977 977
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
         $this->client->openFolder($this->folder_path);
980 980
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
981 981
 
982
-        if($status === true){
983
-            if($expunge) $this->client->expunge();
982
+        if ($status === true) {
983
+            if ($expunge) $this->client->expunge();
984 984
             $this->client->openFolder($target_folder->path);
985 985
 
986 986
             return $target_folder->getMessage($target_status->uidnext, $this->msglist, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
         $this->client->openFolder($this->folder_path);
1001 1001
 
1002 1002
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1003
-        if($expunge) $this->client->expunge();
1003
+        if ($expunge) $this->client->expunge();
1004 1004
 
1005 1005
         return $status;
1006 1006
     }
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
         $this->client->openFolder($this->folder_path);
1017 1017
 
1018 1018
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1019
-        if($expunge) $this->client->expunge();
1019
+        if ($expunge) $this->client->expunge();
1020 1020
 
1021 1021
         return $status;
1022 1022
     }
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
     /**
1147 1147
      * @return object|null
1148 1148
      */
1149
-    public function getStructure(){
1149
+    public function getStructure() {
1150 1150
         return $this->structure;
1151 1151
     }
1152 1152
 
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
     /**
1173 1173
      * @return array
1174 1174
      */
1175
-    public function getAttributes(){
1175
+    public function getAttributes() {
1176 1176
         return $this->attributes;
1177 1177
     }
1178 1178
 
@@ -1180,8 +1180,8 @@  discard block
 block discarded – undo
1180 1180
      * @param $mask
1181 1181
      * @return $this
1182 1182
      */
1183
-    public function setMask($mask){
1184
-        if(class_exists($mask)){
1183
+    public function setMask($mask) {
1184
+        if (class_exists($mask)) {
1185 1185
             $this->mask = $mask;
1186 1186
         }
1187 1187
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
     /**
1192 1192
      * @return string
1193 1193
      */
1194
-    public function getMask(){
1194
+    public function getMask() {
1195 1195
         return $this->mask;
1196 1196
     }
1197 1197
 
@@ -1202,9 +1202,9 @@  discard block
 block discarded – undo
1202 1202
      * @return mixed
1203 1203
      * @throws MaskNotFoundException
1204 1204
      */
1205
-    public function mask($mask = null){
1205
+    public function mask($mask = null) {
1206 1206
         $mask = $mask !== null ? $mask : $this->mask;
1207
-        if(class_exists($mask)){
1207
+        if (class_exists($mask)) {
1208 1208
             return new $mask($this);
1209 1209
         }
1210 1210
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -9 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
                 return $this->attributes[$name];
246 246
             }
247 247
 
248
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
248
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
249 249
             $name = snake_case(substr($method, 3));
250 250
 
251 251
             if(in_array($name, array_keys($this->attributes))) {
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
                 /** @var Attachment $oAttachment */
366 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
                     }
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         if (property_exists($header, 'subject')) {
399 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
         }
@@ -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
 
@@ -971,7 +971,9 @@  discard block
 block discarded – undo
971 971
      */
972 972
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
973 973
 
974
-        if($create_folder) $this->client->createFolder($mailbox, true);
974
+        if($create_folder) {
975
+            $this->client->createFolder($mailbox, true);
976
+        }
975 977
 
976 978
         $target_folder = $this->client->getFolder($mailbox);
977 979
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -980,7 +982,9 @@  discard block
 block discarded – undo
980 982
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
981 983
 
982 984
         if($status === true){
983
-            if($expunge) $this->client->expunge();
985
+            if($expunge) {
986
+                $this->client->expunge();
987
+            }
984 988
             $this->client->openFolder($target_folder->path);
985 989
 
986 990
             return $target_folder->getMessage($target_status->uidnext, $this->msglist, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1000,7 +1004,9 @@  discard block
 block discarded – undo
1000 1004
         $this->client->openFolder($this->folder_path);
1001 1005
 
1002 1006
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1003
-        if($expunge) $this->client->expunge();
1007
+        if($expunge) {
1008
+            $this->client->expunge();
1009
+        }
1004 1010
 
1005 1011
         return $status;
1006 1012
     }
@@ -1016,7 +1022,9 @@  discard block
 block discarded – undo
1016 1022
         $this->client->openFolder($this->folder_path);
1017 1023
 
1018 1024
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1019
-        if($expunge) $this->client->expunge();
1025
+        if($expunge) {
1026
+            $this->client->expunge();
1027
+        }
1020 1028
 
1021 1029
         return $status;
1022 1030
     }
Please login to merge, or discard this patch.