Passed
Push — master ( b5f4ee...d62290 )
by Malte
05:36 queued 01:04
created
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 = (property_exists($p, 'charset')) ? $p->charset : $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);
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
                     return EncodingAliases::get($parameter->value);
918 918
                 }
919 919
             }
920
-        }elseif (is_string($structure) === true){
920
+        }elseif (is_string($structure) === true) {
921 921
             return mb_detect_encoding($structure);
922 922
         }
923 923
 
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
         return null;
968 968
     }
969 969
 
970
-    public function getFolder(){
970
+    public function getFolder() {
971 971
         return $this->client->getFolder($this->folder_path);
972 972
     }
973 973
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
      */
984 984
     public function moveToFolder($mailbox = 'INBOX', $expunge = false, $create_folder = true) {
985 985
 
986
-        if($create_folder) $this->client->createFolder($mailbox, true);
986
+        if ($create_folder) $this->client->createFolder($mailbox, true);
987 987
 
988 988
         $target_folder = $this->client->getFolder($mailbox);
989 989
         $target_status = $target_folder->getStatus(IMAP::SA_ALL);
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
         $this->client->openFolder($this->folder_path);
992 992
         $status = \imap_mail_move($this->client->getConnection(), $this->uid, $mailbox, IMAP::CP_UID);
993 993
 
994
-        if($status === true){
995
-            if($expunge) $this->client->expunge();
994
+        if ($status === true) {
995
+            if ($expunge) $this->client->expunge();
996 996
             $this->client->openFolder($target_folder->path);
997 997
 
998 998
             return $target_folder->getMessage($target_status->uidnext, null, $this->fetch_options, $this->fetch_body, $this->fetch_attachment, $this->fetch_flags);
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
         $this->client->openFolder($this->folder_path);
1013 1013
 
1014 1014
         $status = \imap_delete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1015
-        if($expunge) $this->client->expunge();
1015
+        if ($expunge) $this->client->expunge();
1016 1016
 
1017 1017
         return $status;
1018 1018
     }
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
         $this->client->openFolder($this->folder_path);
1029 1029
 
1030 1030
         $status = \imap_undelete($this->client->getConnection(), $this->uid, IMAP::FT_UID);
1031
-        if($expunge) $this->client->expunge();
1031
+        if ($expunge) $this->client->expunge();
1032 1032
 
1033 1033
         return $status;
1034 1034
     }
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
     /**
1159 1159
      * @return object|null
1160 1160
      */
1161
-    public function getStructure(){
1161
+    public function getStructure() {
1162 1162
         return $this->structure;
1163 1163
     }
1164 1164
 
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
     /**
1185 1185
      * @return array
1186 1186
      */
1187
-    public function getAttributes(){
1187
+    public function getAttributes() {
1188 1188
         return $this->attributes;
1189 1189
     }
1190 1190
 
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
      * @param $mask
1193 1193
      * @return $this
1194 1194
      */
1195
-    public function setMask($mask){
1196
-        if(class_exists($mask)){
1195
+    public function setMask($mask) {
1196
+        if (class_exists($mask)) {
1197 1197
             $this->mask = $mask;
1198 1198
         }
1199 1199
 
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
     /**
1204 1204
      * @return string
1205 1205
      */
1206
-    public function getMask(){
1206
+    public function getMask() {
1207 1207
         return $this->mask;
1208 1208
     }
1209 1209
 
@@ -1214,9 +1214,9 @@  discard block
 block discarded – undo
1214 1214
      * @return mixed
1215 1215
      * @throws MaskNotFoundException
1216 1216
      */
1217
-    public function mask($mask = null){
1217
+    public function mask($mask = null) {
1218 1218
         $mask = $mask !== null ? $mask : $this->mask;
1219
-        if(class_exists($mask)){
1219
+        if (class_exists($mask)) {
1220 1220
             return new $mask($this);
1221 1221
         }
1222 1222
 
Please login to merge, or discard this patch.
src/IMAP/Attachment.php 1 patch
Spacing   +16 added lines, -16 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,9 +263,9 @@  discard block
 block discarded – undo
263 263
      * @param $name
264 264
      */
265 265
     public function setName($name) {
266
-        if($this->config['decoder']['message']['subject'] === 'utf-8') {
266
+        if ($this->config['decoder']['message']['subject'] === 'utf-8') {
267 267
             $this->name = \imap_utf8($name);
268
-        }else{
268
+        } else {
269 269
             $this->name = mb_decode_mimeheader($name);
270 270
         }
271 271
     }
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
     /**
286 286
      * @return string|null
287 287
      */
288
-    public function getMimeType(){
288
+    public function getMimeType() {
289 289
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
290 290
     }
291 291
 
292 292
     /**
293 293
      * @return string|null
294 294
      */
295
-    public function getExtension(){
295
+    public function getExtension() {
296 296
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
297
-        if (class_exists($deprecated_guesser) !== false){
297
+        if (class_exists($deprecated_guesser) !== false) {
298 298
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
299 299
         }
300 300
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
     /**
306 306
      * @return array
307 307
      */
308
-    public function getAttributes(){
308
+    public function getAttributes() {
309 309
         return $this->attributes;
310 310
     }
311 311
 
312 312
     /**
313 313
      * @return Message
314 314
      */
315
-    public function getMessage(){
315
+    public function getMessage() {
316 316
         return $this->oMessage;
317 317
     }
318 318
 
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
      * @param $mask
321 321
      * @return $this
322 322
      */
323
-    public function setMask($mask){
324
-        if(class_exists($mask)){
323
+    public function setMask($mask) {
324
+        if (class_exists($mask)) {
325 325
             $this->mask = $mask;
326 326
         }
327 327
 
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
     /**
332 332
      * @return string
333 333
      */
334
-    public function getMask(){
334
+    public function getMask() {
335 335
         return $this->mask;
336 336
     }
337 337
 
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
      * @return mixed
343 343
      * @throws MaskNotFoundException
344 344
      */
345
-    public function mask($mask = null){
345
+    public function mask($mask = null) {
346 346
         $mask = $mask !== null ? $mask : $this->mask;
347
-        if(class_exists($mask)){
347
+        if (class_exists($mask)) {
348 348
             return new $mask($this);
349 349
         }
350 350
 
Please login to merge, or discard this patch.
src/IMAP/Query/WhereQuery.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -76,18 +76,18 @@  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
-        if (strpos(strtolower($name), "where") === false){
84
+        if (strpos(strtolower($name), "where") === false) {
85 85
             $method = 'where'.ucfirst($name);
86
-        }else{
86
+        } else {
87 87
             $method = lcfirst($name);
88 88
         }
89 89
 
90
-        if(method_exists($this, $method) === true){
90
+        if (method_exists($this, $method) === true) {
91 91
             return call_user_func_array([$that, $method], $arguments);
92 92
         }
93 93
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         if (substr($criteria, 0, 6) === "CUSTOM") {
108 108
             return substr($criteria, 6);
109 109
         }
110
-        if(in_array($criteria, $this->available_criteria) === false) {
110
+        if (in_array($criteria, $this->available_criteria) === false) {
111 111
             throw new InvalidWhereQueryCriteriaException();
112 112
         }
113 113
 
@@ -122,20 +122,20 @@  discard block
 block discarded – undo
122 122
      * @throws InvalidWhereQueryCriteriaException
123 123
      */
124 124
     public function where($criteria, $value = null) {
125
-        if(is_array($criteria)){
126
-            foreach($criteria as $key => $value){
127
-                if(is_numeric($key)){
125
+        if (is_array($criteria)) {
126
+            foreach ($criteria as $key => $value) {
127
+                if (is_numeric($key)) {
128 128
                     return $this->where($value);
129 129
                 }
130 130
                 return $this->where($key, $value);
131 131
             }
132
-        }else{
132
+        } else {
133 133
             $criteria = $this->validate_criteria($criteria);
134 134
             $value = $this->parse_value($value);
135 135
 
136
-            if($value === null || $value === ''){
136
+            if ($value === null || $value === '') {
137 137
                 $this->query->push([$criteria]);
138
-            }else{
138
+            } else {
139 139
                 $this->query->push([$criteria, $value]);
140 140
             }
141 141
         }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function orWhere(\Closure $closure = null) {
152 152
         $this->query->push(['OR']);
153
-        if($closure !== null) $closure($this);
153
+        if ($closure !== null) $closure($this);
154 154
 
155 155
         return $this;
156 156
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function andWhere(\Closure $closure = null) {
164 164
         $this->query->push(['AND']);
165
-        if($closure !== null) $closure($this);
165
+        if ($closure !== null) $closure($this);
166 166
 
167 167
         return $this;
168 168
     }
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
      * @return WhereQuery
403 403
      * @throws InvalidWhereQueryCriteriaException
404 404
      */
405
-    public function whereNoXSpam(){
405
+    public function whereNoXSpam() {
406 406
         return $this->where("X-Spam-Flag NO");
407 407
     }
408 408
 
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
      * @return WhereQuery
411 411
      * @throws InvalidWhereQueryCriteriaException
412 412
      */
413
-    public function whereIsXSpam(){
413
+    public function whereIsXSpam() {
414 414
         return $this->where("X-Spam-Flag YES");
415 415
     }
416 416
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      * @return WhereQuery
421 421
      * @throws InvalidWhereQueryCriteriaException
422 422
      */
423
-    public function whereLanguage($country_code){
423
+    public function whereLanguage($country_code) {
424 424
         return $this->where("Content-Language $country_code");
425 425
     }
426 426
 }
Please login to merge, or discard this patch.