Completed
Push — master ( 872ca7...4d0bad )
by Malte
01:49
created
src/Support/Masks/MessageMask.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  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;
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function getCustomHTMLBody($callback = false) {
49 49
         $body = $this->getHtmlBody();
50
-        if($body === null) return null;
50
+        if ($body === null) return null;
51 51
 
52 52
         if ($callback !== false) {
53 53
             $aAttachment = $this->parent->getAttachments();
54 54
             $aAttachment->each(function($oAttachment) use(&$body, $callback) {
55 55
                 /** @var Attachment $oAttachment */
56
-                if(is_callable($callback)) {
56
+                if (is_callable($callback)) {
57 57
                     $body = $callback($body, $oAttachment);
58
-                }elseif(is_string($callback)) {
58
+                }elseif (is_string($callback)) {
59 59
                     call_user_func($callback, [$body, $oAttachment]);
60 60
                 }
61 61
             });
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      * @return string|null
72 72
      */
73 73
     public function getHTMLBodyWithEmbeddedBase64Images() {
74
-        return $this->getCustomHTMLBody(function($body, $oAttachment){
74
+        return $this->getCustomHTMLBody(function($body, $oAttachment) {
75 75
             /** @var \Webklex\PHPIMAP\Attachment $oAttachment */
76 76
             if ($oAttachment->id && $oAttachment->getImgSrc() != null) {
77 77
                 $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body);
Please login to merge, or discard this patch.
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/Message.php 1 patch
Spacing   +21 added lines, -21 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);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             } elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') {
467 467
                 $this->fetchAttachment($part);
468 468
             }
469
-        } else {
469
+        }else {
470 470
             $this->fetchAttachment($part);
471 471
         }
472 472
     }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
         if ($oAttachment->getName() !== null) {
483 483
             if ($oAttachment->getId() !== null) {
484 484
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
485
-            } else {
485
+            }else {
486 486
                 $this->attachments->push($oAttachment);
487 487
             }
488 488
         }
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 
600 600
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
601 601
             return @iconv($from, $to.'//IGNORE', $str);
602
-        } else {
602
+        }else {
603 603
             if (!$from) {
604 604
                 return mb_convert_encoding($str, $to);
605 605
             }
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
                     return EncodingAliases::get($parameter->value);
621 621
                 }
622 622
             }
623
-        }elseif (property_exists($structure, 'charset')){
623
+        }elseif (property_exists($structure, 'charset')) {
624 624
             return EncodingAliases::get($structure->charset);
625
-        }elseif (is_string($structure) === true){
625
+        }elseif (is_string($structure) === true) {
626 626
             return mb_detect_encoding($structure);
627 627
         }
628 628
 
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
      * @throws Exceptions\ConnectionFailedException
637 637
      * @throws Exceptions\FolderFetchingException
638 638
      */
