Passed
Push — master ( 4b6ca8...7b77e0 )
by Malte
02:34
created
src/Query/Query.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     public function __construct(Client $client, $charset = 'UTF-8') {
77 77
         $this->setClient($client);
78 78
 
79
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
79
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
80 80
 
81 81
         if (ClientManager::get('options.fetch_order') === 'desc') {
82 82
             $this->fetch_order = 'desc';
83
-        } else {
83
+        }else {
84 84
             $this->fetch_order = 'asc';
85 85
         }
86 86
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * Instance boot method for additional functionality
96 96
      */
97
-    protected function boot(){}
97
+    protected function boot() {}
98 98
 
99 99
     /**
100 100
      * Parse a given value
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @return string
104 104
      */
105
-    protected function parse_value($value){
106
-        switch(true){
105
+    protected function parse_value($value) {
106
+        switch (true) {
107 107
             case $value instanceof \Carbon\Carbon:
108 108
                 $value = $value->format($this->date_format);
109 109
                 break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @throws MessageSearchValidationException
121 121
      */
122 122
     protected function parse_date($date) {
123
-        if($date instanceof \Carbon\Carbon) return $date;
123
+        if ($date instanceof \Carbon\Carbon) return $date;
124 124
 
125 125
         try {
126 126
             $date = Carbon::parse($date);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @return Collection
160 160
      * @throws GetMessagesFailedException
161 161
      */
162
-    protected function search(){
162
+    protected function search() {
163 163
         $this->generate_query();
164 164
 
165 165
         try {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                     $raw_flag = isset($raw_flags[$msgno]) ? $raw_flags[$msgno] : [];
228 228
 
229 229
                     $message = Message::make($msgno, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions());
230
-                    switch ($message_key){
230
+                    switch ($message_key) {
231 231
                         case 'number':
232 232
                             $message_key = $message->getMessageNo();
233 233
                             break;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
             return $messages;
248 248
         } catch (\Exception $e) {
249
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
249
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
250 250
         }
251 251
     }
252 252
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      * @throws MessageHeaderFetchingException
264 264
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
265 265
      */
266
-    public function getMessage($msgno, $msglist = null){
266
+    public function getMessage($msgno, $msglist = null) {
267 267
         return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags());
268 268
     }
269 269
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      * @return LengthAwarePaginator
277 277
      * @throws GetMessagesFailedException
278 278
      */
279
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
279
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
280 280
         if (
281 281
                $page === null
282 282
             && isset($_GET[$page_name])
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
         $this->query->each(function($statement) use(&$query) {
303 303
             if (count($statement) == 1) {
304 304
                 $query .= $statement[0];
305
-            } else {
306
-                if($statement[1] === null){
305
+            }else {
306
+                if ($statement[1] === null) {
307 307
                     $query .= $statement[0];
308
-                }else{
308
+                }else {
309 309
                     $query .= $statement[0].' "'.$statement[1].'"';
310 310
                 }
311 311
             }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      * @return $this
336 336
      */
337 337
     public function limit($limit, $page = 1) {
338
-        if($page >= 1) $this->page = $page;
338
+        if ($page >= 1) $this->page = $page;
339 339
         $this->limit = $limit;
340 340
 
341 341
         return $this;
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) {
196 196
 
197 197
         $default_mask = $client->getDefaultMessageMask();
198
-        if($default_mask != null) {
198
+        if ($default_mask != null) {
199 199
             $this->mask = $default_mask;
200 200
         }
201 201
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
      * @throws MessageContentFetchingException
250 250
      * @throws \ReflectionException
251 251
      */
252
-    public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null){
252
+    public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null) {
253 253
         $reflection = new \ReflectionClass(self::class);
254 254
         /** @var self $instance */
255 255
         $instance = $reflection->newInstanceWithoutConstructor();
256 256
 
257 257
         $default_mask = $client->getDefaultMessageMask();
258
-        if($default_mask != null) {
258
+        if ($default_mask != null) {
259 259
             $instance->setMask($default_mask);
260 260
         }
261 261
         $instance->setEvents([
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
      * @throws MethodNotFoundException
288 288
      */
289 289
     public function __call($method, $arguments) {
290
-        if(strtolower(substr($method, 0, 3)) === 'get') {
290
+        if (strtolower(substr($method, 0, 3)) === 'get') {
291 291
             $name = Str::snake(substr($method, 3));
292 292
             return $this->get($name);
293 293
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
294 294
             $name = Str::snake(substr($method, 3));
295 295
 
296
-            if(in_array($name, array_keys($this->attributes))) {
296
+            if (in_array($name, array_keys($this->attributes))) {
297 297
                 $this->attributes[$name] = array_pop($arguments);
298 298
 
299 299
                 return $this->attributes[$name];
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @return mixed|null
335 335
      */
336 336
     public function get($name) {
337
-        if(isset($this->attributes[$name])) {
337
+        if (isset($this->attributes[$name])) {
338 338
             return $this->attributes[$name];
339 339
         }
340 340
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      *
408 408
      * @throws InvalidMessageDateException
409 409
      */
410
-    public function parseRawHeader($raw_header){
410
+    public function parseRawHeader($raw_header) {
411 411
         $this->header = new Header($raw_header);
412 412
     }
413 413
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
     public function parseRawFlags($raw_flags) {
419 419
         $this->flags = FlagCollection::make([]);
420 420
 
421
-        foreach($raw_flags as $flag) {
422
-            if (strpos($flag, "\\") === 0){
421
+        foreach ($raw_flags as $flag) {
422
+            if (strpos($flag, "\\") === 0) {
423 423
                 $flag = substr($flag, 1);
424 424
             }
425 425
             $flag_key = strtolower($flag);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
         if ($part->isAttachment()) {
522 522
             $this->fetchAttachment($part);
523
-        }else{
523
+        }else {
524 524
             $encoding = $this->getEncoding($part);
525 525
 
526 526
             $content = $this->decodeString($part->content, $part->encoding);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
559 559
             if ($oAttachment->getId() !== null) {
560 560
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
561
-            } else {
561
+            }else {
562 562
                 $this->attachments->push($oAttachment);
563 563
             }
564 564
         }
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 
676 676
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
677 677
             return @iconv($from, $to.'//IGNORE', $str);
678
-        } else {
678
+        }else {
679 679
             if (!$from) {
680 680
                 return mb_convert_encoding($str, $to);
681 681
             }
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
                     return EncodingAliases::get($parameter->value);
697 697
                 }
698 698
             }
699
-        }elseif (property_exists($structure, 'charset')){
699
+        }elseif (property_exists($structure, 'charset')) {
700 700
             return EncodingAliases::get($structure->charset);
701
-        }elseif (is_string($structure) === true){
701
+        }elseif (is_string($structure) === true) {
702 702
             return mb_detect_encoding($structure);
703 703
         }
704 704
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
      * @throws Exceptions\ConnectionFailedException
713 713
      * @throws Exceptions\FolderFetchingException
714 714
      */
715
-    public function getFolder(){
715
+    public function getFolder() {
716 716
         return $this->client->getFolder($this->folder_path);
717 717
     }
718 718
 
@@ -727,13 +727,13 @@  discard block
 block discarded – undo
727 727
      * @throws Exceptions\FolderFetchingException
728 728
      * @throws Exceptions\GetMessagesFailedException
729 729
      */
730
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
730
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
731 731
         $thread = $thread ? $thread : MessageCollection::make([]);
732
-        $folder = $folder ? $folder :  $this->getFolder();
732
+        $folder = $folder ? $folder : $this->getFolder();
733 733
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
734 734
 
735 735
         /** @var Message $message */
736
-        foreach($thread as $message) {
736
+        foreach ($thread as $message) {
737 737
             if ($message->message_id == $this->message_id) {
738 738
                 return $thread;
739 739
             }
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
         });
755 755
 
756 756
         if (is_array($this->in_reply_to)) {
757
-            foreach($this->in_reply_to as $in_reply_to) {
757
+            foreach ($this->in_reply_to as $in_reply_to) {
758 758
                 $folder->query()->messageId($in_reply_to)
759 759
                     ->setFetchBody($this->getFetchBodyOption())
760 760
                     ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
             $this->client->openFolder($this->folder_path);
801 801
             if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) {
802
-                if($expunge) $this->client->expunge();
802
+                if ($expunge) $this->client->expunge();
803 803
 
804 804
                 $this->client->openFolder($folder->path);
805 805
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 
842 842
             $this->client->openFolder($this->folder_path);
843 843
             if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) {
844
-                if($expunge) $this->client->expunge();
844
+                if ($expunge) $this->client->expunge();
845 845
 
846 846
                 $this->client->openFolder($folder->path);
847 847
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
      */
869 869
     public function delete($expunge = true) {
870 870
         $status = $this->setFlag("Deleted");
871
-        if($expunge) $this->client->expunge();
871
+        if ($expunge) $this->client->expunge();
872 872
 
873 873
         $event = $this->getEvent("message", "deleted");
874 874
         $event::dispatch($this);
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
      */
888 888
     public function restore($expunge = true) {
889 889
         $status = $this->unsetFlag("Deleted");
890
-        if($expunge) $this->client->expunge();
890
+        if ($expunge) $this->client->expunge();
891 891
 
892 892
         $event = $this->getEvent("message", "restored");
893 893
         $event::dispatch($this);
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
      *
1041 1041
      * @return object|null
1042 1042
      */
1043
-    public function getStructure(){
1043
+    public function getStructure() {
1044 1044
         return $this->structure;
1045 1045
     }
1046 1046
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      *
1067 1067
      * @return array
1068 1068
      */
1069
-    public function getAttributes(){
1069
+    public function getAttributes() {
1070 1070
         return array_merge($this->attributes, $this->header->getAttributes());
1071 1071
     }
1072 1072
 
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
      *
1077 1077
      * @return $this
1078 1078
      */
1079
-    public function setMask($mask){
1080
-        if(class_exists($mask)){
1079
+    public function setMask($mask) {
1080
+        if (class_exists($mask)) {
1081 1081
             $this->mask = $mask;
1082 1082
         }
1083 1083
 
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
      *
1090 1090
      * @return string
1091 1091
      */
1092
-    public function getMask(){
1092
+    public function getMask() {
1093 1093
         return $this->mask;
1094 1094
     }
1095 1095
 
@@ -1100,9 +1100,9 @@  discard block
 block discarded – undo
1100 1100
      * @return mixed
1101 1101
      * @throws MaskNotFoundException
1102 1102
      */
1103
-    public function mask($mask = null){
1103
+    public function mask($mask = null) {
1104 1104
         $mask = $mask !== null ? $mask : $this->mask;
1105
-        if(class_exists($mask)){
1105
+        if (class_exists($mask)) {
1106 1106
             return new $mask($this);
1107 1107
         }
1108 1108
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
      *
1116 1116
      * @return $this
1117 1117
      */
1118
-    public function setFolderPath($folder_path){
1118
+    public function setFolderPath($folder_path) {
1119 1119
         $this->folder_path = $folder_path;
1120 1120
 
1121 1121
         return $this;
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
      *
1128 1128
      * @return $this
1129 1129
      */
1130
-    public function setConfig($config){
1130
+    public function setConfig($config) {
1131 1131
         $this->config = $config;
1132 1132
 
1133 1133
         return $this;
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
      *
1140 1140
      * @return $this
1141 1141
      */
1142
-    public function setAttachments($attachments){
1142
+    public function setAttachments($attachments) {
1143 1143
         $this->attachments = $attachments;
1144 1144
 
1145 1145
         return $this;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
      *
1152 1152
      * @return $this
1153 1153
      */
1154
-    public function setFlags($flags){
1154
+    public function setFlags($flags) {
1155 1155
         $this->flags = $flags;
1156 1156
 
1157 1157
         return $this;
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
      * @throws Exceptions\ConnectionFailedException
1165 1165
      * @return $this
1166 1166
      */
1167
-    public function setClient($client){
1167
+    public function setClient($client) {
1168 1168
         $this->client = $client;
1169 1169
         $this->client->openFolder($this->folder_path);
1170 1170
 
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
      * @throws Exceptions\RuntimeException
1181 1181
      * @return $this
1182 1182
      */
1183
-    public function setMsgn($msgn, $msglist = null){
1183
+    public function setMsgn($msgn, $msglist = null) {
1184 1184
         $this->msgn = $msgn;
1185 1185
         $this->msglist = $msglist;
1186 1186
 
Please login to merge, or discard this patch.