Passed
Push — master ( b99c9f...d56d2c )
by Malte
04:37
created
src/IMAP/Attachment.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         $this->part_number = ($part_number) ? $part_number : $this->part_number;
98 98
 
99 99
         $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask();
100
-        if($default_mask != null) {
100
+        if ($default_mask != null) {
101 101
             $this->mask = $default_mask;
102 102
         }
103 103
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
      * @throws MethodNotFoundException
115 115
      */
116 116
     public function __call($method, $arguments) {
117
-        if(strtolower(substr($method, 0, 3)) === 'get') {
117
+        if (strtolower(substr($method, 0, 3)) === 'get') {
118 118
             $name = Str::snake(substr($method, 3));
119 119
 
120
-            if(isset($this->attributes[$name])) {
120
+            if (isset($this->attributes[$name])) {
121 121
                 return $this->attributes[$name];
122 122
             }
123 123
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @return mixed|null
152 152
      */
153 153
     public function __get($name) {
154
-        if(isset($this->attributes[$name])) {
154
+        if (isset($this->attributes[$name])) {
155 155
             return $this->attributes[$name];
156 156
         }
157 157
 
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
      * @param $name
264 264
      */
265 265
     public function setName($name) {
266
-        if($this->config['decoder']['attachment']['name'] === 'utf-8') {
266
+        if ($this->config['decoder']['attachment']['name'] === 'utf-8') {
267 267
             $this->name = \imap_utf8($name);
268
-        }elseif($this->config['decoder']['attachment']['name'] === 'iconv') {
268
+        }elseif ($this->config['decoder']['attachment']['name'] === 'iconv') {
269 269
             $this->name = iconv_mime_decode($name);
270
-        }else{
270
+        } else {
271 271
             $this->name = mb_decode_mimeheader($name);
272 272
         }
273 273
     }
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
     /**
288 288
      * @return string|null
289 289
      */
290
-    public function getMimeType(){
290
+    public function getMimeType() {
291 291
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
292 292
     }
293 293
 
294 294
     /**
295 295
      * @return string|null
296 296
      */
297
-    public function getExtension(){
297
+    public function getExtension() {
298 298
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
299
-        if (class_exists($deprecated_guesser) !== false){
299
+        if (class_exists($deprecated_guesser) !== false) {
300 300
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
301 301
         }
302 302
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
     /**
308 308
      * @return array
309 309
      */
310
-    public function getAttributes(){
310
+    public function getAttributes() {
311 311
         return $this->attributes;
312 312
     }
313 313
 
314 314
     /**
315 315
      * @return Message
316 316
      */
317
-    public function getMessage(){
317
+    public function getMessage() {
318 318
         return $this->oMessage;
319 319
     }
320 320
 
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
      * @param $mask
323 323
      * @return $this
324 324
      */
325
-    public function setMask($mask){
326
-        if(class_exists($mask)){
325
+    public function setMask($mask) {
326
+        if (class_exists($mask)) {
327 327
             $this->mask = $mask;
328 328
         }
329 329
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     /**
334 334
      * @return string
335 335
      */
336
-    public function getMask(){
336
+    public function getMask() {
337 337
         return $this->mask;
338 338
     }
339 339
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
      * @return mixed
345 345
      * @throws MaskNotFoundException
346 346
      */
347
-    public function mask($mask = null){
347
+    public function mask($mask = null) {
348 348
         $mask = $mask !== null ? $mask : $this->mask;
349
-        if(class_exists($mask)){
349
+        if (class_exists($mask)) {
350 350
             return new $mask($this);
351 351
         }
352 352
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             }
123 123
 
124 124
             return null;
125
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
125
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
126 126
             $name = Str::snake(substr($method, 3));
127 127
 
128 128
             $this->attributes[$name] = array_pop($arguments);
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
     public function setName($name) {
266 266
         if($this->config['decoder']['attachment']['name'] === 'utf-8') {
267 267
             $this->name = \imap_utf8($name);
268
-        }elseif($this->config['decoder']['attachment']['name'] === 'iconv') {
268
+        } elseif($this->config['decoder']['attachment']['name'] === 'iconv') {
269 269
             $this->name = iconv_mime_decode($name);
270
-        }else{
270
+        } else{
271 271
             $this->name = mb_decode_mimeheader($name);
272 272
         }
273 273
     }
Please login to merge, or discard this patch.
src/IMAP/Message.php 2 patches
Braces   +18 added lines, -10 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                 return $this->attributes[$name];
250 250
             }
251 251
 
252
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
252
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
253 253
             $name = Str::snake(substr($method, 3));
254 254
 
255 255
             if(in_array($name, array_keys($this->attributes))) {
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
                 /** @var Attachment $oAttachment */
370 370
                 if(is_callable($replaceImages)) {
371 371
                     $body = $replaceImages($body, $oAttachment);
372
-                }elseif(is_string($replaceImages)) {
372
+                } elseif(is_string($replaceImages)) {
373 373
                     call_user_func($replaceImages, [$body, $oAttachment]);
374
-                }else{
374
+                } else{
375 375
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
376 376
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
377 377
                     }
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
         if (property_exists($header, 'subject')) {
403 403
             if($this->config['decoder']['message']['subject'] === 'utf-8') {
404 404
                 $this->subject = \imap_utf8($header->subject);
405
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
405
+            } elseif($this->config['decoder']['message']['subject'] === 'iconv') {
406 406
                 $this->subject = iconv_mime_decode($header->subject);
407
-            }else{
407
+            } else{
408 408
                 $this->subject = mb_decode_mimeheader($header->subject);
409 409
             }
410 410
         }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                     return EncodingAliases::get($parameter->value);
923 923
                 }
924 924
             }
925
-        }elseif (is_string($structure) === true){
925
+        } elseif (is_string($structure) === true){
926 926
             return mb_detect_encoding($structure);
927 927
         }
928 928
 
@@ -988,7 +988,9 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
990 990
 
991
-        if($create_folder) $this->client->createFolder($mailbox, true);
991
+        if($create_folder) {
992
+            $this->client->createFolder($mailbox, true);
993
+        }
992 994
 
993 995
         $target_folder = $this->client->getFolder($mailbox);
994 996
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -997,7 +999,9 @@  discard block
 block discarded – undo
997 999
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
998 1000
 
999 1001
         if($status === true){
1000
-            if($expunge) $this->client->expunge();
1002
+            if($expunge) {
1003
+                $this->client->expunge();
1004
+            }
1001 1005
             $this->client->openFolder($target_folder->path);
1002 1006
 
1003 1007
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1019,7 +1023,9 @@  discard block
 block discarded – undo
1019 1023
         $this->client->openFolder($this->folder_path);
1020 1024
 
1021 1025
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1022
-        if($expunge) $this->client->expunge();
1026
+        if($expunge) {
1027
+            $this->client->expunge();
1028
+        }
1023 1029
         MessageDeletedEvent::dispatch($this);
1024 1030
 
1025 1031
         return $status;
@@ -1036,7 +1042,9 @@  discard block
 block discarded – undo
1036 1042
         $this->client->openFolder($this->folder_path);
1037 1043
 
1038 1044
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1039
-        if($expunge) $this->client->expunge();
1045
+        if($expunge) {
1046
+            $this->client->expunge();
1047
+        }
1040 1048
         MessageRestoredEvent::dispatch($this);
1041 1049
 
1042 1050
         return $status;
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
201 201
 
202 202
         $default_mask = $client->getDefaultMessageMask();
203
-        if($default_mask != null) {
203
+        if ($default_mask != null) {
204 204
             $this->mask = $default_mask;
205 205
         }
206 206
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $this->msglist = $msglist;
220 220
         $this->client = $client;
221 221
 
222
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
222
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
223 223
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? \imap_msgno($this->client->getConnection(), $uid) : $uid;
224 224
 
225 225
         $this->parseHeader();
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
      * @throws MethodNotFoundException
243 243
      */
244 244
     public function __call($method, $arguments) {
245
-        if(strtolower(substr($method, 0, 3)) === 'get') {
245
+        if (strtolower(substr($method, 0, 3)) === 'get') {
246 246
             $name = Str::snake(substr($method, 3));
247 247
 
248
-            if(in_array($name, array_keys($this->attributes))) {
248
+            if (in_array($name, array_keys($this->attributes))) {
249 249
                 return $this->attributes[$name];
250 250
             }
251 251
 
252 252
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
253 253
             $name = Str::snake(substr($method, 3));
254 254
 
255
-            if(in_array($name, array_keys($this->attributes))) {
255
+            if (in_array($name, array_keys($this->attributes))) {
256 256
                 $this->attributes[$name] = array_pop($arguments);
257 257
 
258 258
                 return $this->attributes[$name];
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      * @return mixed|null
282 282
      */
283 283
     public function __get($name) {
284
-        if(isset($this->attributes[$name])) {
284
+        if (isset($this->attributes[$name])) {
285 285
             return $this->attributes[$name];
286 286
         }
287 287
 
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
         if ($replaceImages !== false) {
368 368
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
369 369
                 /** @var Attachment $oAttachment */
370
-                if(is_callable($replaceImages)) {
370
+                if (is_callable($replaceImages)) {
371 371
                     $body = $replaceImages($body, $oAttachment);
372
-                }elseif(is_string($replaceImages)) {
372
+                }elseif (is_string($replaceImages)) {
373 373
                     call_user_func($replaceImages, [$body, $oAttachment]);
374
-                }else{
374
+                } else {
375 375
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
376 376
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
377 377
                     }
@@ -400,16 +400,16 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         if (property_exists($header, 'subject')) {
403
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
403
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
404 404
                 $this->subject = \imap_utf8($header->subject);
405
-            }elseif($this->config['decoder']['message']['subject'] === 'iconv') {
405
+            }elseif ($this->config['decoder']['message']['subject'] === 'iconv') {
406 406
                 $this->subject = iconv_mime_decode($header->subject);
407
-            }else{
407
+            } else {
408 408
                 $this->subject = mb_decode_mimeheader($header->subject);
409 409
             }
410 410
         }
411 411
 
412
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
412
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
413 413
             $this->extractHeaderAddressPart($header, $part);
414 414
         }
415 415
 
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
      * @return int|null
440 440
      */
441 441
     private function extractPriority($header) {
442
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
442
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
443 443
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
444
-            switch($priority){
444
+            switch ($priority) {
445 445
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
446 446
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
447 447
                     break;
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
         if (property_exists($header, 'date')) {
493 493
             $date = $header->date;
494 494
 
495
-            if(preg_match('/\+0580/', $date)) {
495
+            if (preg_match('/\+0580/', $date)) {
496 496
                 $date = str_replace('+0580', '+0530', $date);
497 497
             }
498 498
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                         $date = trim(array_pop($array));
516 516
                         break;
517 517
                 }
518
-                try{
518
+                try {
519 519
                     $parsed_date = Carbon::parse($date);
520 520
                 } catch (\Exception $_e) {
521 521
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
         $this->client->openFolder($this->folder_path);
539 539
         $flags = \imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
540 540
         if (is_array($flags) && isset($flags[0])) {
541
-            foreach($this->available_flags as $flag) {
541
+            foreach ($this->available_flags as $flag) {
542 542
                 $this->parseFlag($flags, $flag);
543 543
             }
544 544
         }
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
             } else {
611 611
                 $personalParts = \imap_mime_header_decode($address->personal);
612 612
 
613
-                if(is_array($personalParts)) {
613
+                if (is_array($personalParts)) {
614 614
                     $address->personal = '';
615 615
                     foreach ($personalParts as $p) {
616 616
                         $encoding = (property_exists($p, 'charset')) ? $p->charset : $this->getEncoding($p->text);
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
         $this->client->openFolder($this->folder_path);
639 639
         $this->structure = \imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
640 640
 
641
-        if(property_exists($this->structure, 'parts')){
641
+        if (property_exists($this->structure, 'parts')) {
642 642
             $parts = $this->structure->parts;
643 643
 
644
-            foreach ($parts as $part)  {
645
-                foreach ($part->parameters as $parameter)  {
646
-                    if($parameter->attribute == "charset")  {
644
+            foreach ($parts as $part) {
645
+                foreach ($part->parameters as $parameter) {
646
+                    if ($parameter->attribute == "charset") {
647 647
                         $encoding = $parameter->value;
648 648
 
649 649
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
                     return EncodingAliases::get($parameter->value);
923 923
                 }
924 924
             }
925
-        }elseif (is_string($structure) === true){
925
+        }elseif (is_string($structure) === true) {
926 926
             return mb_detect_encoding($structure);
927 927
         }
928 928
 
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
         return null;
973 973
     }
974 974
 
975
-    public function getFolder(){
975
+    public function getFolder() {
976 976
         return $this->client->getFolder($this->folder_path);
977 977
     }
978 978
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
      */
989 989
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
990 990
 
991
-        if($create_folder) $this->client->createFolder($mailbox, true);
991
+        if ($create_folder) $this->client->createFolder($mailbox, true);
992 992
 
993 993
         $target_folder = $this->client->getFolder($mailbox);
994 994
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
         $this->client->openFolder($this->folder_path);
997 997
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
998 998
 
999
-        if($status === true){
1000
-            if($expunge) $this->client->expunge();
999
+        if ($status === true) {
1000
+            if ($expunge) $this->client->expunge();
1001 1001
             $this->client->openFolder($target_folder->path);
1002 1002
 
1003 1003
             $message = $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
         $this->client->openFolder($this->folder_path);
1020 1020
 
1021 1021
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1022
-        if($expunge) $this->client->expunge();
1022
+        if ($expunge) $this->client->expunge();
1023 1023
         MessageDeletedEvent::dispatch($this);
1024 1024
 
1025 1025
         return $status;
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
         $this->client->openFolder($this->folder_path);
1037 1037
 
1038 1038
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1039
-        if($expunge) $this->client->expunge();
1039
+        if ($expunge) $this->client->expunge();
1040 1040
         MessageRestoredEvent::dispatch($this);
1041 1041
 
1042 1042
         return $status;
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
      * @return string
1114 1114
      * @throws Exceptions\ConnectionFailedException
1115 1115
      */
1116
-    public function getToken(){
1116
+    public function getToken() {
1117 1117
         return base64_encode(implode('-', [$this->message_id, $this->subject, strlen($this->getRawBody())]));
1118 1118
     }
1119 1119
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     /**
1177 1177
      * @return object|null
1178 1178
      */
1179
-    public function getStructure(){
1179
+    public function getStructure() {
1180 1180
         return $this->structure;
1181 1181
     }
1182 1182
 
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
     /**
1203 1203
      * @return array
1204 1204
      */
1205
-    public function getAttributes(){
1205
+    public function getAttributes() {
1206 1206
         return $this->attributes;
1207 1207
     }
1208 1208
 
@@ -1210,8 +1210,8 @@  discard block
 block discarded – undo
1210 1210
      * @param $mask
1211 1211
      * @return $this
1212 1212
      */
1213
-    public function setMask($mask){
1214
-        if(class_exists($mask)){
1213
+    public function setMask($mask) {
1214
+        if (class_exists($mask)) {
1215 1215
             $this->mask = $mask;
1216 1216
         }
1217 1217
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
     /**
1222 1222
      * @return string
1223 1223
      */
1224
-    public function getMask(){
1224
+    public function getMask() {
1225 1225
         return $this->mask;
1226 1226
     }
1227 1227
 
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
      * @return mixed
1233 1233
      * @throws MaskNotFoundException
1234 1234
      */
1235
-    public function mask($mask = null){
1235
+    public function mask($mask = null) {
1236 1236
         $mask = $mask !== null ? $mask : $this->mask;
1237
-        if(class_exists($mask)){
1237
+        if (class_exists($mask)) {
1238 1238
             return new $mask($this);
1239 1239
         }
1240 1240
 
Please login to merge, or discard this patch.
examples/custom_message_mask.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
      * New custom method which can be called through a mask
17 17
      * @return string
18 18
      */
19
-    public function my_token(){
19
+    public function my_token() {
20 20
         return implode('-', [$this->message_id, $this->uid, $this->message_no]);
21 21
     }
22 22
 
Please login to merge, or discard this patch.