Passed
Push — master ( 812ed7...044883 )
by Malte
02:04
created
src/Attachment.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $this->part_number = $part->part_number;
105 105
 
106 106
         $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask();
107
-        if($default_mask != null) {
107
+        if ($default_mask != null) {
108 108
             $this->mask = $default_mask;
109 109
         }
110 110
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
      * @throws MethodNotFoundException
122 122
      */
123 123
     public function __call($method, $arguments) {
124
-        if(strtolower(substr($method, 0, 3)) === 'get') {
124
+        if (strtolower(substr($method, 0, 3)) === 'get') {
125 125
             $name = Str::snake(substr($method, 3));
126 126
 
127
-            if(isset($this->attributes[$name])) {
127
+            if (isset($this->attributes[$name])) {
128 128
                 return $this->attributes[$name];
129 129
             }
130 130
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @return mixed|null
161 161
      */
162 162
     public function __get($name) {
163
-        if(isset($this->attributes[$name])) {
163
+        if (isset($this->attributes[$name])) {
164 164
             return $this->attributes[$name];
165 165
         }
166 166
 
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
             $this->setName($name);
224 224
         }elseif (($filename = $this->part->filename) !== null) {
225 225
             $this->setName($filename);
226
-        } else {
226
+        }else {
227 227
             $this->setName("undefined");
228 228
         }
229 229
 
230 230
         if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) {
231 231
             if ($this->part->ifdescription) {
232 232
                 $this->setName($this->part->description);
233
-            } else {
233
+            }else {
234 234
                 $this->setName($this->part->subtype);
235 235
             }
236 236
         }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     public function setName($name) {
257 257
         $decoder = $this->config['decoder']['attachment'];
258 258
         if ($name !== null) {
259
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
259
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
260 260
                 $this->name = \imap_utf8($name);
261
-            }else{
261
+            }else {
262 262
                 $this->name = mb_decode_mimeheader($name);
263 263
             }
264 264
         }
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      *
270 270
      * @return string|null
271 271
      */
272
-    public function getMimeType(){
272
+    public function getMimeType() {
273 273
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
274 274
     }
275 275
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
      *
279 279
      * @return string|null
280 280
      */
281
-    public function getExtension(){
281
+    public function getExtension() {
282 282
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
283
-        if (class_exists($deprecated_guesser) !== false){
283
+        if (class_exists($deprecated_guesser) !== false) {
284 284
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
285 285
         }
286 286
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
      *
294 294
      * @return array
295 295
      */
296
-    public function getAttributes(){
296
+    public function getAttributes() {
297 297
         return $this->attributes;
298 298
     }
299 299
 
300 300
     /**
301 301
      * @return Message
302 302
      */
303
-    public function getMessage(){
303
+    public function getMessage() {
304 304
         return $this->oMessage;
305 305
     }
306 306
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
      *
311 311
      * @return $this
312 312
      */
313
-    public function setMask($mask){
314
-        if(class_exists($mask)){
313
+    public function setMask($mask) {
314
+        if (class_exists($mask)) {
315 315
             $this->mask = $mask;
316 316
         }
317 317
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      *
324 324
      * @return string
325 325
      */
326
-    public function getMask(){
326
+    public function getMask() {
327 327
         return $this->mask;
328 328
     }
329 329
 
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
      * @return mixed
335 335
      * @throws MaskNotFoundException
336 336
      */
337
-    public function mask($mask = null){
337
+    public function mask($mask = null) {
338 338
         $mask = $mask !== null ? $mask : $this->mask;
339
-        if(class_exists($mask)){
339
+        if (class_exists($mask)) {
340 340
             return new $mask($this);
341 341
         }
342 342
 
Please login to merge, or discard this patch.
src/Structure.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      * @throws MessageContentFetchingException
78 78
      * @throws InvalidMessageDateException
79 79
      */
80
-    protected function parse(){
80
+    protected function parse() {
81 81
         $this->findContentType();
82 82
         $this->parts = $this->find_parts();
83 83
     }
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Determine the message content type
87 87
      */
88
-    public function findContentType(){
88
+    public function findContentType() {
89 89
 
90 90
         $content_type = $this->header->get("content-type");
91 91
         $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type;
92
-        if(stripos($content_type, 'multipart') === 0) {
92
+        if (stripos($content_type, 'multipart') === 0) {
93 93
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
94
-        }else{
94
+        }else {
95 95
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
96 96
         }
97 97
     }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     /**
100 100
      * Determine the message content type
101 101
      */
102
-    public function getBoundary(){
102
+    public function getBoundary() {
103 103
         $boundary = $this->header->find("/boundary\=\"?(.*)\"?/");
104 104
         return str_replace('"', '', $boundary);
105 105
     }
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
      * @throws MessageContentFetchingException
112 112
      * @throws InvalidMessageDateException
113 113
      */
114
-    public function find_parts(){
115
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
-            if (($boundary = $this->getBoundary()) === null)  {
114
+    public function find_parts() {
115
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
116
+            if (($boundary = $this->getBoundary()) === null) {
117 117
                 throw new MessageContentFetchingException("no content found", 0);
118 118
             }
119 119
 
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
             ];
123 123
 
124 124
             if (preg_match("/boundary\=\"?(.*)\"?/", $this->raw, $match) == 1) {
125
-                if(is_array($match[1])){
126
-                    foreach($match[1] as $matched){
125
+                if (is_array($match[1])) {
126
+                    foreach ($match[1] as $matched) {
127 127
                         $boundaries[] = str_replace('"', '', $matched);
128 128
                     }
129
-                }else{
130
-                    if(!empty($match[1])) {
129
+                }else {
130
+                    if (!empty($match[1])) {
131 131
                         $boundaries[] = str_replace('"', '', $match[1]);
132 132
                     }
133 133
                 }
134 134
             }
135 135
 
136
-            $raw_parts = explode( $boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw) );
136
+            $raw_parts = explode($boundaries[0], str_replace($boundaries, $boundaries[0], $this->raw));
137 137
             $parts = [];
138 138
             $part_number = 0;
139
-            foreach($raw_parts as $part) {
139
+            foreach ($raw_parts as $part) {
140 140
                 $part = trim(rtrim($part));
141 141
                 if ($part !== "--") {
142 142
                     $parts[] = new Part($part, null, $part_number);
Please login to merge, or discard this patch.
src/Query/WhereQuery.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -76,18 +76,18 @@  discard block
 block discarded – undo
76 76
 
77 77
         $name = Str::camel($name);
78 78
 
79
-        if(strtolower(substr($name, 0, 3)) === 'not') {
79
+        if (strtolower(substr($name, 0, 3)) === 'not') {
80 80
             $that = $that->whereNot();
81 81
             $name = substr($name, 3);
82 82
         }
83 83
 
84
-        if (strpos(strtolower($name), "where") === false){
84
+        if (strpos(strtolower($name), "where") === false) {
85 85
             $method = 'where'.ucfirst($name);
86
-        }else{
86
+        }else {
87 87
             $method = lcfirst($name);
88 88
         }
89 89
 
90
-        if(method_exists($this, $method) === true){
90
+        if (method_exists($this, $method) === true) {
91 91
             return call_user_func_array([$that, $method], $arguments);
92 92
         }
93 93
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if (substr($criteria, 0, 7) === "CUSTOM ") {
107 107
             return substr($criteria, 7);
108 108
         }
109
-        if(in_array($criteria, $this->available_criteria) === false) {
109
+        if (in_array($criteria, $this->available_criteria) === false) {
110 110
             throw new InvalidWhereQueryCriteriaException();
111 111
         }
112 112
 
@@ -121,20 +121,20 @@  discard block
 block discarded – undo
121 121
      * @throws InvalidWhereQueryCriteriaException
122 122
      */
123 123
     public function where($criteria, $value = null) {
124
-        if(is_array($criteria)){
125
-            foreach($criteria as $key => $value){
126
-                if(is_numeric($key)){
124
+        if (is_array($criteria)) {
125
+            foreach ($criteria as $key => $value) {
126
+                if (is_numeric($key)) {
127 127
                     return $this->where($value);
128 128
                 }
129 129
                 return $this->where($key, $value);
130 130
             }
131
-        }else{
131
+        }else {
132 132
             $criteria = $this->validate_criteria($criteria);
133 133
             $value = $this->parse_value($value);
134 134
 
135
-            if($value === null || $value === ''){
135
+            if ($value === null || $value === '') {
136 136
                 $this->query->push([$criteria]);
137
-            }else{
137
+            }else {
138 138
                 $this->query->push([$criteria, $value]);
139 139
             }
140 140
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function orWhere(\Closure $closure = null) {
151 151
         $this->query->push(['OR']);
152
-        if($closure !== null) $closure($this);
152
+        if ($closure !== null) $closure($this);
153 153
 
154 154
         return $this;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function andWhere(\Closure $closure = null) {
163 163
         $this->query->push(['AND']);
164
-        if($closure !== null) $closure($this);
164
+        if ($closure !== null) $closure($this);
165 165
 
166 166
         return $this;
167 167
     }
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      * @return WhereQuery
402 402
      * @throws InvalidWhereQueryCriteriaException
403 403
      */
404
-    public function whereNoXSpam(){
404
+    public function whereNoXSpam() {
405 405
         return $this->where("CUSTOM X-Spam-Flag NO");
406 406
     }
407 407
 
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
      * @return WhereQuery
410 410
      * @throws InvalidWhereQueryCriteriaException
411 411
      */
412
-    public function whereIsXSpam(){
412
+    public function whereIsXSpam() {
413 413
         return $this->where("CUSTOM X-Spam-Flag YES");
414 414
     }
415 415
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @return WhereQuery
422 422
      * @throws InvalidWhereQueryCriteriaException
423 423
      */
424
-    public function whereHeader($header, $value){
424
+    public function whereHeader($header, $value) {
425 425
         return $this->where("CUSTOM HEADER $header $value");
426 426
     }
427 427
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
      * @return WhereQuery
433 433
      * @throws InvalidWhereQueryCriteriaException
434 434
      */
435
-    public function whereMessageId($messageId){
435
+    public function whereMessageId($messageId) {
436 436
         return $this->whereHeader("Message-ID", $messageId);
437 437
     }
438 438
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
      * @return WhereQuery
444 444
      * @throws InvalidWhereQueryCriteriaException
445 445
      */
446
-    public function whereInReplyTo($messageId){
446
+    public function whereInReplyTo($messageId) {
447 447
         return $this->whereHeader("In-Reply-To", $messageId);
448 448
     }
449 449
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
      * @return WhereQuery
454 454
      * @throws InvalidWhereQueryCriteriaException
455 455
      */
456
-    public function whereLanguage($country_code){
456
+    public function whereLanguage($country_code) {
457 457
         return $this->where("Content-Language $country_code");
458 458
     }
459 459
 }
460 460
\ No newline at end of file
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
      *
160 160
      * @throws InvalidMessageDateException
161 161
      */
162
-    protected function parse(){
162
+    protected function parse() {
163 163
         if ($this->header === null) {
164 164
             $body = $this->findHeaders();
165
-        }else{
165
+        }else {
166 166
             $body = $this->raw;
167 167
         }
168 168
 
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
         $this->name = $this->header->get("name");
175 175
         $this->filename = $this->header->get("filename");
176 176
 
177
-        if(!empty($this->header->get("id"))) {
177
+        if (!empty($this->header->get("id"))) {
178 178
             $this->id = $this->header->get("id");
179
-        } else if(!empty($this->header->get("x-attachment-id"))){
179
+        }else if (!empty($this->header->get("x-attachment-id"))) {
180 180
             $this->id = $this->header->get("x-attachment-id");
181
-        } else if(!empty($this->header->get("content-id"))){
181
+        }else if (!empty($this->header->get("content-id"))) {
182 182
             $this->id = strtr($this->header->get("content-id"), [
183 183
                 '<' => '',
184 184
                 '>' => ''
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $content_types = $this->header->get("content-type");
189
-        if(!empty($content_types)){
189
+        if (!empty($content_types)) {
190 190
             $this->subtype = $this->parseSubtype($content_types);
191 191
             $content_type = $content_types;
192 192
             if (is_array($content_types)) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @return string
208 208
      * @throws InvalidMessageDateException
209 209
      */
210
-    private function findHeaders(){
210
+    private function findHeaders() {
211 211
         $body = $this->raw;
212 212
         while (($pos = strpos($body, "\r\n")) > 0) {
213 213
             $body = substr($body, $pos + 2);
@@ -226,16 +226,16 @@  discard block
 block discarded – undo
226 226
      *
227 227
      * @return string
228 228
      */
229
-    private function parseSubtype($content_type){
229
+    private function parseSubtype($content_type) {
230 230
         if (is_array($content_type)) {
231
-            foreach ($content_type as $part){
232
-                if ((strpos($part, "/")) !== false){
231
+            foreach ($content_type as $part) {
232
+                if ((strpos($part, "/")) !== false) {
233 233
                     return $this->parseSubtype($part);
234 234
                 }
235 235
             }
236 236
             return null;
237 237
         }
238
-        if (($pos = strpos($content_type, "/")) !== false){
238
+        if (($pos = strpos($content_type, "/")) !== false) {
239 239
             return substr($content_type, $pos + 1);
240 240
         }
241 241
         return null;
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
     /**
245 245
      * Try to parse the disposition if any is present
246 246
      */
247
-    private function parseDisposition(){
247
+    private function parseDisposition() {
248 248
         $content_disposition = $this->header->get("content-disposition");
249
-        if($content_disposition !== null) {
249
+        if ($content_disposition !== null) {
250 250
             $this->ifdisposition = true;
251 251
             $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition;
252 252
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     /**
256 256
      * Try to parse the description if any is present
257 257
      */
258
-    private function parseDescription(){
258
+    private function parseDescription() {
259 259
         $content_description = $this->header->get("content-description");
260
-        if($content_description !== null) {
260
+        if ($content_description !== null) {
261 261
             $this->ifdescription = true;
262 262
             $this->description = $content_description;
263 263
         }
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Try to parse the encoding if any is present
268 268
      */
269
-    private function parseEncoding(){
269
+    private function parseEncoding() {
270 270
         $encoding = $this->header->get("content-transfer-encoding");
271
-        if($encoding !== null) {
271
+        if ($encoding !== null) {
272 272
             switch (strtolower($encoding)) {
273 273
                 case "quoted-printable":
274 274
                     $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE;
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
302
-        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])) ) ) {
301
+    public function isAttachment() {
302
+        if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition) || !in_array(strtolower($this->disposition), ['attachment', 'inline'])))) {
303 303
             if (($this->subtype == null || in_array((strtolower($this->subtype)), ["plain", "csv", "html"])) && $this->filename == null && $this->name == null) {
304 304
                 return false;
305 305
             }
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      * @throws MethodNotFoundException
74 74
      */
75 75
     public function __call($method, $arguments) {
76
-        if(strtolower(substr($method, 0, 3)) === 'get') {
76
+        if (strtolower(substr($method, 0, 3)) === 'get') {
77 77
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
78 78
 
79
-            if(in_array($name, array_keys($this->attributes))) {
79
+            if (in_array($name, array_keys($this->attributes))) {
80 80
                 return $this->attributes[$name];
81 81
             }
82 82
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return mixed|null
103 103
      */
104 104
     public function get($name) {
105
-        if(isset($this->attributes[$name])) {
105
+        if (isset($this->attributes[$name])) {
106 106
             return $this->attributes[$name];
107 107
         }
108 108
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function find($pattern) {
119 119
         if (preg_match_all($pattern, $this->raw, $matches)) {
120 120
             if (isset($matches[1])) {
121
-                if(count($matches[1]) > 0) {
121
+                if (count($matches[1]) > 0) {
122 122
                     return $matches[1][0];
123 123
                 }
124 124
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @throws InvalidMessageDateException
133 133
      */
134
-    protected function parse(){
134
+    protected function parse() {
135 135
         $header = $this->rfc822_parse_headers($this->raw);
136 136
 
137 137
         $this->extractAddresses($header);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
         $this->parseDate($header);
153 153
         foreach ($header as $key => $value) {
154 154
             $key = trim(rtrim(strtolower($key)));
155
-            if(!isset($this->attributes[$key])){
155
+            if (!isset($this->attributes[$key])) {
156 156
                 $this->attributes[$key] = $value;
157 157
             }
158 158
         }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      *
169 169
      * @return object
170 170
      */
171
-    public function rfc822_parse_headers($raw_headers){
171
+    public function rfc822_parse_headers($raw_headers) {
172 172
         $headers = [];
173 173
         $imap_headers = [];
174 174
         if (extension_loaded('imap')) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
         $lines = explode("\r\n", $raw_headers);
179 179
         $prev_header = null;
180
-        foreach($lines as $line) {
180
+        foreach ($lines as $line) {
181 181
             if (substr($line, 0, 1) === "\n") {
182 182
                 $line = substr($line, 1);
183 183
             }
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
                     }
198 198
                     if (is_array($headers[$prev_header])) {
199 199
                         $headers[$prev_header][] = $line;
200
-                    }else{
200
+                    }else {
201 201
                         $headers[$prev_header] .= $line;
202 202
                     }
203 203
                 }
204
-            }else{
204
+            }else {
205 205
                 if (($pos = strpos($line, ":")) > 0) {
206 206
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
207 207
                     $value = trim(rtrim(substr($line, $pos + 1)));
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
             }
212 212
         }
213 213
 
214
-        foreach($headers as $key => $values) {
214
+        foreach ($headers as $key => $values) {
215 215
             if (isset($imap_headers[$key])) continue;
216 216
             $value = null;
217
-            switch($key){
217
+            switch ($key) {
218 218
                 case 'from':
219 219
                 case 'to':
220 220
                 case 'cc':
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                     break;
230 230
                 default:
231 231
                     if (is_array($values)) {
232
-                        foreach($values as $k => $v) {
232
+                        foreach ($values as $k => $v) {
233 233
                             if ($v == "") {
234 234
                                 unset($values[$k]);
235 235
                             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                             $value = implode(" ", $values);
242 242
                         } elseif ($available_values > 2) {
243 243
                             $value = array_values($values);
244
-                        } else {
244
+                        }else {
245 245
                             $value = "";
246 246
                         }
247 247
                     }
@@ -261,12 +261,12 @@  discard block
 block discarded – undo
261 261
      * @return array The decoded elements are returned in an array of objects, where each
262 262
      * object has two properties, charset and text.
263 263
      */
264
-    public function mime_header_decode($text){
264
+    public function mime_header_decode($text) {
265 265
         if (extension_loaded('imap')) {
266 266
             return \imap_mime_header_decode($text);
267 267
         }
268 268
         $charset = $this->getEncoding($text);
269
-        return [(object)[
269
+        return [(object) [
270 270
             "charset" => $charset,
271 271
             "text" => $this->convertEncoding($text, $charset)
272 272
         ]];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         try {
321 321
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
322 322
                 return iconv($from, $to, $str);
323
-            } else {
323
+            }else {
324 324
                 if (!$from) {
325 325
                     return mb_convert_encoding($str, $to);
326 326
                 }
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             if (strstr($from, '-')) {
331 331
                 $from = str_replace('-', '', $from);
332 332
                 return $this->convertEncoding($str, $from, $to);
333
-            } else {
333
+            }else {
334 334
                 return $str;
335 335
             }
336 336
         }
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
             }
352 352
         }elseif (property_exists($structure, 'charset')) {
353 353
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
354
-        }elseif (is_string($structure) === true){
354
+        }elseif (is_string($structure) === true) {
355 355
             return mb_detect_encoding($structure);
356 356
         }
357 357
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         $decoder = $this->config['decoder']['message'];
370 370
 
371 371
         if ($value !== null) {
372
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
372
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
373 373
                 $value = \imap_utf8($value);
374 374
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
375 375
                     $value = mb_decode_mimeheader($value);
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
                 if ($this->notDecoded($original_value, $value)) {
378 378
                     $decoded_value = $this->mime_header_decode($value);
379 379
                     if (count($decoded_value) > 0) {
380
-                        if(property_exists($decoded_value[0], "text")) {
380
+                        if (property_exists($decoded_value[0], "text")) {
381 381
                             $value = $decoded_value[0]->text;
382 382
                         }
383 383
                     }
384 384
                 }
385
-            }elseif($decoder === 'iconv') {
385
+            }elseif ($decoder === 'iconv') {
386 386
                 $value = iconv_mime_decode($value);
387
-            }else{
387
+            }else {
388 388
                 $value = mb_decode_mimeheader($value);
389 389
             }
390 390
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
      * Try to extract the priority from a given raw header string
405 405
      */
406 406
     private function findPriority() {
407
-        if(($priority = $this->get("x-priority")) === null) return;
408
-        switch($priority){
407
+        if (($priority = $this->get("x-priority")) === null) return;
408
+        switch ($priority) {
409 409
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
410 410
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
411 411
                 break;
@@ -437,12 +437,12 @@  discard block
 block discarded – undo
437 437
      */
438 438
     private function decodeAddresses($values) {
439 439
         $addresses = [];
440
-        foreach($values as $address) {
440
+        foreach ($values as $address) {
441 441
             if (preg_match(
442 442
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
443 443
                 $address,
444 444
                 $matches
445
-            )){
445
+            )) {
446 446
                 $name = trim(rtrim($matches["name"]));
447 447
                 $email = trim(rtrim($matches["email"]));
448 448
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      * @param object $header
462 462
      */
463 463
     private function extractAddresses($header) {
464
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
464
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
465 465
             if (property_exists($header, $key)) {
466 466
                 $this->attributes[$key] = $this->parseAddresses($header->$key);
467 467
             }
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
             }
493 493
             if (!property_exists($address, 'personal')) {
494 494
                 $address->personal = false;
495
-            } else {
495
+            }else {
496 496
                 $personalParts = $this->mime_header_decode($address->personal);
497 497
 
498
-                if(is_array($personalParts)) {
498
+                if (is_array($personalParts)) {
499 499
                     $address->personal = '';
500 500
                     foreach ($personalParts as $p) {
501 501
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
     /**
516 516
      * Search and extract potential header extensions
517 517
      */
518
-    private function extractHeaderExtensions(){
518
+    private function extractHeaderExtensions() {
519 519
         foreach ($this->attributes as $key => $value) {
520 520
             // Only parse strings and don't parse any attributes like the user-agent
521 521
             if (is_string($value) === true && in_array($key, ["user-agent"]) === false) {
522
-                if (($pos = strpos($value, ";")) !== false){
522
+                if (($pos = strpos($value, ";")) !== false) {
523 523
                     $original = substr($value, 0, $pos);
524 524
                     $this->attributes[$key] = trim(rtrim($original));
525 525
 
526 526
                     // Get all potential extensions
527 527
                     $extensions = explode(";", substr($value, $pos + 1));
528
-                    foreach($extensions as $extension) {
529
-                        if (($pos = strpos($extension, "=")) !== false){
528
+                    foreach ($extensions as $extension) {
529
+                        if (($pos = strpos($extension, "=")) !== false) {
530 530
                             $key = substr($extension, 0, $pos);
531 531
                             $key = trim(rtrim(strtolower($key)));
532 532
 
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             $parsed_date = null;
570 570
             $date = $header->date;
571 571
 
572
-            if(preg_match('/\+0580/', $date)) {
572
+            if (preg_match('/\+0580/', $date)) {
573 573
                 $date = str_replace('+0580', '+0530', $date);
574 574
             }
575 575
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
                         $date = trim(array_pop($array));
593 593
                         break;
594 594
                 }
595
-                try{
595
+                try {
596 596
                     $parsed_date = Carbon::parse($date);
597 597
                 } catch (\Exception $_e) {
598 598
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.
src/Query/Query.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     public function __construct(Client $client, $charset = 'UTF-8') {
77 77
         $this->setClient($client);
78 78
 
79
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
79
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
80 80
 
81 81
         if (ClientManager::get('options.fetch_order') === 'desc') {
82 82
             $this->fetch_order = 'desc';
83
-        } else {
83
+        }else {
84 84
             $this->fetch_order = 'asc';
85 85
         }
86 86
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     /**
95 95
      * Instance boot method for additional functionality
96 96
      */
97
-    protected function boot(){}
97
+    protected function boot() {}
98 98
 
99 99
     /**
100 100
      * Parse a given value
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
      *
103 103
      * @return string
104 104
      */
105
-    protected function parse_value($value){
106
-        switch(true){
105
+    protected function parse_value($value) {
106
+        switch (true) {
107 107
             case $value instanceof \Carbon\Carbon:
108 108
                 $value = $value->format($this->date_format);
109 109
                 break;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @throws MessageSearchValidationException
121 121
      */
122 122
     protected function parse_date($date) {
123
-        if($date instanceof \Carbon\Carbon) return $date;
123
+        if ($date instanceof \Carbon\Carbon) return $date;
124 124
 
125 125
         try {
126 126
             $date = Carbon::parse($date);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @return Collection
160 160
      * @throws GetMessagesFailedException
161 161
      */
162
-    protected function search(){
162
+    protected function search() {
163 163
         $this->generate_query();
164 164
 
165 165
         try {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
                     $raw_flag = isset($raw_flags[$msgno]) ? $raw_flags[$msgno] : [];
228 228
 
229 229
                     $message = Message::make($msgno, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions());
230
-                    switch ($message_key){
230
+                    switch ($message_key) {
231 231
                         case 'number':
232 232
                             $message_key = $message->getMessageNo();
233 233
                             break;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
             return $messages;
248 248
         } catch (\Exception $e) {
249
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
249
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
250 250
         }
251 251
     }
252 252
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      * @throws MessageHeaderFetchingException
264 264
      * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException
265 265
      */
266
-    public function getMessage($msgno, $msglist = null){
266
+    public function getMessage($msgno, $msglist = null) {
267 267
         return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags());
268 268
     }
269 269
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
      * @return LengthAwarePaginator
277 277
      * @throws GetMessagesFailedException
278 278
      */
279
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
279
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
280 280
         if (
281 281
                $page === null
282 282
             && isset($_GET[$page_name])
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
         $this->query->each(function($statement) use(&$query) {
303 303
             if (count($statement) == 1) {
304 304
                 $query .= $statement[0];
305
-            } else {
306
-                if($statement[1] === null){
305
+            }else {
306
+                if ($statement[1] === null) {
307 307
                     $query .= $statement[0];
308
-                }else{
308
+                }else {
309 309
                     $query .= $statement[0].' "'.$statement[1].'"';
310 310
                 }
311 311
             }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      * @return $this
336 336
      */
337 337
     public function limit($limit, $page = 1) {
338
-        if($page >= 1) $this->page = $page;
338
+        if ($page >= 1) $this->page = $page;
339 339
         $this->limit = $limit;
340 340
 
341 341
         return $this;
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) {
196 196
 
197 197
         $default_mask = $client->getDefaultMessageMask();
198
-        if($default_mask != null) {
198
+        if ($default_mask != null) {
199 199
             $this->mask = $default_mask;
200 200
         }
201 201
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -249,13 +249,13 @@  discard block
 block discarded – undo
249 249
      * @throws MessageContentFetchingException
250 250
      * @throws \ReflectionException
251 251
      */
252
-    public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null){
252
+    public static function make($msgn, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null) {
253 253
         $reflection = new \ReflectionClass(self::class);
254 254
         /** @var self $instance */
255 255
         $instance = $reflection->newInstanceWithoutConstructor();
256 256
 
257 257
         $default_mask = $client->getDefaultMessageMask();
258
-        if($default_mask != null) {
258
+        if ($default_mask != null) {
259 259
             $instance->setMask($default_mask);
260 260
         }
261 261
         $instance->setEvents([
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
      * @throws MethodNotFoundException
288 288
      */
289 289
     public function __call($method, $arguments) {
290
-        if(strtolower(substr($method, 0, 3)) === 'get') {
290
+        if (strtolower(substr($method, 0, 3)) === 'get') {
291 291
             $name = Str::snake(substr($method, 3));
292 292
             return $this->get($name);
293 293
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
294 294
             $name = Str::snake(substr($method, 3));
295 295
 
296
-            if(in_array($name, array_keys($this->attributes))) {
296
+            if (in_array($name, array_keys($this->attributes))) {
297 297
                 $this->attributes[$name] = array_pop($arguments);
298 298
 
299 299
                 return $this->attributes[$name];
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      * @return mixed|null
335 335
      */
336 336
     public function get($name) {
337
-        if(isset($this->attributes[$name])) {
337
+        if (isset($this->attributes[$name])) {
338 338
             return $this->attributes[$name];
339 339
         }
340 340
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      *
408 408
      * @throws InvalidMessageDateException
409 409
      */
410
-    public function parseRawHeader($raw_header){
410
+    public function parseRawHeader($raw_header) {
411 411
         $this->header = new Header($raw_header);
412 412
     }
413 413
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
     public function parseRawFlags($raw_flags) {
419 419
         $this->flags = FlagCollection::make([]);
420 420
 
421
-        foreach($raw_flags as $flag) {
422
-            if (strpos($flag, "\\") === 0){
421
+        foreach ($raw_flags as $flag) {
422
+            if (strpos($flag, "\\") === 0) {
423 423
                 $flag = substr($flag, 1);
424 424
             }
425 425
             $flag_key = strtolower($flag);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 
521 521
         if ($part->isAttachment()) {
522 522
             $this->fetchAttachment($part);
523
-        }else{
523
+        }else {
524 524
             $encoding = $this->getEncoding($part);
525 525
 
526 526
             $content = $this->decodeString($part->content, $part->encoding);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
559 559
             if ($oAttachment->getId() !== null) {
560 560
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
561
-            } else {
561
+            }else {
562 562
                 $this->attachments->push($oAttachment);
563 563
             }
564 564
         }
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 
676 676
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
677 677
             return @iconv($from, $to.'//IGNORE', $str);
678
-        } else {
678
+        }else {
679 679
             if (!$from) {
680 680
                 return mb_convert_encoding($str, $to);
681 681
             }
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
                     return EncodingAliases::get($parameter->value);
697 697
                 }
698 698
             }
699
-        }elseif (property_exists($structure, 'charset')){
699
+        }elseif (property_exists($structure, 'charset')) {
700 700
             return EncodingAliases::get($structure->charset);
701
-        }elseif (is_string($structure) === true){
701
+        }elseif (is_string($structure) === true) {
702 702
             return mb_detect_encoding($structure);
703 703
         }
704 704
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
      * @throws Exceptions\ConnectionFailedException
713 713
      * @throws Exceptions\FolderFetchingException
714 714
      */
715
-    public function getFolder(){
715
+    public function getFolder() {
716 716
         return $this->client->getFolder($this->folder_path);
717 717
     }
718 718
 
@@ -727,13 +727,13 @@  discard block
 block discarded – undo
727 727
      * @throws Exceptions\FolderFetchingException
728 728
      * @throws Exceptions\GetMessagesFailedException
729 729
      */
730
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
730
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
731 731
         $thread = $thread ? $thread : MessageCollection::make([]);
732
-        $folder = $folder ? $folder :  $this->getFolder();
732
+        $folder = $folder ? $folder : $this->getFolder();
733 733
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
734 734
 
735 735
         /** @var Message $message */
736
-        foreach($thread as $message) {
736
+        foreach ($thread as $message) {
737 737
             if ($message->message_id == $this->message_id) {
738 738
                 return $thread;
739 739
             }
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
         });
755 755
 
756 756
         if (is_array($this->in_reply_to)) {
757
-            foreach($this->in_reply_to as $in_reply_to) {
757
+            foreach ($this->in_reply_to as $in_reply_to) {
758 758
                 $folder->query()->messageId($in_reply_to)
759 759
                     ->setFetchBody($this->getFetchBodyOption())
760 760
                     ->leaveUnread()->get()->each(function($message) use(&$thread, $folder, $sent_folder){
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 
800 800
             $this->client->openFolder($this->folder_path);
801 801
             if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) {
802
-                if($expunge) $this->client->expunge();
802
+                if ($expunge) $this->client->expunge();
803 803
 
804 804
                 $this->client->openFolder($folder->path);
805 805
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 
842 842
             $this->client->openFolder($this->folder_path);
843 843
             if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) {
844
-                if($expunge) $this->client->expunge();
844
+                if ($expunge) $this->client->expunge();
845 845
 
846 846
                 $this->client->openFolder($folder->path);
847 847
                 $message_num = $this->client->getConnection()->getMessageNumber($next_uid);
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
      */
869 869
     public function delete($expunge = true) {
870 870
         $status = $this->setFlag("Deleted");
871
-        if($expunge) $this->client->expunge();
871
+        if ($expunge) $this->client->expunge();
872 872
 
873 873
         $event = $this->getEvent("message", "deleted");
874 874
         $event::dispatch($this);
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
      */
888 888
     public function restore($expunge = true) {
889 889
         $status = $this->unsetFlag("Deleted");
890
-        if($expunge) $this->client->expunge();
890
+        if ($expunge) $this->client->expunge();
891 891
 
892 892
         $event = $this->getEvent("message", "restored");
893 893
         $event::dispatch($this);
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
      *
1041 1041
      * @return object|null
1042 1042
      */
1043
-    public function getStructure(){
1043
+    public function getStructure() {
1044 1044
         return $this->structure;
1045 1045
     }
1046 1046
 
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      *
1067 1067
      * @return array
1068 1068
      */
1069
-    public function getAttributes(){
1069
+    public function getAttributes() {
1070 1070
         return array_merge($this->attributes, $this->header->getAttributes());
1071 1071
     }
1072 1072
 
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
      *
1077 1077
      * @return $this
1078 1078
      */
1079
-    public function setMask($mask){
1080
-        if(class_exists($mask)){
1079
+    public function setMask($mask) {
1080
+        if (class_exists($mask)) {
1081 1081
             $this->mask = $mask;
1082 1082
         }
1083 1083
 
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
      *
1090 1090
      * @return string
1091 1091
      */
1092
-    public function getMask(){
1092
+    public function getMask() {
1093 1093
         return $this->mask;
1094 1094
     }
1095 1095
 
@@ -1100,9 +1100,9 @@  discard block
 block discarded – undo
1100 1100
      * @return mixed
1101 1101
      * @throws MaskNotFoundException
1102 1102
      */
1103
-    public function mask($mask = null){
1103
+    public function mask($mask = null) {
1104 1104
         $mask = $mask !== null ? $mask : $this->mask;
1105
-        if(class_exists($mask)){
1105
+        if (class_exists($mask)) {
1106 1106
             return new $mask($this);
1107 1107
         }
1108 1108
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
      *
1116 1116
      * @return $this
1117 1117
      */
1118
-    public function setFolderPath($folder_path){
1118
+    public function setFolderPath($folder_path) {
1119 1119
         $this->folder_path = $folder_path;
1120 1120
 
1121 1121
         return $this;
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
      *
1128 1128
      * @return $this
1129 1129
      */
1130
-    public function setConfig($config){
1130
+    public function setConfig($config) {
1131 1131
         $this->config = $config;
1132 1132
 
1133 1133
         return $this;
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
      *
1140 1140
      * @return $this
1141 1141
      */
1142
-    public function setAttachments($attachments){
1142
+    public function setAttachments($attachments) {
1143 1143
         $this->attachments = $attachments;
1144 1144
 
1145 1145
         return $this;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
      *
1152 1152
      * @return $this
1153 1153
      */
1154
-    public function setFlags($flags){
1154
+    public function setFlags($flags) {
1155 1155
         $this->flags = $flags;
1156 1156
 
1157 1157
         return $this;
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
      * @throws Exceptions\ConnectionFailedException
1165 1165
      * @return $this
1166 1166
      */
1167
-    public function setClient($client){
1167
+    public function setClient($client) {
1168 1168
         $this->client = $client;
1169 1169
         $this->client->openFolder($this->folder_path);
1170 1170
 
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
      * @throws Exceptions\RuntimeException
1181 1181
      * @return $this
1182 1182
      */
1183
-    public function setMsgn($msgn, $msglist = null){
1183
+    public function setMsgn($msgn, $msglist = null) {
1184 1184
         $this->msgn = $msgn;
1185 1185
         $this->msglist = $msglist;
1186 1186
 
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
             throw new AuthFailedException($message);
86 86
         }
87 87
 
88
-        if(!$this->stream) {
88
+        if (!$this->stream) {
89 89
             $errors = \imap_errors();
90 90
             $message = implode("; ", (is_array($errors) ? $errors : array()));
91 91
             throw new AuthFailedException($message);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         if (!$this->cert_validation) {
117 117
             $address .= '/novalidate-cert';
118 118
         }
119
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
119
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
120 120
             $address .= '/'.$this->encryption;
121 121
         } elseif ($this->encryption === "starttls") {
122 122
             $address .= '/tls';
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      *
145 145
      * @return bool
146 146
      */
147
-    public function connected(){
147
+    public function connected() {
148 148
         return !$this->stream;
149 149
     }
150 150
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @return array
216 216
      */
217
-    public function headers($uids, $rfc = "RFC822"){
217
+    public function headers($uids, $rfc = "RFC822") {
218 218
         $result = [];
219 219
         $uids = is_array($uids) ? $uids : [$uids];
220 220
         foreach ($uids as $uid) {
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @return array
231 231
      */
232
-    public function flags($uids){
232
+    public function flags($uids) {
233 233
         $result = [];
234 234
         $uids = is_array($uids) ? $uids : [$uids];
235 235
         foreach ($uids as $uid) {
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
             $flags = [];
238 238
             if (is_array($raw_flags) && isset($raw_flags[0])) {
239 239
                 $raw_flags = (array) $raw_flags[0];
240
-                foreach($raw_flags as $flag => $value) {
241
-                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){
240
+                foreach ($raw_flags as $flag => $value) {
241
+                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) {
242 242
                         $flags[] = "\\".ucfirst($flag);
243 243
                     }
244 244
                 }
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         if ($id === null) {
260 260
             $overview = $this->overview("1:*");
261 261
             $uids = [];
262
-            foreach($overview as $set){
262
+            foreach ($overview as $set) {
263 263
                 $uids[$set->msgno] = $set->uid;
264 264
             }
265 265
             return $uids;
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
         $result = [];
300 300
 
301 301
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
302
-        if(is_array($items)){
302
+        if (is_array($items)) {
303 303
             foreach ($items as $item) {
304 304
                 $name = $this->decodeFolderName($item->name);
305 305
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
306 306
             }
307
-        }else{
307
+        }else {
308 308
             throw new RuntimeException(\imap_last_error());
309 309
         }
310 310
 
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true) {
326 326
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
327 327
 
328
-        if ($mode == "+"){
328
+        if ($mode == "+") {
329 329
             $status = \imap_setflag_full($this->stream, $from, $flag, IMAP::NIL);
330
-        }else{
330
+        }else {
331 331
             $status = \imap_clearflag_full($this->stream, $from, $flag, IMAP::NIL);
332 332
         }
333 333
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
      */
350 350
     public function appendMessage($folder, $message, $flags = null, $date = null) {
351 351
         if ($date != null) {
352
-            if ($date instanceof \Carbon\Carbon){
352
+            if ($date instanceof \Carbon\Carbon) {
353 353
                 $date = $date->format('d-M-Y H:i:s O');
354 354
             }
355 355
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
     /**
485 485
      * Enable the debug mode
486 486
      */
487
-    public function enableDebug(){
487
+    public function enableDebug() {
488 488
         $this->debug = true;
489 489
     }
490 490
 
491 491
     /**
492 492
      * Disable the debug mode
493 493
      */
494
-    public function disableDebug(){
494
+    public function disableDebug() {
495 495
         $this->debug = false;
496 496
     }
497 497
 
Please login to merge, or discard this patch.
src/Folder.php 1 patch
Spacing   +14 added lines, -14 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");
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @return array
249 249
      * @throws ConnectionFailedException
250 250
      */
251
-    public function overview($sequence = null){
251
+    public function overview($sequence = null) {
252 252
         $this->client->openFolder($this->path);
253 253
         $sequence = $sequence === null ? "1:*" : $sequence;
254 254
         return $this->client->getConnection()->overview($sequence);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
          */
273 273
 
274 274
         if ($internal_date != null) {
275
-            if ($internal_date instanceof Carbon){
275
+            if ($internal_date instanceof Carbon) {
276 276
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
277 277
             }
278 278
         }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
      */
307 307
     public function delete($expunge = true) {
308 308
         $status = $this->client->getConnection()->deleteFolder($this->path);
309
-        if($expunge) $this->client->expunge();
309
+        if ($expunge) $this->client->expunge();
310 310
 
311 311
         $event = $this->getEvent("folder", "deleted");
312 312
         $event::dispatch($this);
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             try {
362 362
                 $line = $connection->nextLine();
363 363
                 if (($pos = strpos($line, "EXISTS")) !== false) {
364
-                    $msgn = (int) substr($line, 2, $pos -2);
364
+                    $msgn = (int) substr($line, 2, $pos - 2);
365 365
                     $connection->done();
366 366
 
367 367
                     $message = $this->query()->getMessage($msgn);
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 
373 373
                     $connection->idle();
374 374
                 }
375
-            }catch (Exceptions\RuntimeException $e) {
376
-                if(strpos($e->getMessage(), "connection closed") === false) {
375
+            } catch (Exceptions\RuntimeException $e) {
376
+                if (strpos($e->getMessage(), "connection closed") === false) {
377 377
                     throw $e;
378
-                }else{
378
+                }else {
379 379
                     $this->client->connect();
380 380
                     $this->client->openFolder($this->path);
381 381
                     $connection = $this->client->getConnection();
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
      * Set the delimiter
421 421
      * @param $delimiter
422 422
      */
423
-    public function setDelimiter($delimiter){
424
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
423
+    public function setDelimiter($delimiter) {
424
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
425 425
             $delimiter = ClientManager::get('options.delimiter', '/');
426 426
         }
427 427
 
Please login to merge, or discard this patch.