Passed
Push — master ( 7eda73...e84ff4 )
by Malte
04:28
created
src/IMAP/Query/Query.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function __construct(Client $client, $charset = 'UTF-8') {
69 69
         $this->setClient($client);
70 70
 
71
-        if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
71
+        if (config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
72 72
 
73 73
         $this->date_format = config('imap.date_format', 'd M y');
74 74
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     /**
81 81
      * Instance boot method for additional functionality
82 82
      */
83
-    protected function boot(){}
83
+    protected function boot() {}
84 84
 
85 85
     /**
86 86
      * Parse a given value
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
      *
89 89
      * @return string
90 90
      */
91
-    protected function parse_value($value){
92
-        switch(true){
91
+    protected function parse_value($value) {
92
+        switch (true) {
93 93
             case $value instanceof \Carbon\Carbon:
94 94
                 $value = $value->format($this->date_format);
95 95
                 break;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @throws MessageSearchValidationException
107 107
      */
108 108
     protected function parse_date($date) {
109
-        if($date instanceof \Carbon\Carbon) return $date;
109
+        if ($date instanceof \Carbon\Carbon) return $date;
110 110
 
111 111
         try {
112 112
             $date = Carbon::parse($date);
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
      * @return \Illuminate\Support\Collection
146 146
      * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException
147 147
      */
148
-    protected function search(){
148
+    protected function search() {
149 149
         $this->generate_query();
150 150
 
151 151
         /**
152 152
          * Don't set the charset if it isn't used - prevent strange outlook mail server errors
153 153
          * @see https://github.com/Webklex/laravel-imap/issues/100
154 154
          */
155
-        if($this->getCharset() === null){
155
+        if ($this->getCharset() === null) {
156 156
             $available_messages = imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID);
157
-        }else{
157
+        } else {
158 158
             $available_messages = imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset());
159 159
         }
160 160
 
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 
185 185
                 $options = config('imap.options');
186 186
 
187
-                if(strtolower($options['fetch_order']) === 'desc'){
187
+                if (strtolower($options['fetch_order']) === 'desc') {
188 188
                     $available_messages = $available_messages->reverse();
189 189
                 }
190 190
 
191
-                $query =& $this;
191
+                $query = & $this;
192 192
 
193 193
                 $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) {
194 194
                     $oMessage = new Message($msgno, $msglist, $query->getClient(), $query->getFetchOptions(), $query->getFetchBody(), $query->getFetchAttachment(), $query->getFetchFlags());
195
-                    switch ($options['message_key']){
195
+                    switch ($options['message_key']) {
196 196
                         case 'number':
197 197
                             $message_key = $oMessage->getMessageNo();
198 198
                             break;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      * @return \Illuminate\Pagination\LengthAwarePaginator
224 224
      * @throws GetMessagesFailedException
225 225
      */
226
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
226
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
227 227
         $this->page = $page > $this->page ? $page : $this->page;
228 228
         $this->limit = $per_page;
229 229
 
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
             if (count($statement) == 1) {
242 242
                 $query .= $statement[0];
243 243
             } else {
244
-                if($statement[1] === null){
244
+                if ($statement[1] === null) {
245 245
                     $query .= $statement[0];
246
-                }else{
246
+                } else {
247 247
                     $query .= $statement[0].' "'.$statement[1].'"';
248 248
                 }
249 249
             }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
      * @return $this
274 274
      */
275 275
     public function limit($limit, $page = 1) {
276
-        if($page >= 1) $this->page = $page;
276
+        if ($page >= 1) $this->page = $page;
277 277
         $this->limit = $limit;
278 278
 
279 279
         return $this;
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
     public function __construct(Client $client, $charset = 'UTF-8') {
69 69
         $this->setClient($client);
70 70
 
71
-        if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
71
+        if(config('imap.options.fetch') === IMAP::FT_PEEK) {
72
+            $this->leaveUnread();
73
+        }
72 74
 
73 75
         $this->date_format = config('imap.date_format', 'd M y');
74 76
 
@@ -106,7 +108,9 @@  discard block
 block discarded – undo
106 108
      * @throws MessageSearchValidationException
107 109
      */
108 110
     protected function parse_date($date) {
109
-        if($date instanceof \Carbon\Carbon) return $date;
111
+        if($date instanceof \Carbon\Carbon) {
112
+            return $date;
113
+        }
110 114
 
111 115
         try {
112 116
             $date = Carbon::parse($date);
@@ -154,7 +158,7 @@  discard block
 block discarded – undo
154 158
          */
155 159
         if($this->getCharset() === null){
156 160
             $available_messages = imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID);
157
-        }else{
161
+        } else{
158 162
             $available_messages = imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset());
159 163
         }
160 164
 
@@ -243,7 +247,7 @@  discard block
 block discarded – undo
243 247
             } else {
244 248
                 if($statement[1] === null){
245 249
                     $query .= $statement[0];
246
-                }else{
250
+                } else{
247 251
                     $query .= $statement[0].' "'.$statement[1].'"';
248 252
                 }
249 253
             }
@@ -273,7 +277,9 @@  discard block
 block discarded – undo
273 277
      * @return $this
274 278
      */
275 279
     public function limit($limit, $page = 1) {
276
-        if($page >= 1) $this->page = $page;
280
+        if($page >= 1) {
281
+            $this->page = $page;
282
+        }
277 283
         $this->limit = $limit;
278 284
 
279 285
         return $this;
Please login to merge, or discard this patch.
src/IMAP/Message.php 2 patches
Spacing   +35 added lines, -35 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
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
         return null;
960 960
     }
961 961
 
962
-    public function getFolder(){
962
+    public function getFolder() {
963 963
         return $this->client->getFolder($this->folder_path);
964 964
     }
965 965
 
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
      */
976 976
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
977 977
 
978
-        if($create_folder) $this->client->createFolder($mailbox, true);
978
+        if ($create_folder) $this->client->createFolder($mailbox, true);
979 979
 
980 980
         $target_folder = $this->client->getFolder($mailbox);
981 981
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -983,8 +983,8 @@  discard block
 block discarded – undo
983 983
         $this->client->openFolder($this->folder_path);
984 984
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
985 985
 
986
-        if($status === true){
987
-            if($expunge) $this->client->expunge();
986
+        if ($status === true) {
987
+            if ($expunge) $this->client->expunge();
988 988
             $this->client->openFolder($target_folder->path);
989 989
 
990 990
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
         $this->client->openFolder($this->folder_path);
1005 1005
 
1006 1006
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1007
-        if($expunge) $this->client->expunge();
1007
+        if ($expunge) $this->client->expunge();
1008 1008
 
1009 1009
         return $status;
1010 1010
     }
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
         $this->client->openFolder($this->folder_path);
1021 1021
 
1022 1022
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1023
-        if($expunge) $this->client->expunge();
1023
+        if ($expunge) $this->client->expunge();
1024 1024
 
1025 1025
         return $status;
1026 1026
     }
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
     /**
1151 1151
      * @return object|null
1152 1152
      */
1153
-    public function getStructure(){
1153
+    public function getStructure() {
1154 1154
         return $this->structure;
1155 1155
     }
1156 1156
 
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
     /**
1177 1177
      * @return array
1178 1178
      */
1179
-    public function getAttributes(){
1179
+    public function getAttributes() {
1180 1180
         return $this->attributes;
1181 1181
     }
1182 1182
 
@@ -1184,8 +1184,8 @@  discard block
 block discarded – undo
1184 1184
      * @param $mask
1185 1185
      * @return $this
1186 1186
      */
1187
-    public function setMask($mask){
1188
-        if(class_exists($mask)){
1187
+    public function setMask($mask) {
1188
+        if (class_exists($mask)) {
1189 1189
             $this->mask = $mask;
1190 1190
         }
1191 1191
 
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
     /**
1196 1196
      * @return string
1197 1197
      */
1198
-    public function getMask(){
1198
+    public function getMask() {
1199 1199
         return $this->mask;
1200 1200
     }
1201 1201
 
@@ -1206,9 +1206,9 @@  discard block
 block discarded – undo
1206 1206
      * @return mixed
1207 1207
      * @throws MaskNotFoundException
1208 1208
      */
1209
-    public function mask($mask = null){
1209
+    public function mask($mask = null) {
1210 1210
         $mask = $mask !== null ? $mask : $this->mask;
1211
-        if(class_exists($mask)){
1211
+        if (class_exists($mask)) {
1212 1212
             return new $mask($this);
1213 1213
         }
1214 1214
 
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
 
@@ -975,7 +975,9 @@  discard block
 block discarded – undo
975 975
      */
976 976
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
977 977
 
978
-        if($create_folder) $this->client->createFolder($mailbox, true);
978
+        if($create_folder) {
979
+            $this->client->createFolder($mailbox, true);
980
+        }
979 981
 
980 982
         $target_folder = $this->client->getFolder($mailbox);
981 983
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -984,7 +986,9 @@  discard block
 block discarded – undo
984 986
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
985 987
 
986 988
         if($status === true){
987
-            if($expunge) $this->client->expunge();
989
+            if($expunge) {
990
+                $this->client->expunge();
991
+            }
988 992
             $this->client->openFolder($target_folder->path);
989 993
 
990 994
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1004,7 +1008,9 @@  discard block
 block discarded – undo
1004 1008
         $this->client->openFolder($this->folder_path);
1005 1009
 
1006 1010
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1007
-        if($expunge) $this->client->expunge();
1011
+        if($expunge) {
1012
+            $this->client->expunge();
1013
+        }
1008 1014
 
1009 1015
         return $status;
1010 1016
     }
@@ -1020,7 +1026,9 @@  discard block
 block discarded – undo
1020 1026
         $this->client->openFolder($this->folder_path);
1021 1027
 
1022 1028
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1023
-        if($expunge) $this->client->expunge();
1029
+        if($expunge) {
1030
+            $this->client->expunge();
1031
+        }
1024 1032
 
1025 1033
         return $status;
1026 1034
     }
Please login to merge, or discard this patch.
src/IMAP/Support/PaginatedCollection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
      * @return int|null
70 70
      */
71 71
     public function total($total = null) {
72
-        if($total === null) {
72
+        if ($total === null) {
73 73
             return $this->total;
74 74
         }
75 75
 
Please login to merge, or discard this patch.