Passed
Push — master ( decd81...881ae2 )
by Malte
03:28
created
src/Message.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = 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
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
      * @throws MethodNotFoundException
242 242
      */
243 243
     public function __call($method, $arguments) {
244
-        if(strtolower(substr($method, 0, 3)) === 'get') {
244
+        if (strtolower(substr($method, 0, 3)) === 'get') {
245 245
             $name = Str::snake(substr($method, 3));
246 246
             return $this->get($name);
247 247
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
248 248
             $name = Str::snake(substr($method, 3));
249 249
 
250
-            if(in_array($name, array_keys($this->attributes))) {
250
+            if (in_array($name, array_keys($this->attributes))) {
251 251
                 $this->attributes[$name] = array_pop($arguments);
252 252
 
253 253
                 return $this->attributes[$name];
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      * @return mixed|null
289 289
      */
290 290
     public function get($name) {
291
-        if(isset($this->attributes[$name])) {
291
+        if (isset($this->attributes[$name])) {
292 292
             return $this->attributes[$name];
293 293
         }
294 294
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
         $flags = $this->client->getConnection()->flags([$this->msgn]);
371 371
 
372 372
         if (isset($flags[$this->msgn])) {
373
-            foreach($flags[$this->msgn] as $flag) {
374
-                if (strpos($flag, "\\") === 0){
373
+            foreach ($flags[$this->msgn] as $flag) {
374
+                if (strpos($flag, "\\") === 0) {
375 375
                     $flag = substr($flag, 1);
376 376
                 }
377 377
                 $flag_key = strtolower($flag);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 
441 441
         if ($part->isAttachment()) {
442 442
             $this->fetchAttachment($part);
443
-        }else{
443
+        }else {
444 444
             $encoding = $this->getEncoding($part);
445 445
 
446 446
             $content = $this->decodeString($part->content, $part->encoding);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         if ($oAttachment->getName() !== null) {
479 479
             if ($oAttachment->getId() !== null) {
480 480
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
481
-            } else {
481
+            }else {
482 482
                 $this->attachments->push($oAttachment);
483 483
             }
484 484
         }
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 
596 596
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
597 597
             return @iconv($from, $to.'//IGNORE', $str);
598
-        } else {
598
+        }else {
599 599
             if (!$from) {
600 600
                 return mb_convert_encoding($str, $to);
601 601
             }
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
                     return EncodingAliases::get($parameter->value);
617 617
                 }
618 618
             }
619
-        }elseif (property_exists($structure, 'charset')){
619
+        }elseif (property_exists($structure, 'charset')) {
620 620
             return EncodingAliases::get($structure->charset);
621
-        }elseif (is_string($structure) === true){
621
+        }elseif (is_string($structure) === true) {
622 622
             return mb_detect_encoding($structure);
623 623
         }
624 624
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @throws Exceptions\ConnectionFailedException
633 633
      * @throws Exceptions\FolderFetchingException
634 634
      */
635
-    public function getFolder(){
635
+    public function getFolder() {
636 636
         return $this->client->getFolder($this->folder_path);
637 637
     }
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
      * @throws Exceptions\FolderFetchingException
648 648
      * @throws Exceptions\GetMessagesFailedException
649 649
      */
650
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
650
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
651 651
         $thread = $thread ? $thread : MessageCollection::make([]);
652
-        $folder = $folder ? $folder :  $this->getFolder();
652
+        $folder = $folder ? $folder : $this->getFolder();
653 653
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
654 654
 
655 655
         /** @var Message $message */
656
-        foreach($thread as $message) {
656
+        foreach ($thread as $message) {
657 657
             if ($message->message_id == $this->message_id) {
658 658
                 return $thread;
659 659
             }
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         });
675 675
 
676 676
         if (is_array($this->in_reply_to)) {
677
-            foreach($this->in_reply_to as $in_reply_to) {
677
+            foreach ($this->in_reply_to as $in_reply_to) {
678 678
                 $folder->query()->messageId($in_reply_to)
679 679
                     ->setFetchBody($this->getFetchBodyOption())
680 680
                     ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 
720 720
             $this->client->openFolder($this->folder_path);
721 721
             if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) {
722
-                if($expunge) $this->client->expunge();
722
+                if ($expunge) $this->client->expunge();
723 723
 
724 724
                 $this->client->openFolder($folder->path);
725 725
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
             $this->client->openFolder($this->folder_path);
763 763
             if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) {
764
-                if($expunge) $this->client->expunge();
764
+                if ($expunge) $this->client->expunge();
765 765
 
766 766
                 $this->client->openFolder($folder->path);
767 767
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
      */
789 789
     public function delete($expunge = true) {
790 790
         $status = $this->setFlag("Deleted");
791
-        if($expunge) $this->client->expunge();
791
+        if ($expunge) $this->client->expunge();
792 792
 
793 793
         $event = $this->getEvent("message", "deleted");
794 794
         $event::dispatch($this);
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
      */
808 808
     public function restore($expunge = true) {
809 809
         $status = $this->unsetFlag("Deleted");
810
-        if($expunge) $this->client->expunge();
810
+        if ($expunge) $this->client->expunge();
811 811
 
812 812
         $event = $this->getEvent("message", "restored");
813 813
         $event::dispatch($this);
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
      *
961 961
      * @return object|null
962 962
      */
963
-    public function getStructure(){
963
+    public function getStructure() {
964 964
         return $this->structure;
965 965
     }
966 966
 
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
      *
987 987
      * @return array
988 988
      */
989
-    public function getAttributes(){
989
+    public function getAttributes() {
990 990
         return array_merge($this->attributes, $this->header->getAttributes());
991 991
     }
992 992
 
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
      *
997 997
      * @return $this
998 998
      */
999
-    public function setMask($mask){
1000
-        if(class_exists($mask)){
999
+    public function setMask($mask) {
1000
+        if (class_exists($mask)) {
1001 1001
             $this->mask = $mask;
1002 1002
         }
1003 1003
 
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
      *
1010 1010
      * @return string
1011 1011
      */
1012
-    public function getMask(){
1012
+    public function getMask() {
1013 1013
         return $this->mask;
1014 1014
     }
1015 1015
 
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
      * @return mixed
1021 1021
      * @throws MaskNotFoundException
1022 1022
      */
1023
-    public function mask($mask = null){
1023
+    public function mask($mask = null) {
1024 1024
         $mask = $mask !== null ? $mask : $this->mask;
1025
-        if(class_exists($mask)){
1025
+        if (class_exists($mask)) {
1026 1026
             return new $mask($this);
1027 1027
         }
1028 1028
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -8 removed lines patch added patch discarded remove patch
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if(strtolower(substr($method, 0, 3)) === 'get') {
245 245
             $name = Str::snake(substr($method, 3));
246 246
             return $this->get($name);
247
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
247
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
248 248
             $name = Str::snake(substr($method, 3));
249 249
 
250 250
             if(in_array($name, array_keys($this->attributes))) {
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 
441 441
         if ($part->isAttachment()) {
442 442
             $this->fetchAttachment($part);
443
-        }else{
443
+        } else{
444 444
             $encoding = $this->getEncoding($part);
445 445
 
446 446
             $content = $this->decodeString($part->content, $part->encoding);
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
                     return EncodingAliases::get($parameter->value);
617 617
                 }
618 618
             }
619
-        }elseif (property_exists($structure, 'charset')){
619
+        } elseif (property_exists($structure, 'charset')){
620 620
             return EncodingAliases::get($structure->charset);
621
-        }elseif (is_string($structure) === true){
621
+        } elseif (is_string($structure) === true){
622 622
             return mb_detect_encoding($structure);
623 623
         }
624 624
 
@@ -719,7 +719,9 @@  discard block
 block discarded – undo
719 719
 
720 720
             $this->client->openFolder($this->folder_path);
721 721
             if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) {
722
-                if($expunge) $this->client->expunge();
722
+                if($expunge) {
723
+                    $this->client->expunge();
724
+                }
723 725
 
724 726
                 $this->client->openFolder($folder->path);
725 727
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -761,7 +763,9 @@  discard block
 block discarded – undo
761 763
 
762 764
             $this->client->openFolder($this->folder_path);
763 765
             if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) {
764
-                if($expunge) $this->client->expunge();
766
+                if($expunge) {
767
+                    $this->client->expunge();
768
+                }
765 769
 
766 770
                 $this->client->openFolder($folder->path);
767 771
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -788,7 +792,9 @@  discard block
 block discarded – undo
788 792
      */
789 793
     public function delete($expunge = true) {
790 794
         $status = $this->setFlag("Deleted");
791
-        if($expunge) $this->client->expunge();
795
+        if($expunge) {
796
+            $this->client->expunge();
797
+        }
792 798
 
793 799
         $event = $this->getEvent("message", "deleted");
794 800
         $event::dispatch($this);
@@ -807,7 +813,9 @@  discard block
 block discarded – undo
807 813
      */
808 814
     public function restore($expunge = true) {
809 815
         $status = $this->unsetFlag("Deleted");
810
-        if($expunge) $this->client->expunge();
816
+        if($expunge) {
817
+            $this->client->expunge();
818
+        }
811 819
 
812 820
         $event = $this->getEvent("message", "restored");
813 821
         $event::dispatch($this);
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @throws InvalidMessageDateException
161 161
      */
162
-    protected function parse(){
162
+    protected function parse() {
163 163
         if ($this->header === null) {
164 164
             $body = $this->findHeaders();
165
-        }else{
165
+        }else {
166 166
             $body = $this->raw;
167 167
         }
168 168
 
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
         $this->name = $this->header->get("name");
175 175
         $this->filename = $this->header->get("filename");
176 176
 
177
-        if(!empty($this->header->get("id"))) {
177
+        if (!empty($this->header->get("id"))) {
178 178
             $this->id = $this->header->get("id");
179
-        } else if(!empty($this->header->get("x-attachment-id"))){
179
+        }else if (!empty($this->header->get("x-attachment-id"))) {
180 180
             $this->id = $this->header->get("x-attachment-id");
181
-        } else if(!empty($this->header->get("content-id"))){
181
+        }else if (!empty($this->header->get("content-id"))) {
182 182
             $this->id = strtr($this->header->get("content-id"), [
183 183
                 '<' => '',
184 184
                 '>' => ''
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $content_types = $this->header->get("content-type");
189
-        if(!empty($content_types)){
189
+        if (!empty($content_types)) {
190 190
             $this->subtype = $this->parseSubtype($content_types);
191 191
             $content_type = $content_types;
192 192
             if (is_array($content_types)) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return string
208 208
      * @throws InvalidMessageDateException
209 209
      */
210
-    private function findHeaders(){
210
+    private function findHeaders() {
211 211
         $body = $this->raw;
212 212
         while (($pos = strpos($body, "\r\n")) > 0) {
213 213
             $body = substr($body, $pos + 2);
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string
228 228
      */
229
-    private function parseSubtype($content_type){
229
+    private function parseSubtype($content_type) {
230 230
         if (is_array($content_type)) {
231
-            foreach ($content_type as $part){
232
-                if ((strpos($part, "/")) !== false){
231
+            foreach ($content_type as $part) {
232
+                if ((strpos($part, "/")) !== false) {
233 233
                     return $this->parseSubtype($part);
234 234
                 }
235 235
             }
236 236
             return null;
237 237
         }
238
-        if (($pos = strpos($content_type, "/")) !== false){
238
+        if (($pos = strpos($content_type, "/")) !== false) {
239 239
             return substr($content_type, $pos + 1);
240 240
         }
241 241
         return null;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
     /**
245 245
      * Try to parse the disposition if any is present
246 246
      */
247
-    private function parseDisposition(){
247
+    private function parseDisposition() {
248 248
         $content_disposition = $this->header->get("content-disposition");
249
-        if($content_disposition !== null) {
249
+        if ($content_disposition !== null) {
250 250
             $this->ifdisposition = true;
251 251
             $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition;
252 252
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     /**
256 256
      * Try to parse the description if any is present
257 257
      */
258
-    private function parseDescription(){
258
+    private function parseDescription() {
259 259
         $content_description = $this->header->get("content-description");
260
-        if($content_description !== null) {
260
+        if ($content_description !== null) {
261 261
             $this->ifdescription = true;
262 262
             $this->description = $content_description;
263 263
         }
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Try to parse the encoding if any is present
268 268
      */
269
-    private function parseEncoding(){
269
+    private function parseEncoding() {
270 270
         $encoding = $this->header->get("content-transfer-encoding");
271
-        if($encoding !== null) {
271
+        if ($encoding !== null) {
272 272
             switch (strtolower($encoding)) {
273 273
                 case "quoted-printable":
274 274
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
302
-        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])) ) ) {
301
+    public function isAttachment() {
302
+        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])))) {
303 303
             if (($this->subtype == null || in_array((strtolower($this->subtype)), ["plain", "csv", "html"])) && $this->filename == null && $this->name == null) {
304 304
                 return false;
305 305
             }
Please login to merge, or discard this patch.