Passed
Push — master ( aad7db...4b5f38 )
by Malte
04:57 queued 02:17
created
src/Client.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
      * @param array $config
177 177
      * @param array $default_config
178 178
      */
179
-    private function setAccountConfig($key, $config, $default_config){
179
+    private function setAccountConfig($key, $config, $default_config) {
180 180
         $value = $this->default_account_config[$key];
181
-        if(isset($config[$key])) {
181
+        if (isset($config[$key])) {
182 182
             $value = $config[$key];
183
-        }elseif(isset($default_config[$key])) {
183
+        }elseif (isset($default_config[$key])) {
184 184
             $value = $default_config[$key];
185 185
         }
186 186
         $this->$key = $value;
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
      */
193 193
     protected function setEventsFromConfig($config) {
194 194
         $this->events = ClientManager::get("events");
195
-        if(isset($config['events'])){
196
-            if(isset($config['events'])) {
197
-                foreach($config['events'] as $section => $events) {
195
+        if (isset($config['events'])) {
196
+            if (isset($config['events'])) {
197
+                foreach ($config['events'] as $section => $events) {
198 198
                     $this->events[$section] = array_merge($this->events[$section], $events);
199 199
                 }
200 200
             }
@@ -208,45 +208,45 @@  discard block
 block discarded – undo
208 208
      * @throws MaskNotFoundException
209 209
      */
210 210
     protected function setMaskFromConfig($config) {
211
-        $default_config  = ClientManager::get("masks");
211
+        $default_config = ClientManager::get("masks");
212 212
 
213
-        if(isset($config['masks'])){
214
-            if(isset($config['masks']['message'])) {
215
-                if(class_exists($config['masks']['message'])) {
213
+        if (isset($config['masks'])) {
214
+            if (isset($config['masks']['message'])) {
215
+                if (class_exists($config['masks']['message'])) {
216 216
                     $this->default_message_mask = $config['masks']['message'];
217
-                }else{
217
+                }else {
218 218
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
219 219
                 }
220
-            }else{
221
-                if(class_exists($default_config['message'])) {
220
+            }else {
221
+                if (class_exists($default_config['message'])) {
222 222
                     $this->default_message_mask = $default_config['message'];
223
-                }else{
223
+                }else {
224 224
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
225 225
                 }
226 226
             }
227
-            if(isset($config['masks']['attachment'])) {
228
-                if(class_exists($config['masks']['attachment'])) {
227
+            if (isset($config['masks']['attachment'])) {
228
+                if (class_exists($config['masks']['attachment'])) {
229 229
                     $this->default_message_mask = $config['masks']['attachment'];
230
-                }else{
230
+                }else {
231 231
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
232 232
                 }
233
-            }else{
234
-                if(class_exists($default_config['attachment'])) {
233
+            }else {
234
+                if (class_exists($default_config['attachment'])) {
235 235
                     $this->default_message_mask = $default_config['attachment'];
236
-                }else{
236
+                }else {
237 237
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
238 238
                 }
239 239
             }
240
-        }else{
241
-            if(class_exists($default_config['message'])) {
240
+        }else {
241
+            if (class_exists($default_config['message'])) {
242 242
                 $this->default_message_mask = $default_config['message'];
243
-            }else{
243
+            }else {
244 244
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
245 245
             }
246 246
 
247
-            if(class_exists($default_config['attachment'])) {
247
+            if (class_exists($default_config['attachment'])) {
248 248
                 $this->default_message_mask = $default_config['attachment'];
249
-            }else{
249
+            }else {
250 250
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
251 251
             }
252 252
         }
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $timeout = $this->connection !== false ? $this->connection->getConnectionTimeout() : null;
311 311
             $this->connection = new ImapProtocol($this->validate_cert);
312 312
             $this->connection->setConnectionTimeout($timeout);
313
-        }else{
313
+        }else {
314 314
             if (extension_loaded('imap') === false) {
315 315
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
316 316
             }
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
388 388
         $items = $this->connection->folders('', $pattern);
389 389
 
390
-        if(is_array($items)){
390
+        if (is_array($items)) {
391 391
             foreach ($items as $folder_name => $item) {
392 392
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
393 393
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
             }
403 403
 
404 404
             return $folders;
405
-        }else{
405
+        }else {
406 406
             throw new FolderFetchingException("failed to fetch any folders");
407 407
         }
408 408
     }
@@ -436,10 +436,10 @@  discard block
 block discarded – undo
436 436
     public function createFolder($folder, $expunge = true) {
437 437
         $this->checkConnection();
438 438
         $status = $this->connection->createFolder($folder);
439
-        if($expunge) $this->expunge();
439
+        if ($expunge) $this->expunge();
440 440
 
441 441
         $folder = $this->getFolder($folder);
442
-        if($status && $folder) {
442
+        if ($status && $folder) {
443 443
             $event = $this->getEvent("folder", "new");
444 444
             $event::dispatch($folder);
445 445
         }
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
      *
465 465
      * @return Folder
466 466
      */
467
-    public function getFolderPath(){
467
+    public function getFolderPath() {
468 468
         return $this->active_folder;
469 469
     }
470 470
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
      *
519 519
      * @return int
520 520
      */
521
-    public function getTimeout($type){
521
+    public function getTimeout($type) {
522 522
         return $this->connection->getConnectionTimeout();
523 523
     }
524 524
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
      *
528 528
      * @return string
529 529
      */
530
-    public function getDefaultMessageMask(){
530
+    public function getDefaultMessageMask() {
531 531
         return $this->default_message_mask;
532 532
     }
533 533
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
      *
538 538
      * @return array
539 539
      */
540
-    public function getDefaultEvents($section){
540
+    public function getDefaultEvents($section) {
541 541
         return $this->events[$section];
542 542
     }
543 543
 
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
      * @throws MaskNotFoundException
550 550
      */
551 551
     public function setDefaultMessageMask($mask) {
552
-        if(class_exists($mask)) {
552
+        if (class_exists($mask)) {
553 553
             $this->default_message_mask = $mask;
554 554
 
555 555
             return $this;
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
      *
564 564
      * @return string
565 565
      */
566
-    public function getDefaultAttachmentMask(){
566
+    public function getDefaultAttachmentMask() {
567 567
         return $this->default_attachment_mask;
568 568
     }
569 569
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      * @throws MaskNotFoundException
576 576
      */
577 577
     public function setDefaultAttachmentMask($mask) {
578
-        if(class_exists($mask)) {
578
+        if (class_exists($mask)) {
579 579
             $this->default_attachment_mask = $mask;
580 580
 
581 581
             return $this;
Please login to merge, or discard this patch.
src/Support/Masks/MessageMask.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * @return null
32 32
      */
33
-    public function getHtmlBody(){
33
+    public function getHtmlBody() {
34 34
         $bodies = $this->parent->getBodies();
35 35
         if (!isset($bodies['html'])) {
36 36
             return null;
37 37
         }
38 38
 
39
-        if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
39
+        if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) {
40 40
             return $bodies['html']->content;
41 41
         }
42 42
         return $bodies['html'];
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function getCustomHTMLBody($callback = false) {
52 52
         $body = $this->getHtmlBody();
53
-        if($body === null) return null;
53
+        if ($body === null) return null;
54 54
 
55 55
         if ($callback !== false) {
56 56
             $aAttachment = $this->parent->getAttachments();
57 57
             $aAttachment->each(function($oAttachment) use(&$body, $callback) {
58 58
                 /** @var Attachment $oAttachment */
59
-                if(is_callable($callback)) {
59
+                if (is_callable($callback)) {
60 60
                     $body = $callback($body, $oAttachment);
61
-                }elseif(is_string($callback)) {
61
+                }elseif (is_string($callback)) {
62 62
                     call_user_func($callback, [$body, $oAttachment]);
63 63
                 }
64 64
             });
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * @return string|null
75 75
      */
76 76
     public function getHTMLBodyWithEmbeddedBase64Images() {
77
-        return $this->getCustomHTMLBody(function($body, $oAttachment){
77
+        return $this->getCustomHTMLBody(function($body, $oAttachment) {
78 78
             /** @var \Webklex\PHPIMAP\Attachment $oAttachment */
79 79
             if ($oAttachment->id) {
80 80
                 $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body);
Please login to merge, or discard this patch.
src/Attachment.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $this->part_number = $part->part_number;
105 105
 
106 106
         $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask();
107
-        if($default_mask != null) {
107
+        if ($default_mask != null) {
108 108
             $this->mask = $default_mask;
109 109
         }
110 110
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
      * @throws MethodNotFoundException
122 122
      */
123 123
     public function __call($method, $arguments) {
124
-        if(strtolower(substr($method, 0, 3)) === 'get') {
124
+        if (strtolower(substr($method, 0, 3)) === 'get') {
125 125
             $name = Str::snake(substr($method, 3));
126 126
 
127
-            if(isset($this->attributes[$name])) {
127
+            if (isset($this->attributes[$name])) {
128 128
                 return $this->attributes[$name];
129 129
             }
130 130
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @return mixed|null
161 161
      */
162 162
     public function __get($name) {
163
-        if(isset($this->attributes[$name])) {
163
+        if (isset($this->attributes[$name])) {
164 164
             return $this->attributes[$name];
165 165
         }
166 166
 
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
             $this->setName($name);
224 224
         }elseif (($filename = $this->part->filename) !== null) {
225 225
             $this->setName($filename);
226
-        } else {
226
+        }else {
227 227
             $this->setName("undefined");
228 228
         }
229 229
 
230 230
         if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) {
231 231
             if ($this->part->ifdescription) {
232 232
                 $this->setName($this->part->description);
233
-            } else {
233
+            }else {
234 234
                 $this->setName($this->part->subtype);
235 235
             }
236 236
         }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     public function setName($name) {
257 257
         $decoder = $this->config['decoder']['attachment'];
258 258
         if ($name !== null) {
259
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
259
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
260 260
                 $this->name = \imap_utf8($name);
261
-            }else{
261
+            }else {
262 262
                 $this->name = mb_decode_mimeheader($name);
263 263
             }
264 264
         }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      *
270 270
      * @return string|null
271 271
      */
272
-    public function getMimeType(){
272
+    public function getMimeType() {
273 273
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
274 274
     }
275 275
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
      *
279 279
      * @return string|null
280 280
      */
281
-    public function getExtension(){
281
+    public function getExtension() {
282 282
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
283
-        if (class_exists($deprecated_guesser) !== false){
283
+        if (class_exists($deprecated_guesser) !== false) {
284 284
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
285 285
         }
286 286
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
      *
294 294
      * @return array
295 295
      */
296
-    public function getAttributes(){
296
+    public function getAttributes() {
297 297
         return $this->attributes;
298 298
     }
299 299
 
300 300
     /**
301 301
      * @return Message
302 302
      */
303
-    public function getMessage(){
303
+    public function getMessage() {
304 304
         return $this->oMessage;
305 305
     }
306 306
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
      *
311 311
      * @return $this
312 312
      */
313
-    public function setMask($mask){
314
-        if(class_exists($mask)){
313
+    public function setMask($mask) {
314
+        if (class_exists($mask)) {
315 315
             $this->mask = $mask;
316 316
         }
317 317
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      *
324 324
      * @return string
325 325
      */
326
-    public function getMask(){
326
+    public function getMask() {
327 327
         return $this->mask;
328 328
     }
329 329
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      * @return mixed
335 335
      * @throws MaskNotFoundException
336 336
      */
337
-    public function mask($mask = null){
337
+    public function mask($mask = null) {
338 338
         $mask = $mask !== null ? $mask : $this->mask;
339
-        if(class_exists($mask)){
339
+        if (class_exists($mask)) {
340 340
             return new $mask($this);
341 341
         }
342 342
 
Please login to merge, or discard this patch.
src/Structure.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @throws MessageContentFetchingException
78 78
      * @throws InvalidMessageDateException
79 79
      */
80
-    protected function parse(){
80
+    protected function parse() {
81 81
         $this->findContentType();
82 82
         $this->parts = $this->find_parts();
83 83
     }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Determine the message content type
87 87
      */
88
-    public function findContentType(){
88
+    public function findContentType() {
89 89
 
90 90
         $content_type = $this->header->get("content-type");
91 91
         $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
92
-        if(stripos($content_type, 'multipart') === 0) {
92
+        if (stripos($content_type, 'multipart') === 0) {
93 93
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
94
-        }else{
94
+        }else {
95 95
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
96 96
         }
97 97
     }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * Determine the message content type
101 101
      */
102
-    public function getBoundary(){
102
+    public function getBoundary() {
103 103
         $boundary = $this->header->find("/boundary\=\"?(.*)\"?/");
104 104
         return str_replace('"', '', $boundary);
105 105
     }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
      * @throws MessageContentFetchingException
112 112
      * @throws InvalidMessageDateException
113 113
      */
114
-    public function find_parts(){
115
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
-            if (($boundary = $this->getBoundary()) === null)  {
114
+    public function find_parts() {
115
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
+            if (($boundary = $this->getBoundary()) === null) {
117 117
                 throw new MessageContentFetchingException("no content found", 0);
118 118
             }
119 119
 
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
             ];
123 123
 
124 124
             if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) {
125
-                if(is_array($match[1])){
126
-                    foreach($match[1] as $matched){
125
+                if (is_array($match[1])) {
126
+                    foreach ($match[1] as $matched) {
127 127
                         $boundaries[] = str_replace('"', '', $matched);
128 128
                     }
129
-                }else{
130
-                    if(!empty($match[1])) {
129
+                }else {
130
+                    if (!empty($match[1])) {
131 131
                         $boundaries[] = str_replace('"', '', $match[1]);
132 132
                     }
133 133
                 }
134 134
             }
135 135
 
136
-            $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) );
136
+            $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw));
137 137
             $parts = [];
138 138
             $part_number = 0;
139
-            foreach($raw_parts as $part) {
139
+            foreach ($raw_parts as $part) {
140 140
                 $part = trim(rtrim($part));
141 141
                 if ($part !== "--") {
142 142
                     $parts[] = new Part($part, null, $part_number);
Please login to merge, or discard this patch.
src/Connection/Protocols/ImapProtocol.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @throws ConnectionFailedException
83 83
      * @throws RuntimeException
84 84
      */
85
-    protected function enableTls(){
85
+    protected function enableTls() {
86 86
         $response = $this->requestAndResponse('STARTTLS');
87 87
         $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod());
88 88
         if (!$result) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $stack = [];
145 145
 
146 146
         //  replace any trailing <NL> including spaces with a single space
147
-        $line = rtrim($line) . ' ';
147
+        $line = rtrim($line).' ';
148 148
         while (($pos = strpos($line, ' ')) !== false) {
149 149
             $token = substr($line, 0, $pos);
150 150
             if (!strlen($token)) {
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
                     if (strlen($token) > $chars) {
175 175
                         $line = substr($token, $chars);
176 176
                         $token = substr($token, 0, $chars);
177
-                    } else {
177
+                    }else {
178 178
                         $line .= $this->nextLine();
179 179
                     }
180 180
                     $tokens[] = $token;
181
-                    $line = trim($line) . ' ';
181
+                    $line = trim($line).' ';
182 182
                     continue;
183 183
                 }
184 184
             }
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
         $line = $this->nextTaggedLine($tag); // get next tag
229 229
         if (!$dontParse) {
230 230
             $tokens = $this->decodeLine($line);
231
-        } else {
231
+        }else {
232 232
             $tokens = $line;
233 233
         }
234 234
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
             // First two chars are still needed for the response code
256 256
             $tokens = [substr($tokens, 0, 2)];
257 257
         }
258
-        if (is_array($lines)){
258
+        if (is_array($lines)) {
259 259
             if ($this->debug) echo "<< ".json_encode($lines)."\n";
260
-        }else{
260
+        }else {
261 261
             if ($this->debug) echo "<< ".$lines."\n";
262 262
         }
263 263
 
@@ -282,27 +282,27 @@  discard block
 block discarded – undo
282 282
     public function sendRequest($command, $tokens = [], &$tag = null) {
283 283
         if (!$tag) {
284 284
             $this->noun++;
285
-            $tag = 'TAG' . $this->noun;
285
+            $tag = 'TAG'.$this->noun;
286 286
         }
287 287
 
288
-        $line = $tag . ' ' . $command;
288
+        $line = $tag.' '.$command;
289 289
 
290 290
         foreach ($tokens as $token) {
291 291
             if (is_array($token)) {
292
-                if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) {
292
+                if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) {
293 293
                     throw new RuntimeException('failed to write - connection closed?');
294 294
                 }
295 295
                 if (!$this->assumedNextLine('+ ')) {
296 296
                     throw new RuntimeException('failed to send literal string');
297 297
                 }
298 298
                 $line = $token[1];
299
-            } else {
300
-                $line .= ' ' . $token;
299
+            }else {
300
+                $line .= ' '.$token;
301 301
             }
302 302
         }
303 303
         if ($this->debug) echo ">> ".$line."\n";
304 304
 
305
-        if (fwrite($this->stream, $line . "\r\n") === false) {
305
+        if (fwrite($this->stream, $line."\r\n") === false) {
306 306
             throw new RuntimeException('failed to write - connection closed?');
307 307
         }
308 308
     }
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
     public function escapeString($string) {
333 333
         if (func_num_args() < 2) {
334 334
             if (strpos($string, "\n") !== false) {
335
-                return ['{' . strlen($string) . '}', $string];
336
-            } else {
337
-                return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"';
335
+                return ['{'.strlen($string).'}', $string];
336
+            }else {
337
+                return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"';
338 338
             }
339 339
         }
340 340
         $result = [];
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             }
360 360
             $result[] = $this->escapeList($v);
361 361
         }
362
-        return '(' . implode(' ', $result) . ')';
362
+        return '('.implode(' ', $result).')';
363 363
     }
364 364
 
365 365
     /**
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
                     error_log("got an extra server challenge: $response");
400 400
                     // respond with an empty response.
401 401
                     $this->sendRequest('');
402
-                } else {
402
+                }else {
403 403
                     if (preg_match('/^NO /i', $response) ||
404 404
                         preg_match('/^BAD /i', $response)) {
405 405
                         error_log("got failure response: $response");
406 406
                         return false;
407
-                    } else if (preg_match("/^OK /i", $response)) {
407
+                    }else if (preg_match("/^OK /i", $response)) {
408 408
                         return true;
409 409
                     }
410 410
                 }
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      *
438 438
      * @return bool
439 439
      */
440
-    public function connected(){
440
+    public function connected() {
441 441
         return (boolean) $this->stream;
442 442
     }
443 443
 
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
                     $result[strtolower($tokens[1])] = $tokens[0];
485 485
                     break;
486 486
                 case '[UIDVALIDITY':
487
-                    $result['uidvalidity'] = (int)$tokens[2];
487
+                    $result['uidvalidity'] = (int) $tokens[2];
488 488
                     break;
489 489
                 case '[UIDNEXT':
490
-                    $result['uidnext'] = (int)$tokens[2];
490
+                    $result['uidnext'] = (int) $tokens[2];
491 491
                     break;
492 492
                 default:
493 493
                     // ignore
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
         if (is_array($from)) {
542 542
             $set = implode(',', $from);
543 543
         } elseif ($to === null) {
544
-            $set = (int)$from;
544
+            $set = (int) $from;
545 545
         } elseif ($to === INF) {
546
-            $set = (int)$from . ':*';
547
-        } else {
548
-            $set = (int)$from . ':' . (int)$to;
546
+            $set = (int) $from.':*';
547
+        }else {
548
+            $set = (int) $from.':'.(int) $to;
549 549
         }
550 550
 
551
-        $items = (array)$items;
551
+        $items = (array) $items;
552 552
         $itemList = $this->escapeList($items);
553 553
 
554
-        $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag);
554
+        $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag);
555 555
 
556 556
         $result = [];
557 557
         $tokens = null; // define $tokens variable before first use
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
                 $count = count($tokens[2]);
567 567
                 if ($tokens[2][$count - 2] == 'UID') {
568 568
                     $uidKey = $count - 1;
569
-                } else {
569
+                }else {
570 570
                     $uidKey = array_search('UID', $tokens[2]) + 1;
571 571
                 }
572 572
             }
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
                     $data = $tokens[2][1];
583 583
                 } elseif ($uid && $tokens[2][2] == $items[0]) {
584 584
                     $data = $tokens[2][3];
585
-                } else {
585
+                }else {
586 586
                     // maybe the server send an other field we didn't wanted
587 587
                     $count = count($tokens[2]);
588 588
                     // we start with 2, because 0 was already checked
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
                         break;
595 595
                     }
596 596
                 }
597
-            } else {
597
+            }else {
598 598
                 $data = [];
599 599
                 while (key($tokens[2]) !== null) {
600 600
                     $data[current($tokens[2])] = next($tokens[2]);
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      * @return array
640 640
      * @throws RuntimeException
641 641
      */
642
-    public function headers($uids, $rfc = "RFC822"){
642
+    public function headers($uids, $rfc = "RFC822") {
643 643
         return $this->fetch(["$rfc.HEADER"], $uids);
644 644
     }
645 645
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
      * @return array
651 651
      * @throws RuntimeException
652 652
      */
653
-    public function flags($uids){
653
+    public function flags($uids) {
654 654
         return $this->fetch(["FLAGS"], $uids);
655 655
     }
656 656
 
@@ -734,22 +734,22 @@  discard block
 block discarded – undo
734 734
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true) {
735 735
         $item = 'FLAGS';
736 736
         if ($mode == '+' || $mode == '-') {
737
-            $item = $mode . $item;
737
+            $item = $mode.$item;
738 738
         }
739 739
         if ($silent) {
740 740
             $item .= '.SILENT';
741 741
         }
742 742
 
743 743
         $flags = $this->escapeList($flags);
744
-        $set = (int)$from;
744
+        $set = (int) $from;
745 745
         if ($to !== null) {
746
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
746
+            $set .= ':'.($to == INF ? '*' : (int) $to);
747 747
         }
748 748
 
749 749
         $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent);
750 750
 
751 751
         if ($silent) {
752
-            return (bool)$result;
752
+            return (bool) $result;
753 753
         }
754 754
 
755 755
         $tokens = $result;
@@ -799,9 +799,9 @@  discard block
 block discarded – undo
799 799
      * @throws RuntimeException
800 800
      */
801 801
     public function copyMessage($folder, $from, $to = null) {
802
-        $set = (int)$from;
802
+        $set = (int) $from;
803 803
         if ($to !== null) {
804
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
804
+            $set .= ':'.($to == INF ? '*' : (int) $to);
805 805
         }
806 806
 
807 807
         return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true);
@@ -818,9 +818,9 @@  discard block
 block discarded – undo
818 818
      * @throws RuntimeException
819 819
      */
820 820
     public function moveMessage($folder, $from, $to = null) {
821
-        $set = (int)$from;
821
+        $set = (int) $from;
822 822
         if ($to !== null) {
823
-            $set .= ':' . ($to == INF ? '*' : (int)$to);
823
+            $set .= ':'.($to == INF ? '*' : (int) $to);
824 824
         }
825 825
 
826 826
         return $this->requestAndResponse('MOVE', [$set, $this->escapeString($folder)], true);
@@ -971,14 +971,14 @@  discard block
 block discarded – undo
971 971
     /**
972 972
      * Enable the debug mode
973 973
      */
974
-    public function enableDebug(){
974
+    public function enableDebug() {
975 975
         $this->debug = true;
976 976
     }
977 977
 
978 978
     /**
979 979
      * Disable the debug mode
980 980
      */
981
-    public function disableDebug(){
981
+    public function disableDebug() {
982 982
         $this->debug = false;
983 983
     }
984 984
 }
985 985
\ No newline at end of file
Please login to merge, or discard this patch.
src/Query/WhereQuery.php 1 patch
Spacing   +19 added lines, -19 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
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if (substr($criteria, 0, 7) === "CUSTOM ") {
107 107
             return substr($criteria, 7);
108 108
         }
109
-        if(in_array($criteria, $this->available_criteria) === false) {
109
+        if (in_array($criteria, $this->available_criteria) === false) {
110 110
             throw new InvalidWhereQueryCriteriaException();
111 111
         }
112 112
 
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
      * @throws InvalidWhereQueryCriteriaException
122 122
      */
123 123
     public function where($criteria, $value = null) {
124
-        if(is_array($criteria)){
125
-            foreach($criteria as $key => $value){
126
-                if(is_numeric($key)){
124
+        if (is_array($criteria)) {
125
+            foreach ($criteria as $key => $value) {
126
+                if (is_numeric($key)) {
127 127
                     return $this->where($value);
128 128
                 }
129 129
                 return $this->where($key, $value);
130 130
             }
131
-        }else{
131
+        }else {
132 132
             $criteria = $this->validate_criteria($criteria);
133 133
             $value = $this->parse_value($value);
134 134
 
135
-            if($value === null || $value === ''){
135
+            if ($value === null || $value === '') {
136 136
                 $this->query->push([$criteria]);
137
-            }else{
137
+            }else {
138 138
                 $this->query->push([$criteria, $value]);
139 139
             }
140 140
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function orWhere(\Closure $closure = null) {
151 151
         $this->query->push(['OR']);
152
-        if($closure !== null) $closure($this);
152
+        if ($closure !== null) $closure($this);
153 153
 
154 154
         return $this;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function andWhere(\Closure $closure = null) {
163 163
         $this->query->push(['AND']);
164
-        if($closure !== null) $closure($this);
164
+        if ($closure !== null) $closure($this);
165 165
 
166 166
         return $this;
167 167
     }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      * @return WhereQuery
402 402
      * @throws InvalidWhereQueryCriteriaException
403 403
      */
404
-    public function whereNoXSpam(){
404
+    public function whereNoXSpam() {
405 405
         return $this->where("CUSTOM X-Spam-Flag NO");
406 406
     }
407 407
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      * @return WhereQuery
410 410
      * @throws InvalidWhereQueryCriteriaException
411 411
      */
412
-    public function whereIsXSpam(){
412
+    public function whereIsXSpam() {
413 413
         return $this->where("CUSTOM X-Spam-Flag YES");
414 414
     }
415 415
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @return WhereQuery
422 422
      * @throws InvalidWhereQueryCriteriaException
423 423
      */
424
-    public function whereHeader($header, $value){
424
+    public function whereHeader($header, $value) {
425 425
         return $this->where("CUSTOM HEADER $header $value");
426 426
     }
427 427
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
      * @return WhereQuery
433 433
      * @throws InvalidWhereQueryCriteriaException
434 434
      */
435
-    public function whereMessageId($messageId){
435
+    public function whereMessageId($messageId) {
436 436
         return $this->whereHeader("Message-ID", $messageId);
437 437
     }
438 438
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      * @return WhereQuery
444 444
      * @throws InvalidWhereQueryCriteriaException
445 445
      */
446
-    public function whereInReplyTo($messageId){
446
+    public function whereInReplyTo($messageId) {
447 447
         return $this->whereHeader("In-Reply-To", $messageId);
448 448
     }
449 449
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
      * @return WhereQuery
454 454
      * @throws InvalidWhereQueryCriteriaException
455 455
      */
456
-    public function whereLanguage($country_code){
456
+    public function whereLanguage($country_code) {
457 457
         return $this->where("Content-Language $country_code");
458 458
     }
459 459
 }
460 460
\ No newline at end of file
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.
src/Header.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      * @throws MethodNotFoundException
74 74
      */
75 75
     public function __call($method, $arguments) {
76
-        if(strtolower(substr($method, 0, 3)) === 'get') {
76
+        if (strtolower(substr($method, 0, 3)) === 'get') {
77 77
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
78 78
 
79
-            if(in_array($name, array_keys($this->attributes))) {
79
+            if (in_array($name, array_keys($this->attributes))) {
80 80
                 return $this->attributes[$name];
81 81
             }
82 82
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return mixed|null
103 103
      */
104 104
     public function get($name) {
105
-        if(isset($this->attributes[$name])) {
105
+        if (isset($this->attributes[$name])) {
106 106
             return $this->attributes[$name];
107 107
         }
108 108
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function find($pattern) {
119 119
         if (preg_match_all($pattern, $this->raw, $matches)) {
120 120
             if (isset($matches[1])) {
121
-                if(count($matches[1]) > 0) {
121
+                if (count($matches[1]) > 0) {
122 122
                     return $matches[1][0];
123 123
                 }
124 124
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @throws InvalidMessageDateException
133 133
      */
134
-    protected function parse(){
134
+    protected function parse() {
135 135
         $header = $this->rfc822_parse_headers($this->raw);
136 136
 
137 137
         $this->extractAddresses($header);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         $this->parseDate($header);
153 153
         foreach ($header as $key => $value) {
154 154
             $key = trim(rtrim(strtolower($key)));
155
-            if(!isset($this->attributes[$key])){
155
+            if (!isset($this->attributes[$key])) {
156 156
                 $this->attributes[$key] = $value;
157 157
             }
158 158
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      *
169 169
      * @return object
170 170
      */
171
-    public function rfc822_parse_headers($raw_headers){
171
+    public function rfc822_parse_headers($raw_headers) {
172 172
         $headers = [];
173 173
         $imap_headers = [];
174 174
         if (extension_loaded('imap')) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
         $lines = explode("\r\n", $raw_headers);
179 179
         $prev_header = null;
180
-        foreach($lines as $line) {
180
+        foreach ($lines as $line) {
181 181
             if (substr($line, 0, 1) === "\n") {
182 182
                 $line = substr($line, 1);
183 183
             }
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
                     }
198 198
                     if (is_array($headers[$prev_header])) {
199 199
                         $headers[$prev_header][] = $line;
200
-                    }else{
200
+                    }else {
201 201
                         $headers[$prev_header] .= $line;
202 202
                     }
203 203
                 }
204
-            }else{
204
+            }else {
205 205
                 if (($pos = strpos($line, ":")) > 0) {
206 206
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
207 207
                     $value = trim(rtrim(substr($line, $pos + 1)));
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
             }
212 212
         }
213 213
 
214
-        foreach($headers as $key => $values) {
214
+        foreach ($headers as $key => $values) {
215 215
             if (isset($imap_headers[$key])) continue;
216 216
             $value = null;
217
-            switch($key){
217
+            switch ($key) {
218 218
                 case 'from':
219 219
                 case 'to':
220 220
                 case 'cc':
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                     break;
230 230
                 default:
231 231
                     if (is_array($values)) {
232
-                        foreach($values as $k => $v) {
232
+                        foreach ($values as $k => $v) {
233 233
                             if ($v == "") {
234 234
                                 unset($values[$k]);
235 235
                             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                             $value = implode(" ", $values);
242 242
                         } elseif ($available_values > 2) {
243 243
                             $value = array_values($values);
244
-                        } else {
244
+                        }else {
245 245
                             $value = "";
246 246
                         }
247 247
                     }
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
      * @return array The decoded elements are returned in an array of objects, where each
262 262
      * object has two properties, charset and text.
263 263
      */
264
-    public function mime_header_decode($text){
264
+    public function mime_header_decode($text) {
265 265
         if (extension_loaded('imap')) {
266 266
             return \imap_mime_header_decode($text);
267 267
         }
268 268
         $charset = $this->getEncoding($text);
269
-        return [(object)[
269
+        return [(object) [
270 270
             "charset" => $charset,
271 271
             "text" => $this->convertEncoding($text, $charset)
272 272
         ]];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         try {
321 321
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
322 322
                 return iconv($from, $to, $str);
323
-            } else {
323
+            }else {
324 324
                 if (!$from) {
325 325
                     return mb_convert_encoding($str, $to);
326 326
                 }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             if (strstr($from, '-')) {
331 331
                 $from = str_replace('-', '', $from);
332 332
                 return $this->convertEncoding($str, $from, $to);
333
-            } else {
333
+            }else {
334 334
                 return $str;
335 335
             }
336 336
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }elseif (property_exists($structure, 'charset')) {
353 353
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
354
-        }elseif (is_string($structure) === true){
354
+        }elseif (is_string($structure) === true) {
355 355
             return mb_detect_encoding($structure);
356 356
         }
357 357
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         $decoder = $this->config['decoder']['message'];
370 370
 
371 371
         if ($value !== null) {
372
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
372
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
373 373
                 $value = \imap_utf8($value);
374 374
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
375 375
                     $value = mb_decode_mimeheader($value);
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
                 if ($this->notDecoded($original_value, $value)) {
378 378
                     $decoded_value = $this->mime_header_decode($value);
379 379
                     if (count($decoded_value) > 0) {
380
-                        if(property_exists($decoded_value[0], "text")) {
380
+                        if (property_exists($decoded_value[0], "text")) {
381 381
                             $value = $decoded_value[0]->text;
382 382
                         }
383 383
                     }
384 384
                 }
385
-            }elseif($decoder === 'iconv') {
385
+            }elseif ($decoder === 'iconv') {
386 386
                 $value = iconv_mime_decode($value);
387
-            }else{
387
+            }else {
388 388
                 $value = mb_decode_mimeheader($value);
389 389
             }
390 390
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
      * Try to extract the priority from a given raw header string
405 405
      */
406 406
     private function findPriority() {
407
-        if(($priority = $this->get("x-priority")) === null) return;
408
-        switch($priority){
407
+        if (($priority = $this->get("x-priority")) === null) return;
408
+        switch ($priority) {
409 409
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
410 410
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
411 411
                 break;
@@ -437,12 +437,12 @@  discard block
 block discarded – undo
437 437
      */
438 438
     private function decodeAddresses($values) {
439 439
         $addresses = [];
440
-        foreach($values as $address) {
440
+        foreach ($values as $address) {
441 441
             if (preg_match(
442 442
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
443 443
                 $address,
444 444
                 $matches
445
-            )){
445
+            )) {
446 446
                 $name = trim(rtrim($matches["name"]));
447 447
                 $email = trim(rtrim($matches["email"]));
448 448
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      * @param object $header
462 462
      */
463 463
     private function extractAddresses($header) {
464
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
464
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
465 465
             if (property_exists($header, $key)) {
466 466
                 $this->attributes[$key] = $this->parseAddresses($header->$key);
467 467
             }
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
             }
493 493
             if (!property_exists($address, 'personal')) {
494 494
                 $address->personal = false;
495
-            } else {
495
+            }else {
496 496
                 $personalParts = $this->mime_header_decode($address->personal);
497 497
 
498
-                if(is_array($personalParts)) {
498
+                if (is_array($personalParts)) {
499 499
                     $address->personal = '';
500 500
                     foreach ($personalParts as $p) {
501 501
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
     /**
516 516
      * Search and extract potential header extensions
517 517
      */
518
-    private function extractHeaderExtensions(){
518
+    private function extractHeaderExtensions() {
519 519
         foreach ($this->attributes as $key => $value) {
520 520
             // Only parse strings and don't parse any attributes like the user-agent
521 521
             if (is_string($value) === true && in_array($key, ["user-agent"]) === false) {
522
-                if (($pos = strpos($value, ";")) !== false){
522
+                if (($pos = strpos($value, ";")) !== false) {
523 523
                     $original = substr($value, 0, $pos);
524 524
                     $this->attributes[$key] = trim(rtrim($original));
525 525
 
526 526
                     // Get all potential extensions
527 527
                     $extensions = explode(";", substr($value, $pos + 1));
528
-                    foreach($extensions as $extension) {
529
-                        if (($pos = strpos($extension, "=")) !== false){
528
+                    foreach ($extensions as $extension) {
529
+                        if (($pos = strpos($extension, "=")) !== false) {
530 530
                             $key = substr($extension, 0, $pos);
531 531
                             $key = trim(rtrim(strtolower($key)));
532 532
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             $parsed_date = null;
570 570
             $date = $header->date;
571 571
 
572
-            if(preg_match('/\+0580/', $date)) {
572
+            if (preg_match('/\+0580/', $date)) {
573 573
                 $date = str_replace('+0580', '+0530', $date);
574 574
             }
575 575
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
                         $date = trim(array_pop($array));
593 593
                         break;
594 594
                 }
595
-                try{
595
+                try {
596 596
                     $parsed_date = Carbon::parse($date);
597 597
                 } catch (\Exception $_e) {
598 598
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.
src/Message.php 1 patch
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 && $oAttachment->getSize() > 0) {
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.