Completed
Push — master ( 0f9365...3e6975 )
by Malte
05:01
created
src/IMAP/Query/WhereQuery.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
 
77 77
         $name = Str::camel($name);
78 78
 
79
-        if(strtolower(substr($name, 0, 3)) === 'not') {
79
+        if (strtolower(substr($name, 0, 3)) === 'not') {
80 80
             $that = $that->whereNot();
81 81
             $name = substr($name, 3);
82 82
         }
83 83
 
84 84
         $method = 'where'.ucfirst($name);
85
-        if(method_exists($this, $method) === true){
85
+        if (method_exists($this, $method) === true) {
86 86
             return call_user_func_array([$that, $method], $arguments);
87 87
         }
88 88
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     protected function validate_criteria($criteria) {
100 100
         $criteria = strtoupper($criteria);
101 101
 
102
-        if(in_array($criteria, $this->available_criteria) === false) {
102
+        if (in_array($criteria, $this->available_criteria) === false) {
103 103
             throw new InvalidWhereQueryCriteriaException();
104 104
         }
105 105
 
@@ -114,21 +114,21 @@  discard block
 block discarded – undo
114 114
      * @throws InvalidWhereQueryCriteriaException
115 115
      */
116 116
     public function where($criteria, $value = null) {
117
-        if(is_array($criteria)){
118
-            foreach($criteria as $arguments){
119
-                if(count($arguments) == 1){
117
+        if (is_array($criteria)) {
118
+            foreach ($criteria as $arguments) {
119
+                if (count($arguments) == 1) {
120 120
                     $this->where($arguments[0]);
121
-                }elseif(count($arguments) == 2){
121
+                }elseif (count($arguments) == 2) {
122 122
                     $this->where($arguments[0], $arguments[1]);
123 123
                 }
124 124
             }
125
-        }else{
125
+        } else {
126 126
             $criteria = $this->validate_criteria($criteria);
127 127
             $value = $this->parse_value($value);
128 128
 
129
-            if($value === null || $value === ''){
129
+            if ($value === null || $value === '') {
130 130
                 $this->query->push([$criteria]);
131
-            }else{
131
+            } else {
132 132
                 $this->query->push([$criteria, $value]);
133 133
             }
134 134
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function orWhere(\Closure $closure = null) {
145 145
         $this->query->push(['OR']);
146
-        if($closure !== null) $closure($this);
146
+        if ($closure !== null) $closure($this);
147 147
 
148 148
         return $this;
149 149
     }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function andWhere(\Closure $closure = null) {
157 157
         $this->query->push(['AND']);
158
-        if($closure !== null) $closure($this);
158
+        if ($closure !== null) $closure($this);
159 159
 
160 160
         return $this;
161 161
     }
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
      * @return WhereQuery
406 406
      * @throws InvalidWhereQueryCriteriaException
407 407
      */
408
-    public function whereNoXSpam(){
408
+    public function whereNoXSpam() {
409 409
         return $this->where("X-Spam-Flag NO");
410 410
     }
411 411
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      * @return WhereQuery
414 414
      * @throws InvalidWhereQueryCriteriaException
415 415
      */
416
-    public function whereIsXSpam(){
416
+    public function whereIsXSpam() {
417 417
         return $this->where("X-Spam-Flag YES");
418 418
     }
419 419
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
      * @return WhereQuery
424 424
      * @throws InvalidWhereQueryCriteriaException
425 425
      */
426
-    public function whereLanguage($country_code){
426
+    public function whereLanguage($country_code) {
427 427
         return $this->where("Content-Language $country_code");
428 428
     }
429 429
 }
Please login to merge, or discard this patch.
src/IMAP/Folder.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
         $this->setDelimiter($structure->delimiter);
121 121
         $this->path      = $structure->name;
122
-        $this->full_name  = $this->decodeName($structure->name);
122
+        $this->full_name = $this->decodeName($structure->name);
123 123
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
124 124
 
125 125
         $this->parseAttributes($structure->attributes);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @return WhereQuery
133 133
      * @throws Exceptions\ConnectionFailedException
134 134
      */
135
-    public function query($charset = 'UTF-8'){
135
+    public function query($charset = 'UTF-8') {
136 136
         $this->getClient()->checkConnection();
137 137
         $this->getClient()->openFolder($this->path);
138 138
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      * @inheritdoc self::query($charset = 'UTF-8')
144 144
      * @throws Exceptions\ConnectionFailedException
145 145
      */
146
-    public function search($charset = 'UTF-8'){
146
+    public function search($charset = 'UTF-8') {
147 147
         return $this->query($charset);
148 148
     }
149 149
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @inheritdoc self::query($charset = 'UTF-8')
152 152
      * @throws Exceptions\ConnectionFailedException
153 153
      */
154
-    public function messages($charset = 'UTF-8'){
154
+    public function messages($charset = 'UTF-8') {
155 155
         return $this->query($charset);
156 156
     }
157 157
 
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
      * @deprecated 1.2.1:2.0.0 No longer needed. Use Folder::query() instead
317 317
      * @see Folder::query()
318 318
      */
319
-    public function searchMessages(array $where, $fetch_options = null, $fetch_body = true,  $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") {
319
+    public function searchMessages(array $where, $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") {
320 320
         $this->getClient()->checkConnection();
321 321
 
322 322
         return $this->query($charset)->where($where)->setFetchOptions($fetch_options)->setFetchBody($fetch_body)
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      */
376 376
     public function delete($expunge = true) {
377 377
         $status = imap_deletemailbox($this->client->getConnection(), $this->path);
378
-        if($expunge) $this->client->expunge();
378
+        if ($expunge) $this->client->expunge();
379 379
 
380 380
         return $status;
381 381
     }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      */
393 393
     public function move($target_mailbox, $expunge = true) {
394 394
         $status = imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
395
-        if($expunge) $this->client->expunge();
395
+        if ($expunge) $this->client->expunge();
396 396
 
397 397
         return $status;
398 398
     }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
          */
434 434
 
435 435
         if ($internal_date != null) {
436
-            if ($internal_date instanceof \Carbon\Carbon){
436
+            if ($internal_date instanceof \Carbon\Carbon) {
437 437
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
438 438
             }
439 439
             return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
     /**
455 455
      * @param $delimiter
456 456
      */
457
-    public function setDelimiter($delimiter){
458
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
457
+    public function setDelimiter($delimiter) {
458
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
459 459
             $delimiter = config('imap.options.delimiter', '/');
460 460
         }
461 461
 
Please login to merge, or discard this patch.
src/IMAP/Message.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = false) {
198 198
 
199 199
         $default_mask = $client->getDefaultMessageMask();
200
-        if($default_mask != null) {
200
+        if ($default_mask != null) {
201 201
             $this->mask = $default_mask;
202 202
         }
203 203
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         $this->msglist = $msglist;
217 217
         $this->client = $client;
218 218
 
219
-        $this->uid =  ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
219
+        $this->uid = ($this->fetch_options == IMAP::FT_UID) ? $uid : $uid;
220 220
         $this->msgn = ($this->fetch_options == IMAP::FT_UID) ? imap_msgno($this->client->getConnection(), $uid) : $uid;
221 221
 
222 222
         $this->parseHeader();
@@ -239,17 +239,17 @@  discard block
 block discarded – undo
239 239
      * @throws MethodNotFoundException
240 240
      */
241 241
     public function __call($method, $arguments) {
242
-        if(strtolower(substr($method, 0, 3)) === 'get') {
242
+        if (strtolower(substr($method, 0, 3)) === 'get') {
243 243
             $name = Str::snake(substr($method, 3));
244 244
 
245
-            if(in_array($name, array_keys($this->attributes))) {
245
+            if (in_array($name, array_keys($this->attributes))) {
246 246
                 return $this->attributes[$name];
247 247
             }
248 248
 
249 249
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
250 250
             $name = Str::snake(substr($method, 3));
251 251
 
252
-            if(in_array($name, array_keys($this->attributes))) {
252
+            if (in_array($name, array_keys($this->attributes))) {
253 253
                 $this->attributes[$name] = array_pop($arguments);
254 254
 
255 255
                 return $this->attributes[$name];
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      * @return mixed|null
279 279
      */
280 280
     public function __get($name) {
281
-        if(isset($this->attributes[$name])) {
281
+        if (isset($this->attributes[$name])) {
282 282
             return $this->attributes[$name];
283 283
         }
284 284
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
         if ($replaceImages !== false) {
365 365
             $this->attachments->each(function($oAttachment) use(&$body, $replaceImages) {
366 366
                 /** @var Attachment $oAttachment */
367
-                if(is_callable($replaceImages)) {
367
+                if (is_callable($replaceImages)) {
368 368
                     $body = $replaceImages($body, $oAttachment);
369
-                }elseif(is_string($replaceImages)) {
369
+                }elseif (is_string($replaceImages)) {
370 370
                     call_user_func($replaceImages, [$body, $oAttachment]);
371
-                }else{
371
+                } else {
372 372
                     if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
373 373
                         $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
374 374
                     }
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
         }
398 398
 
399 399
         if (property_exists($header, 'subject')) {
400
-            if($this->config['decoder']['message']['subject'] === 'utf-8') {
400
+            if ($this->config['decoder']['message']['subject'] === 'utf-8') {
401 401
                 $this->subject = imap_utf8($header->subject);
402
-            }else{
402
+            } else {
403 403
                 $this->subject = mb_decode_mimeheader($header->subject);
404 404
             }
405 405
         }
406 406
 
407
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part){
407
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $part) {
408 408
             $this->extractHeaderAddressPart($header, $part);
409 409
         }
410 410
 
@@ -434,9 +434,9 @@  discard block
 block discarded – undo
434 434
      * @return int|null
435 435
      */
436 436
     private function extractPriority($header) {
437
-        if(preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)){
437
+        if (preg_match('/x\-priority\:.*([0-9]{1,2})/i', $header, $priority)) {
438 438
             $priority = isset($priority[1]) ? (int) $priority[1] : 0;
439
-            switch($priority){
439
+            switch ($priority) {
440 440
                 case IMAP::MESSAGE_PRIORITY_HIGHEST;
441 441
                     $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
442 442
                     break;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
         if (property_exists($header, 'date')) {
488 488
             $date = $header->date;
489 489
 
490
-            if(preg_match('/\+0580/', $date)) {
490
+            if (preg_match('/\+0580/', $date)) {
491 491
                 $date = str_replace('+0580', '+0530', $date);
492 492
             }
493 493
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
                         $date = trim(array_pop($array));
511 511
                         break;
512 512
                 }
513
-                try{
513
+                try {
514 514
                     $parsed_date = Carbon::parse($date);
515 515
                 } catch (\Exception $_e) {
516 516
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e);
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
         $this->client->openFolder($this->folder_path);
534 534
         $flags = imap_fetch_overview($this->client->getConnection(), $this->uid, IMAP::FT_UID);
535 535
         if (is_array($flags) && isset($flags[0])) {
536
-            foreach($this->available_flags as $flag) {
536
+            foreach ($this->available_flags as $flag) {
537 537
                 $this->parseFlag($flags, $flag);
538 538
             }
539 539
         }
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
             } else {
606 606
                 $personalParts = imap_mime_header_decode($address->personal);
607 607
 
608
-                if(is_array($personalParts)) {
608
+                if (is_array($personalParts)) {
609 609
                     $address->personal = '';
610 610
                     foreach ($personalParts as $p) {
611 611
                         $encoding = $this->getEncoding($p->text);
@@ -633,12 +633,12 @@  discard block
 block discarded – undo
633 633
         $this->client->openFolder($this->folder_path);
634 634
         $this->structure = imap_fetchstructure($this->client->getConnection(), $this->uid, IMAP::FT_UID);
635 635
 
636
-        if(property_exists($this->structure, 'parts')){
636
+        if (property_exists($this->structure, 'parts')) {
637 637
             $parts = $this->structure->parts;
638 638
 
639
-            foreach ($parts as $part)  {
640
-                foreach ($part->parameters as $parameter)  {
641
-                    if($parameter->attribute == "charset")  {
639
+            foreach ($parts as $part) {
640
+                foreach ($part->parameters as $parameter) {
641
+                    if ($parameter->attribute == "charset") {
642 642
                         $encoding = $parameter->value;
643 643
 
644 644
                         $encoding = preg_replace('/Content-Transfer-Encoding/', '', $encoding);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                     return EncodingAliases::get($parameter->value);
920 920
                 }
921 921
             }
922
-        }elseif (is_string($structure) === true){
922
+        }elseif (is_string($structure) === true) {
923 923
             return mb_detect_encoding($structure);
924 924
         }
925 925
 
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         return null;
970 970
     }
971 971
 
972
-    public function getFolder(){
972
+    public function getFolder() {
973 973
         return $this->client->getFolder($this->folder_path);
974 974
     }
975 975
 
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
      */
986 986
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
987 987
 
988
-        if($create_folder) $this->client->createFolder($mailbox, true);
988
+        if ($create_folder) $this->client->createFolder($mailbox, true);
989 989
 
990 990
         $target_folder = $this->client->getFolder($mailbox);
991 991
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -993,8 +993,8 @@  discard block
 block discarded – undo
993 993
         $this->client->openFolder($this->folder_path);
994 994
         $status = imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
995 995
 
996
-        if($status === true){
997
-            if($expunge) $this->client->expunge();
996
+        if ($status === true) {
997
+            if ($expunge) $this->client->expunge();
998 998
             $this->client->openFolder($target_folder->path);
999 999
 
1000 1000
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
         $this->client->openFolder($this->folder_path);
1015 1015
 
1016 1016
         $status = imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1017
-        if($expunge) $this->client->expunge();
1017
+        if ($expunge) $this->client->expunge();
1018 1018
 
1019 1019
         return $status;
1020 1020
     }
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
         $this->client->openFolder($this->folder_path);
1031 1031
 
1032 1032
         $status = imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1033
-        if($expunge) $this->client->expunge();
1033
+        if ($expunge) $this->client->expunge();
1034 1034
 
1035 1035
         return $status;
1036 1036
     }
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
     /**
1161 1161
      * @return object|null
1162 1162
      */
1163
-    public function getStructure(){
1163
+    public function getStructure() {
1164 1164
         return $this->structure;
1165 1165
     }
1166 1166
 
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
     /**
1187 1187
      * @return array
1188 1188
      */
1189
-    public function getAttributes(){
1189
+    public function getAttributes() {
1190 1190
         return $this->attributes;
1191 1191
     }
1192 1192
 
@@ -1194,8 +1194,8 @@  discard block
 block discarded – undo
1194 1194
      * @param $mask
1195 1195
      * @return $this
1196 1196
      */
1197
-    public function setMask($mask){
1198
-        if(class_exists($mask)){
1197
+    public function setMask($mask) {
1198
+        if (class_exists($mask)) {
1199 1199
             $this->mask = $mask;
1200 1200
         }
1201 1201
 
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
     /**
1206 1206
      * @return string
1207 1207
      */
1208
-    public function getMask(){
1208
+    public function getMask() {
1209 1209
         return $this->mask;
1210 1210
     }
1211 1211
 
@@ -1216,9 +1216,9 @@  discard block
 block discarded – undo
1216 1216
      * @return mixed
1217 1217
      * @throws MaskNotFoundException
1218 1218
      */
1219
-    public function mask($mask = null){
1219
+    public function mask($mask = null) {
1220 1220
         $mask = $mask !== null ? $mask : $this->mask;
1221
-        if(class_exists($mask)){
1221
+        if (class_exists($mask)) {
1222 1222
             return new $mask($this);
1223 1223
         }
1224 1224
 
Please login to merge, or discard this patch.