Passed
Push — master ( 556262...0c61e0 )
by Malte
02:02
created
src/Support/Masks/Mask.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function __construct($parent) {
44 44
         $this->parent = $parent;
45 45
 
46
-        if(method_exists($this->parent, 'getAttributes')){
46
+        if (method_exists($this->parent, 'getAttributes')) {
47 47
             $this->attributes = array_merge($this->attributes, $this->parent->getAttributes());
48 48
         }
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     /**
54 54
      * Boot method made to be used by any custom mask
55 55
      */
56
-    protected function boot(){}
56
+    protected function boot() {}
57 57
 
58 58
     /**
59 59
      * Call dynamic attribute setter and getter methods and inherit the parent calls
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
      * @throws MethodNotFoundException
65 65
      */
66 66
     public function __call($method, $arguments) {
67
-        if(strtolower(substr($method, 0, 3)) === 'get') {
67
+        if (strtolower(substr($method, 0, 3)) === 'get') {
68 68
             $name = Str::snake(substr($method, 3));
69 69
 
70
-            if(isset($this->attributes[$name])) {
70
+            if (isset($this->attributes[$name])) {
71 71
                 return $this->attributes[$name];
72 72
             }
73 73
 
74 74
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
75 75
             $name = Str::snake(substr($method, 3));
76 76
 
77
-            if(isset($this->attributes[$name])) {
77
+            if (isset($this->attributes[$name])) {
78 78
                 $this->attributes[$name] = array_pop($arguments);
79 79
 
80 80
                 return $this->attributes[$name];
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         }
84 84
 
85
-        if(method_exists($this->parent, $method) === true){
85
+        if (method_exists($this->parent, $method) === true) {
86 86
             return call_user_func_array([$this->parent, $method], $arguments);
87 87
         }
88 88
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      * @return mixed|null
110 110
      */
111 111
     public function __get($name) {
112
-        if(isset($this->attributes[$name])) {
112
+        if (isset($this->attributes[$name])) {
113 113
             return $this->attributes[$name];
114 114
         }
115 115
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      *
122 122
      * @return mixed
123 123
      */
124
-    public function getParent(){
124
+    public function getParent() {
125 125
         return $this->parent;
126 126
     }
127 127
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @return array
132 132
      */
133
-    public function getAttributes(){
133
+    public function getAttributes() {
134 134
         return $this->attributes;
135 135
     }
136 136
 
Please login to merge, or discard this patch.
src/Folder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
         $this->setDelimiter($delimiter);
127 127
         $this->path      = $folder_name;
128
-        $this->full_name  = $this->decodeName($folder_name);
128
+        $this->full_name = $this->decodeName($folder_name);
129 129
         $this->name      = $this->getSimpleName($this->delimiter, $this->full_name);
130 130
 
131 131
         $this->parseAttributes($attributes);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @return WhereQuery
139 139
      * @throws Exceptions\ConnectionFailedException
140 140
      */
141
-    public function query($charset = 'UTF-8'){
141
+    public function query($charset = 'UTF-8') {
142 142
         $this->getClient()->checkConnection();
143 143
         $this->getClient()->openFolder($this->path);
144 144
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @inheritdoc self::query($charset = 'UTF-8')
150 150
      * @throws Exceptions\ConnectionFailedException
151 151
      */
152
-    public function search($charset = 'UTF-8'){
152
+    public function search($charset = 'UTF-8') {
153 153
         return $this->query($charset);
154 154
     }
155 155
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      * @inheritdoc self::query($charset = 'UTF-8')
158 158
      * @throws Exceptions\ConnectionFailedException
159 159
      */
160
-    public function messages($charset = 'UTF-8'){
160
+    public function messages($charset = 'UTF-8') {
161 161
         return $this->query($charset);
162 162
     }
163 163
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     public function move($new_name, $expunge = true) {
233 233
         $this->client->checkConnection();
234 234
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
235
-        if($expunge) $this->client->expunge();
235
+        if ($expunge) $this->client->expunge();
236 236
 
237 237
         $folder = $this->client->getFolder($new_name);
238 238
         $event = $this->getEvent("folder", "moved");
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
          */
260 260
 
261 261
         if ($internal_date != null) {
262
-            if ($internal_date instanceof Carbon){
262
+            if ($internal_date instanceof Carbon) {
263 263
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
264 264
             }
265 265
         }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      */
294 294
     public function delete($expunge = true) {
295 295
         $status = $this->client->getConnection()->deleteFolder($this->path);
296
-        if($expunge) $this->client->expunge();
296
+        if ($expunge) $this->client->expunge();
297 297
 
298 298
         $event = $this->getEvent("folder", "deleted");
299 299
         $event::dispatch($this);
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
             try {
349 349
                 $line = $connection->nextLine();
350 350
                 if (($pos = strpos($line, "EXISTS")) !== false) {
351
-                    $msgn = (int) substr($line, 2, $pos -2);
351
+                    $msgn = (int) substr($line, 2, $pos - 2);
352 352
                     $connection->done();
353 353
 
354 354
                     $message = $this->query()->getMessage($msgn);
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 
360 360
                     $connection->idle();
361 361
                 }
362
-            }catch (Exceptions\RuntimeException $e) {
363
-                if(strpos($e->getMessage(), "connection closed") === false) {
362
+            } catch (Exceptions\RuntimeException $e) {
363
+                if (strpos($e->getMessage(), "connection closed") === false) {
364 364
                     throw $e;
365
-                }else{
365
+                }else {
366 366
                     $this->client->connect();
367 367
                     $this->client->openFolder($this->path);
368 368
                     $connection = $this->client->getConnection();
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
      * Set the delimiter
408 408
      * @param $delimiter
409 409
      */
410
-    public function setDelimiter($delimiter){
411
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
410
+    public function setDelimiter($delimiter) {
411
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
412 412
             $delimiter = ClientManager::get('options.delimiter', '/');
413 413
         }
414 414
 
Please login to merge, or discard this patch.
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/Header.php 1 patch
Spacing   +33 added lines, -33 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);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $this->parseDate($header);
150 150
         foreach ($header as $key => $value) {
151 151
             $key = trim(rtrim(strtolower($key)));
152
-            if(!isset($this->attributes[$key])){
152
+            if (!isset($this->attributes[$key])) {
153 153
                 $this->attributes[$key] = $value;
154 154
             }
155 155
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      *
166 166
      * @return object
167 167
      */
168
-    public function rfc822_parse_headers($raw_headers){
168
+    public function rfc822_parse_headers($raw_headers) {
169 169
         $headers = [];
170 170
         $imap_headers = [];
171 171
         if (extension_loaded('imap')) {
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 
175 175
         $lines = explode("\r\n", $raw_headers);
176 176
         $prev_header = null;
177
-        foreach($lines as $line) {
177
+        foreach ($lines as $line) {
178 178
             if (substr($line, 0, 1) === "\t") {
179 179
                 $line = substr($line, 2);
180 180
                 if ($prev_header !== null) {
181 181
                     $headers[$prev_header][] = $line;
182 182
                 }
183
-            }else{
183
+            }else {
184 184
                 if (($pos = strpos($line, ":")) > 0) {
185 185
                     $key = strtolower(substr($line, 0, $pos));
186 186
                     $value = trim(rtrim(strtolower(substr($line, $pos + 1))));
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
             }
191 191
         }
192 192
 
193
-        foreach($headers as $key => $values) {
193
+        foreach ($headers as $key => $values) {
194 194
             if (isset($imap_headers[$key])) continue;
195 195
             $value = null;
196
-            switch($key){
196
+            switch ($key) {
197 197
                 case 'from':
198 198
                 case 'to':
199 199
                 case 'cc':
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
      * @return array The decoded elements are returned in an array of objects, where each
222 222
      * object has two properties, charset and text.
223 223
      */
224
-    public function mime_header_decode($text){
224
+    public function mime_header_decode($text) {
225 225
         if (extension_loaded('imap')) {
226 226
             return \imap_mime_header_decode($text);
227 227
         }
228 228
         $charset = $this->getEncoding($text);
229
-        return [(object)[
229
+        return [(object) [
230 230
             "charset" => $charset,
231 231
             "text" => $this->convertEncoding($text, $charset)
232 232
         ]];
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         try {
281 281
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
282 282
                 return iconv($from, $to, $str);
283
-            } else {
283
+            }else {
284 284
                 if (!$from) {
285 285
                     return mb_convert_encoding($str, $to);
286 286
                 }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             if (strstr($from, '-')) {
291 291
                 $from = str_replace('-', '', $from);
292 292
                 return $this->convertEncoding($str, $from, $to);
293
-            } else {
293
+            }else {
294 294
                 return $str;
295 295
             }
296 296
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             }
312 312
         }elseif (property_exists($structure, 'charset')) {
313 313
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
314
-        }elseif (is_string($structure) === true){
314
+        }elseif (is_string($structure) === true) {
315 315
             return mb_detect_encoding($structure);
316 316
         }
317 317
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         $decoder = $this->config['decoder']['message'];
330 330
 
331 331
         if ($value !== null) {
332
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
332
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
333 333
                 $value = \imap_utf8($value);
334 334
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
335 335
                     $value = mb_decode_mimeheader($value);
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
                 if ($this->notDecoded($original_value, $value)) {
338 338
                     $decoded_value = $this->mime_header_decode($value);
339 339
                     if (count($decoded_value) > 0) {
340
-                        if(property_exists($decoded_value[0], "text")) {
340
+                        if (property_exists($decoded_value[0], "text")) {
341 341
                             $value = $decoded_value[0]->text;
342 342
                         }
343 343
                     }
344 344
                 }
345
-            }elseif($decoder === 'iconv') {
345
+            }elseif ($decoder === 'iconv') {
346 346
                 $value = iconv_mime_decode($value);
347
-            }else{
347
+            }else {
348 348
                 $value = mb_decode_mimeheader($value);
349 349
             }
350 350
 
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
      * Try to extract the priority from a given raw header string
365 365
      */
366 366
     private function findPriority() {
367
-        if(($priority = $this->get("x-priority")) === null) return;
368
-        switch($priority){
367
+        if (($priority = $this->get("x-priority")) === null) return;
368
+        switch ($priority) {
369 369
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
370 370
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
371 371
                 break;
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
      */
398 398
     private function decodeAddresses($values) {
399 399
         $addresses = [];
400
-        foreach($values as $address) {
400
+        foreach ($values as $address) {
401 401
             if (preg_match(
402 402
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
403 403
                 $address,
404 404
                 $matches
405
-            )){
405
+            )) {
406 406
                 $name = trim(rtrim($matches["name"]));
407 407
                 $email = trim(rtrim($matches["email"]));
408 408
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @param object $header
422 422
      */
423 423
     private function extractAddresses($header) {
424
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key){
424
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key) {
425 425
             if (property_exists($header, $key)) {
426 426
                 $this->attributes[$key] = $this->parseAddresses($header->$key);
427 427
             }
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
             }
449 449
             if (!property_exists($address, 'personal')) {
450 450
                 $address->personal = false;
451
-            } else {
451
+            }else {
452 452
                 $personalParts = $this->mime_header_decode($address->personal);
453 453
 
454
-                if(is_array($personalParts)) {
454
+                if (is_array($personalParts)) {
455 455
                     $address->personal = '';
456 456
                     foreach ($personalParts as $p) {
457 457
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
     /**
472 472
      * Search and extract potential header extensions
473 473
      */
474
-    private function extractHeaderExtensions(){
474
+    private function extractHeaderExtensions() {
475 475
         foreach ($this->attributes as $key => $value) {
476 476
             if (is_string($value) === true) {
477
-                if (($pos = strpos($value, ";")) !== false){
477
+                if (($pos = strpos($value, ";")) !== false) {
478 478
                     $original = substr($value, 0, $pos);
479 479
                     $this->attributes[$key] = trim(rtrim($original));
480 480
                     $extensions = explode(";", substr($value, $pos + 1));
481
-                    foreach($extensions as $extension) {
482
-                        if (($pos = strpos($extension, "=")) !== false){
481
+                    foreach ($extensions as $extension) {
482
+                        if (($pos = strpos($extension, "=")) !== false) {
483 483
                             $key = substr($extension, 0, $pos);
484 484
                             $value = substr($extension, $pos + 1);
485 485
                             $value = str_replace('"', "", $value);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             $parsed_date = null;
517 517
             $date = $header->date;
518 518
 
519
-            if(preg_match('/\+0580/', $date)) {
519
+            if (preg_match('/\+0580/', $date)) {
520 520
                 $date = str_replace('+0580', '+0530', $date);
521 521
             }
522 522
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
                         $date = trim(array_pop($array));
540 540
                         break;
541 541
                 }
542
-                try{
542
+                try {
543 543
                     $parsed_date = Carbon::parse($date);
544 544
                 } catch (\Exception $_e) {
545 545
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
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,10 +85,10 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Determine the message content type
87 87
      */
88
-    public function findContentType(){
89
-        if(stripos($this->header->get("content-type"), 'multipart') === 0) {
88
+    public function findContentType() {
89
+        if (stripos($this->header->get("content-type"), 'multipart') === 0) {
90 90
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
91
-        }else{
91
+        }else {
92 92
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
93 93
         }
94 94
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * Determine the message content type
98 98
      */
99
-    public function getBoundary(){
99
+    public function getBoundary() {
100 100
         return $this->header->find("/boundary\=\"(.*)\"/");
101 101
     }
102 102
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      * @throws MessageContentFetchingException
108 108
      * @throws InvalidMessageDateException
109 109
      */
110
-    public function find_parts(){
111
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
112
-            if (($boundary = $this->getBoundary()) === null)  {
110
+    public function find_parts() {
111
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
112
+            if (($boundary = $this->getBoundary()) === null) {
113 113
                 throw new MessageContentFetchingException("no content found", 0);
114 114
             }
115 115
 
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
             ];
119 119
 
120 120
             if (preg_match("/boundary\=\"(.*)\"/", $this->raw, $match) == 1) {
121
-                if(is_array($match[1])){
122
-                    foreach($match[1] as $matched){
121
+                if (is_array($match[1])) {
122
+                    foreach ($match[1] as $matched) {
123 123
                         $boundaries[] = $matched;
124 124
                     }
125
-                }else{
126
-                    if(!empty($match[1])) {
125
+                }else {
126
+                    if (!empty($match[1])) {
127 127
                         $boundaries[] = $match[1];
128 128
                     }
129 129
                 }
130 130
             }
131 131
 
132
-            $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) );
132
+            $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw));
133 133
             $parts = [];
134 134
             $part_number = 0;
135
-            foreach($raw_parts as $part) {
135
+            foreach ($raw_parts as $part) {
136 136
                 $part = trim(rtrim($part));
137 137
                 if ($part !== "--") {
138 138
                     $parts[] = new Part($part, null, $part_number);
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/Message.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
     public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) {
195 195
 
196 196
         $default_mask = $client->getDefaultMessageMask();
197
-        if($default_mask != null) {
197
+        if ($default_mask != null) {
198 198
             $this->mask = $default_mask;
199 199
         }
200 200
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -239,13 +239,13 @@  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
             return $this->get($name);
245 245
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
246 246
             $name = Str::snake(substr($method, 3));
247 247
 
248
-            if(in_array($name, array_keys($this->attributes))) {
248
+            if (in_array($name, array_keys($this->attributes))) {
249 249
                 $this->attributes[$name] = array_pop($arguments);
250 250
 
251 251
                 return $this->attributes[$name];
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      * @return mixed|null
287 287
      */
288 288
     public function get($name) {
289
-        if(isset($this->attributes[$name])) {
289
+        if (isset($this->attributes[$name])) {
290 290
             return $this->attributes[$name];
291 291
         }
292 292
 
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
         $flags = $this->client->getConnection()->flags([$this->msgn]);
369 369
 
370 370
         if (isset($flags[$this->msgn])) {
371
-            foreach($flags[$this->msgn] as $flag) {
372
-                if (strpos($flag, "\\") === 0){
371
+            foreach ($flags[$this->msgn] as $flag) {
372
+                if (strpos($flag, "\\") === 0) {
373 373
                     $flag = substr($flag, 1);
374 374
                 }
375 375
                 $flag_key = strtolower($flag);
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
      */
426 426
     private function fetchPart(Part $part) {
427 427
 
428
-        if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) {
428
+        if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])))) {
429 429
 
430 430
             if (strtolower($part->subtype) == "plain" || strtolower($part->subtype) == "csv") {
431 431
                 $encoding = $this->getEncoding($part);
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
             } elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') {
464 464
                 $this->fetchAttachment($part);
465 465
             }
466
-        } else {
466
+        }else {
467 467
             $this->fetchAttachment($part);
468 468
         }
469 469
     }
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         if ($oAttachment->getName() !== null) {
480 480
             if ($oAttachment->getId() !== null) {
481 481
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
482
-            } else {
482
+            }else {
483 483
                 $this->attachments->push($oAttachment);
484 484
             }
485 485
         }
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 
597 597
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
598 598
             return @iconv($from, $to.'//IGNORE', $str);
599
-        } else {
599
+        }else {
600 600
             if (!$from) {
601 601
                 return mb_convert_encoding($str, $to);
602 602
             }
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
                     return EncodingAliases::get($parameter->value);
618 618
                 }
619 619
             }
620
-        }elseif (property_exists($structure, 'charset')){
620
+        }elseif (property_exists($structure, 'charset')) {
621 621
             return EncodingAliases::get($structure->charset);
622
-        }elseif (is_string($structure) === true){
622
+        }elseif (is_string($structure) === true) {
623 623
             return mb_detect_encoding($structure);
624 624
         }
625 625
 
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
      * @throws Exceptions\ConnectionFailedException
634 634
      * @throws Exceptions\FolderFetchingException
635 635
      */
636
-    public function getFolder(){
636
+    public function getFolder() {
637 637
         return $this->client->getFolder($this->folder_path);
638 638
     }
639 639
 
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
      */
711 711
     public function delete($expunge = true) {
712 712
         $status = $this->setFlag("Deleted");
713
-        if($expunge) $this->client->expunge();
713
+        if ($expunge) $this->client->expunge();
714 714
 
715 715
         $event = $this->getEvent("message", "deleted");
716 716
         $event::dispatch($this);
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
      */
730 730
     public function restore($expunge = true) {
731 731
         $status = $this->unsetFlag("Deleted");
732
-        if($expunge) $this->client->expunge();
732
+        if ($expunge) $this->client->expunge();
733 733
 
734 734
         $event = $this->getEvent("message", "restored");
735 735
         $event::dispatch($this);
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
      *
883 883
      * @return object|null
884 884
      */
885
-    public function getStructure(){
885
+    public function getStructure() {
886 886
         return $this->structure;
887 887
     }
888 888
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
      *
909 909
      * @return array
910 910
      */
911
-    public function getAttributes(){
911
+    public function getAttributes() {
912 912
         return array_merge($this->attributes, $this->header->getAttributes());
913 913
     }
914 914
 
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
      *
919 919
      * @return $this
920 920
      */
921
-    public function setMask($mask){
922
-        if(class_exists($mask)){
921
+    public function setMask($mask) {
922
+        if (class_exists($mask)) {
923 923
             $this->mask = $mask;
924 924
         }
925 925
 
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
      *
932 932
      * @return string
933 933
      */
934
-    public function getMask(){
934
+    public function getMask() {
935 935
         return $this->mask;
936 936
     }
937 937
 
@@ -942,9 +942,9 @@  discard block
 block discarded – undo
942 942
      * @return mixed
943 943
      * @throws MaskNotFoundException
944 944
      */
945
-    public function mask($mask = null){
945
+    public function mask($mask = null) {
946 946
         $mask = $mask !== null ? $mask : $this->mask;
947
-        if(class_exists($mask)){
947
+        if (class_exists($mask)) {
948 948
             return new $mask($this);
949 949
         }
950 950
 
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +15 added lines, -15 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
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
         $this->name = $this->header->get("name");
176 176
         $this->filename = $this->header->get("filename");
177 177
 
178
-        if(!empty($this->header->get("id"))) {
178
+        if (!empty($this->header->get("id"))) {
179 179
             $this->id = $this->header->get("id");
180
-        } else if(!empty($this->header->get("x-attachment-id"))){
180
+        }else if (!empty($this->header->get("x-attachment-id"))) {
181 181
             $this->id = $this->header->get("x-attachment-id");
182
-        } else if(!empty($this->header->get("content-id"))){
182
+        }else if (!empty($this->header->get("content-id"))) {
183 183
             $this->id = strtr($this->header->get("content-id"), [
184 184
                 '<' => '',
185 185
                 '>' => ''
186 186
             ]);
187 187
         }
188 188
 
189
-        if(!empty($this->header->get("content-type"))){
189
+        if (!empty($this->header->get("content-type"))) {
190 190
             $rawContentType = $this->header->get("content-type");
191 191
             $contentTypeArray = explode(';', $rawContentType);
192 192
             $this->content_type = trim($contentTypeArray[0]);
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @return string
204 204
      * @throws InvalidMessageDateException
205 205
      */
206
-    private function findHeaders(){
206
+    private function findHeaders() {
207 207
         $body = $this->raw;
208 208
         while (($pos = strpos($body, "\r\n")) > 0) {
209 209
             $body = substr($body, $pos + 2);
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
     /**
220 220
      * Try to parse the subtype if any is present
221 221
      */
222
-    private function parseSubtype(){
222
+    private function parseSubtype() {
223 223
         $content_type = $this->header->get("content-type");
224
-        if (($pos = strpos($content_type, "/")) !== false){
224
+        if (($pos = strpos($content_type, "/")) !== false) {
225 225
             $this->subtype = substr($content_type, $pos + 1);
226 226
         }
227 227
     }
@@ -229,9 +229,9 @@  discard block
 block discarded – undo
229 229
     /**
230 230
      * Try to parse the disposition if any is present
231 231
      */
232
-    private function parseDisposition(){
232
+    private function parseDisposition() {
233 233
         $content_disposition = $this->header->get("content-disposition");
234
-        if($content_disposition !== null) {
234
+        if ($content_disposition !== null) {
235 235
             $this->ifdisposition = true;
236 236
             $this->disposition = $content_disposition;
237 237
         }
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
     /**
241 241
      * Try to parse the description if any is present
242 242
      */
243
-    private function parseDescription(){
243
+    private function parseDescription() {
244 244
         $content_description = $this->header->get("content-description");
245
-        if($content_description !== null) {
245
+        if ($content_description !== null) {
246 246
             $this->ifdescription = true;
247 247
             $this->description = $content_description;
248 248
         }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
     /**
252 252
      * Try to parse the encoding if any is present
253 253
      */
254
-    private function parseEncoding(){
254
+    private function parseEncoding() {
255 255
         $encoding = $this->header->get("content-transfer-encoding");
256
-        if($encoding !== null) {
256
+        if ($encoding !== null) {
257 257
             switch (strtolower($encoding)) {
258 258
                 case "quoted-printable":
259 259
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
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.