639
-    public function getFolder(){
639
+    public function getFolder() {
640 640
         return $this->client->getFolder($this->folder_path);
641 641
     }
642 642
 
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
      */
714 714
     public function delete($expunge = true) {
715 715
         $status = $this->setFlag("Deleted");
716
-        if($expunge) $this->client->expunge();
716
+        if ($expunge) $this->client->expunge();
717 717
 
718 718
         $event = $this->getEvent("message", "deleted");
719 719
         $event::dispatch($this);
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
      */
733 733
     public function restore($expunge = true) {
734 734
         $status = $this->unsetFlag("Deleted");
735
-        if($expunge) $this->client->expunge();
735
+        if ($expunge) $this->client->expunge();
736 736
 
737 737
         $event = $this->getEvent("message", "restored");
738 738
         $event::dispatch($this);
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
      *
886 886
      * @return object|null
887 887
      */
888
-    public function getStructure(){
888
+    public function getStructure() {
889 889
         return $this->structure;
890 890
     }
891 891
 
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
      *
912 912
      * @return array
913 913
      */
914
-    public function getAttributes(){
914
+    public function getAttributes() {
915 915
         return array_merge($this->attributes, $this->header->getAttributes());
916 916
     }
917 917
 
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
      *
922 922
      * @return $this
923 923
      */
924
-    public function setMask($mask){
925
-        if(class_exists($mask)){
924
+    public function setMask($mask) {
925
+        if (class_exists($mask)) {
926 926
             $this->mask = $mask;
927 927
         }
928 928
 
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
      *
935 935
      * @return string
936 936
      */
937
-    public function getMask(){
937
+    public function getMask() {
938 938
         return $this->mask;
939 939
     }
940 940
 
@@ -945,9 +945,9 @@  discard block
 block discarded – undo
945 945
      * @return mixed
946 946
      * @throws MaskNotFoundException
947 947
      */
948
-    public function mask($mask = null){
948
+    public function mask($mask = null) {
949 949
         $mask = $mask !== null ? $mask : $this->mask;
950
-        if(class_exists($mask)){
950
+        if (class_exists($mask)) {
951 951
             return new $mask($this);
952 952
         }
953 953
 
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @throws InvalidMessageDateException
154 154
      */
155
-    protected function parse(){
155
+    protected function parse() {
156 156
         if ($this->header === null) {
157 157
             $body = $this->findHeaders();
158
-        }else{
158
+        }else {
159 159
             $body = $this->raw;
160 160
         }
161 161
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @return string
180 180
      * @throws InvalidMessageDateException
181 181
      */
182
-    private function findHeaders(){
182
+    private function findHeaders() {
183 183
         $body = $this->raw;
184 184
         while (($pos = strpos($body, "\r\n")) > 0) {
185 185
             $body = substr($body, $pos + 2);
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
     /**
196 196
      * Try to parse the subtype if any is present
197 197
      */
198
-    private function parseSubtype(){
198
+    private function parseSubtype() {
199 199
         $content_type = $this->header->get("content-type");
200
-        if (($pos = strpos($content_type, "/")) !== false){
200
+        if (($pos = strpos($content_type, "/")) !== false) {
201 201
             $this->subtype = substr($content_type, $pos + 1);
202 202
         }
203 203
     }
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
     /**
206 206
      * Try to parse the disposition if any is present
207 207
      */
208
-    private function parseDisposition(){
208
+    private function parseDisposition() {
209 209
         $content_disposition = $this->header->get("content-disposition");
210
-        if($content_disposition !== null) {
210
+        if ($content_disposition !== null) {
211 211
             $this->ifdisposition = true;
212 212
             $this->disposition = $content_disposition;
213 213
         }
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
     /**
217 217
      * Try to parse the description if any is present
218 218
      */
219
-    private function parseDescription(){
219
+    private function parseDescription() {
220 220
         $content_description = $this->header->get("content-description");
221
-        if($content_description !== null) {
221
+        if ($content_description !== null) {
222 222
             $this->ifdescription = true;
223 223
             $this->description = $content_description;
224 224
         }
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
     /**
228 228
      * Try to parse the encoding if any is present
229 229
      */
230
-    private function parseEncoding(){
230
+    private function parseEncoding() {
231 231
         $encoding = $this->header->get("content-transfer-encoding");
232
-        if($encoding !== null) {
232
+        if ($encoding !== null) {
233 233
             switch (strtolower($encoding)) {
234 234
                 case "quoted-printable":
235 235
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +38 added lines, -38 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
             }
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
         try {
337 337
             if ($this->authentication == "oauth") {
338 338
                 $this->connection->authenticate($this->username, $this->password);
339
-            }else{
339
+            }else {
340 340
                 $this->connection->login($this->username, $this->password);
341 341
             }
342 342
         } catch (\Exception $e) {
@@ -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/Attachment.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) {
230 230
             if ($this->part->ifdescription) {
231 231
                 $this->setName($this->part->description);
232
-            } else {
232
+            }else {
233 233
                 $this->setName($this->part->subtype);
234 234
             }
235 235
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     public function setName($name) {
256 256
         $decoder = $this->config['decoder']['attachment'];
257 257
         if ($name !== null) {
258
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
258
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
259 259
                 $this->name = \imap_utf8($name);
260
-            }else{
260
+            }else {
261 261
                 $this->name = mb_decode_mimeheader($name);
262 262
             }
263 263
         }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @return string|null
270 270
      */
271
-    public function getMimeType(){
271
+    public function getMimeType() {
272 272
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
273 273
     }
274 274
 
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * @return string|null
279 279
      */
280
-    public function getExtension(){
280
+    public function getExtension() {
281 281
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
282
-        if (class_exists($deprecated_guesser) !== false){
282
+        if (class_exists($deprecated_guesser) !== false) {
283 283
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
284 284
         }
285 285
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
      *
293 293
      * @return array
294 294
      */
295
-    public function getAttributes(){
295
+    public function getAttributes() {
296 296
         return $this->attributes;
297 297
     }
298 298
 
299 299
     /**
300 300
      * @return Message
301 301
      */
302
-    public function getMessage(){
302
+    public function getMessage() {
303 303
         return $this->oMessage;
304 304
     }
305 305
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
      *
310 310
      * @return $this
311 311
      */
312
-    public function setMask($mask){
313
-        if(class_exists($mask)){
312
+    public function setMask($mask) {
313
+        if (class_exists($mask)) {
314 314
             $this->mask = $mask;
315 315
         }
316 316
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      *
323 323
      * @return string
324 324
      */
325
-    public function getMask(){
325
+    public function getMask() {
326 326
         return $this->mask;
327 327
     }
328 328
 
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
      * @return mixed
334 334
      * @throws MaskNotFoundException
335 335
      */
336
-    public function mask($mask = null){
336
+    public function mask($mask = null) {
337 337
         $mask = $mask !== null ? $mask : $this->mask;
338
-        if(class_exists($mask)){
338
+        if (class_exists($mask)) {
339 339
             return new $mask($this);
340 340
         }
341 341
 
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) = explode("@", $email);
@@ -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.