Completed
Push — master ( 7ee17a...53dc02 )
by Malte
326:57 queued 225:36
created
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/Client.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
      * @param array $config
195 195
      * @param array $default_config
196 196
      */
197
-    private function setAccountConfig($key, $config, $default_config){
197
+    private function setAccountConfig($key, $config, $default_config) {
198 198
         $value = $this->default_account_config[$key];
199
-        if(isset($config[$key])) {
199
+        if (isset($config[$key])) {
200 200
             $value = $config[$key];
201
-        }elseif(isset($default_config[$key])) {
201
+        }elseif (isset($default_config[$key])) {
202 202
             $value = $default_config[$key];
203 203
         }
204 204
         $this->$key = $value;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
      */
211 211
     protected function setEventsFromConfig($config) {
212 212
         $this->events = ClientManager::get("events");
213
-        if(isset($config['events'])){
214
-            if(isset($config['events'])) {
215
-                foreach($config['events'] as $section => $events) {
213
+        if (isset($config['events'])) {
214
+            if (isset($config['events'])) {
215
+                foreach ($config['events'] as $section => $events) {
216 216
                     $this->events[$section] = array_merge($this->events[$section], $events);
217 217
                 }
218 218
             }
@@ -226,45 +226,45 @@  discard block
 block discarded – undo
226 226
      * @throws MaskNotFoundException
227 227
      */
228 228
     protected function setMaskFromConfig($config) {
229
-        $default_config  = ClientManager::get("masks");
229
+        $default_config = ClientManager::get("masks");
230 230
 
231
-        if(isset($config['masks'])){
232
-            if(isset($config['masks']['message'])) {
233
-                if(class_exists($config['masks']['message'])) {
231
+        if (isset($config['masks'])) {
232
+            if (isset($config['masks']['message'])) {
233
+                if (class_exists($config['masks']['message'])) {
234 234
                     $this->default_message_mask = $config['masks']['message'];
235
-                }else{
235
+                }else {
236 236
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']);
237 237
                 }
238
-            }else{
239
-                if(class_exists($default_config['message'])) {
238
+            }else {
239
+                if (class_exists($default_config['message'])) {
240 240
                     $this->default_message_mask = $default_config['message'];
241
-                }else{
241
+                }else {
242 242
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
243 243
                 }
244 244
             }
245
-            if(isset($config['masks']['attachment'])) {
246
-                if(class_exists($config['masks']['attachment'])) {
245
+            if (isset($config['masks']['attachment'])) {
246
+                if (class_exists($config['masks']['attachment'])) {
247 247
                     $this->default_message_mask = $config['masks']['attachment'];
248
-                }else{
248
+                }else {
249 249
                     throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']);
250 250
                 }
251
-            }else{
252
-                if(class_exists($default_config['attachment'])) {
251
+            }else {
252
+                if (class_exists($default_config['attachment'])) {
253 253
                     $this->default_message_mask = $default_config['attachment'];
254
-                }else{
254
+                }else {
255 255
                     throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
256 256
                 }
257 257
             }
258
-        }else{
259
-            if(class_exists($default_config['message'])) {
258
+        }else {
259
+            if (class_exists($default_config['message'])) {
260 260
                 $this->default_message_mask = $default_config['message'];
261
-            }else{
261
+            }else {
262 262
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']);
263 263
             }
264 264
 
265
-            if(class_exists($default_config['attachment'])) {
265
+            if (class_exists($default_config['attachment'])) {
266 266
                 $this->default_message_mask = $default_config['attachment'];
267
-            }else{
267
+            }else {
268 268
                 throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']);
269 269
             }
270 270
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
             $this->connection = new ImapProtocol($this->validate_cert, $this->encryption);
330 330
             $this->connection->setConnectionTimeout($timeout);
331 331
             $this->connection->setProxy($this->proxy);
332
-        }else{
332
+        }else {
333 333
             if (extension_loaded('imap') === false) {
334 334
                 throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol"));
335 335
             }
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
         $pattern = $parent_folder.($hierarchical ? '%' : '*');
443 443
         $items = $this->connection->folders('', $pattern);
444 444
 
445
-        if(is_array($items)){
445
+        if (is_array($items)) {
446 446
             foreach ($items as $folder_name => $item) {
447 447
                 $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]);
448 448
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             }
458 458
 
459 459
             return $folders;
460
-        }else{
460
+        }else {
461 461
             throw new FolderFetchingException("failed to fetch any folders");
462 462
         }
463 463
     }
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
         $this->checkConnection();
494 494
         $status = $this->connection->createFolder($folder);
495 495
 
496
-        if($expunge) $this->expunge();
496
+        if ($expunge) $this->expunge();
497 497
 
498 498
         $folder = $this->getFolder($folder);
499
-        if($status && $folder) {
499
+        if ($status && $folder) {
500 500
             $event = $this->getEvent("folder", "new");
501 501
             $event::dispatch($folder);
502 502
         }
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      *
522 522
      * @return Folder
523 523
      */
524
-    public function getFolderPath(){
524
+    public function getFolderPath() {
525 525
         return $this->active_folder;
526 526
     }
527 527
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
      *
576 576
      * @return int
577 577
      */
578
-    public function getTimeout($type){
578
+    public function getTimeout($type) {
579 579
         return $this->connection->getConnectionTimeout();
580 580
     }
581 581
 
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
      *
585 585
      * @return string
586 586
      */
587
-    public function getDefaultMessageMask(){
587
+    public function getDefaultMessageMask() {
588 588
         return $this->default_message_mask;
589 589
     }
590 590
 
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
      *
595 595
      * @return array
596 596
      */
597
-    public function getDefaultEvents($section){
597
+    public function getDefaultEvents($section) {
598 598
         return $this->events[$section];
599 599
     }
600 600
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
      * @throws MaskNotFoundException
607 607
      */
608 608
     public function setDefaultMessageMask($mask) {
609
-        if(class_exists($mask)) {
609
+        if (class_exists($mask)) {
610 610
             $this->default_message_mask = $mask;
611 611
 
612 612
             return $this;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      *
621 621
      * @return string
622 622
      */
623
-    public function getDefaultAttachmentMask(){
623
+    public function getDefaultAttachmentMask() {
624 624
         return $this->default_attachment_mask;
625 625
     }
626 626
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
      * @throws MaskNotFoundException
633 633
      */
634 634
     public function setDefaultAttachmentMask($mask) {
635
-        if(class_exists($mask)) {
635
+        if (class_exists($mask)) {
636 636
             $this->default_attachment_mask = $mask;
637 637
 
638 638
             return $this;
Please login to merge, or discard this patch.
src/Part.php 1 patch
Spacing   +18 added lines, -18 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,7 +298,7 @@  discard block
 block discarded – undo
298 298
      *
299 299
      * @return bool
300 300
      */
301
-    public function isAttachment(){
301
+    public function isAttachment() {
302 302
         if ($this->type == IMAP::MESSAGE_TYPE_TEXT &&
303 303
             ($this->ifdisposition == 0 ||
304 304
                 (empty($this->disposition) || !in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')))
Please login to merge, or discard this patch.
src/Connection/Protocols/LegacyProtocol.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             throw new AuthFailedException($message);
88 88
         }
89 89
 
90
-        if(!$this->stream) {
90
+        if (!$this->stream) {
91 91
             $errors = \imap_errors();
92 92
             $message = implode("; ", (is_array($errors) ? $errors : array()));
93 93
             throw new AuthFailedException($message);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         if (!$this->cert_validation) {
119 119
             $address .= '/novalidate-cert';
120 120
         }
121
-        if (in_array($this->encryption,['tls', 'notls', 'ssl'])) {
121
+        if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) {
122 122
             $address .= '/'.$this->encryption;
123 123
         } elseif ($this->encryption === "starttls") {
124 124
             $address .= '/tls';
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      *
147 147
      * @return bool
148 148
      */
149
-    public function connected(){
149
+    public function connected() {
150 150
         return !$this->stream;
151 151
     }
152 152
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      *
219 219
      * @return array
220 220
      */
221
-    public function headers($uids, $rfc = "RFC822", $uid = false){
221
+    public function headers($uids, $rfc = "RFC822", $uid = false) {
222 222
         $result = [];
223 223
         $uids = is_array($uids) ? $uids : [$uids];
224 224
         foreach ($uids as $uid) {
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      *
235 235
      * @return array
236 236
      */
237
-    public function flags($uids, $uid = false){
237
+    public function flags($uids, $uid = false) {
238 238
         $result = [];
239 239
         $uids = is_array($uids) ? $uids : [$uids];
240 240
         foreach ($uids as $uid) {
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
             $flags = [];
243 243
             if (is_array($raw_flags) && isset($raw_flags[0])) {
244 244
                 $raw_flags = (array) $raw_flags[0];
245
-                foreach($raw_flags as $flag => $value) {
246
-                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){
245
+                foreach ($raw_flags as $flag => $value) {
246
+                    if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) {
247 247
                         $flags[] = "\\".ucfirst($flag);
248 248
                     }
249 249
                 }
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         if ($id === null) {
265 265
             $overview = $this->overview("1:*");
266 266
             $uids = [];
267
-            foreach($overview as $set){
267
+            foreach ($overview as $set) {
268 268
                 $uids[$set->msgno] = $set->uid;
269 269
             }
270 270
             return $uids;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @return array
291 291
      */
292 292
     public function overview($sequence, $uid = false) {
293
-        return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::FT_UID : IMAP::NIL);
293
+        return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::FT_UID : IMAP::NIL);
294 294
     }
295 295
 
296 296
     /**
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
         $result = [];
306 306
 
307 307
         $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder);
308
-        if(is_array($items)){
308
+        if (is_array($items)) {
309 309
             foreach ($items as $item) {
310 310
                 $name = $this->decodeFolderName($item->name);
311 311
                 $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []];
312 312
             }
313
-        }else{
313
+        }else {
314 314
             throw new RuntimeException(\imap_last_error());
315 315
         }
316 316
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
     public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) {
333 333
         $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags);
334 334
 
335
-        if ($mode == "+"){
335
+        if ($mode == "+") {
336 336
             $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL);
337
-        }else{
337
+        }else {
338 338
             $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL);
339 339
         }
340 340
 
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      */
357 357
     public function appendMessage($folder, $message, $flags = null, $date = null) {
358 358
         if ($date != null) {
359
-            if ($date instanceof \Carbon\Carbon){
359
+            if ($date instanceof \Carbon\Carbon) {
360 360
                 $date = $date->format('d-M-Y H:i:s O');
361 361
             }
362 362
             return \imap_append($this->stream, $folder, $message, $flags, $date);
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
     /**
494 494
      * Enable the debug mode
495 495
      */
496
-    public function enableDebug(){
496
+    public function enableDebug() {
497 497
         $this->debug = true;
498 498
     }
499 499
 
500 500
     /**
501 501
      * Disable the debug mode
502 502
      */
503
-    public function disableDebug(){
503
+    public function disableDebug() {
504 504
         $this->debug = false;
505 505
     }
506 506
 
Please login to merge, or discard this patch.
src/Attribute.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      *
61 61
      * @return string
62 62
      */
63
-    public function toString(){
63
+    public function toString() {
64 64
         return $this->__toString();
65 65
     }
66 66
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      *
70 70
      * @return array
71 71
      */
72
-    public function __serialize(){
72
+    public function __serialize() {
73 73
         return $this->values;
74 74
     }
75 75
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      *
79 79
      * @return array
80 80
      */
81
-    public function toArray(){
81
+    public function toArray() {
82 82
         return $this->__serialize();
83 83
     }
84 84
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             if ($this->contains($value) === false) {
142 142
                 $this->values[] = $value;
143 143
             }
144
-        }else{
144
+        }else {
145 145
             $this->values[] = $value;
146 146
         }
147 147
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return Attribute
154 154
      */
155
-    public function setName($name){
155
+    public function setName($name) {
156 156
         $this->name = $name;
157 157
 
158 158
         return $this;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @return string
165 165
      */
166
-    public function getName(){
166
+    public function getName() {
167 167
         return $this->name;
168 168
     }
169 169
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @return array
174 174
      */
175
-    public function get(){
175
+    public function get() {
176 176
         return $this->values;
177 177
     }
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return array
183 183
      */
184
-    public function all(){
184
+    public function all() {
185 185
         return $this->get();
186 186
     }
187 187
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
      *
191 191
      * @return mixed|null
192 192
      */
193
-    public function first(){
193
+    public function first() {
194 194
         if (count($this->values) > 0) {
195 195
             return $this->values[0];
196 196
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      *
203 203
      * @return mixed|null
204 204
      */
205
-    public function last(){
205
+    public function last() {
206 206
         $cnt = count($this->values);
207 207
         if ($cnt > 0) {
208 208
             return $this->values[$cnt - 1];
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) {
203 203
 
204 204
         $default_mask = $client->getDefaultMessageMask();
205
-        if($default_mask != null) {
205
+        if ($default_mask != null) {
206 206
             $this->mask = $default_mask;
207 207
         }
208 208
         $this->events["message"] = $client->getDefaultEvents("message");
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
      * @throws MessageFlagException
262 262
      * @throws Exceptions\RuntimeException
263 263
      */
264
-    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){
264
+    public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) {
265 265
         $reflection = new \ReflectionClass(self::class);
266 266
         /** @var self $instance */
267 267
         $instance = $reflection->newInstanceWithoutConstructor();
268 268
 
269 269
         $default_mask = $client->getDefaultMessageMask();
270
-        if($default_mask != null) {
270
+        if ($default_mask != null) {
271 271
             $instance->setMask($default_mask);
272 272
         }
273 273
         $instance->setEvents([
@@ -302,13 +302,13 @@  discard block
 block discarded – undo
302 302
      * @throws MethodNotFoundException
303 303
      */
304 304
     public function __call($method, $arguments) {
305
-        if(strtolower(substr($method, 0, 3)) === 'get') {
305
+        if (strtolower(substr($method, 0, 3)) === 'get') {
306 306
             $name = Str::snake(substr($method, 3));
307 307
             return $this->get($name);
308 308
         }elseif (strtolower(substr($method, 0, 3)) === 'set') {
309 309
             $name = Str::snake(substr($method, 3));
310 310
 
311
-            if(in_array($name, array_keys($this->attributes))) {
311
+            if (in_array($name, array_keys($this->attributes))) {
312 312
                 return $this->__set($name, array_pop($arguments));
313 313
             }
314 314
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      * @return mixed|null
348 348
      */
349 349
     public function get($name) {
350
-        if(isset($this->attributes[$name])) {
350
+        if (isset($this->attributes[$name])) {
351 351
             return $this->attributes[$name];
352 352
         }
353 353
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      *
422 422
      * @throws InvalidMessageDateException
423 423
      */
424
-    public function parseRawHeader($raw_header){
424
+    public function parseRawHeader($raw_header) {
425 425
         $this->header = new Header($raw_header);
426 426
     }
427 427
 
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     public function parseRawFlags($raw_flags) {
433 433
         $this->flags = FlagCollection::make([]);
434 434
 
435
-        foreach($raw_flags as $flag) {
436
-            if (strpos($flag, "\\") === 0){
435
+        foreach ($raw_flags as $flag) {
436
+            if (strpos($flag, "\\") === 0) {
437 437
                 $flag = substr($flag, 1);
438 438
             }
439 439
             $flag_key = strtolower($flag);
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
      * @throws MessageFlagException
507 507
      * @throws Exceptions\RuntimeException
508 508
      */
509
-    public function peek(){
509
+    public function peek() {
510 510
         if ($this->fetch_options == IMAP::FT_PEEK) {
511 511
             if ($this->getFlags()->get("seen") == null) {
512 512
                 $this->unsetFlag("Seen");
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
     private function fetchPart(Part $part) {
556 556
         if ($part->isAttachment()) {
557 557
             $this->fetchAttachment($part);
558
-        }else{
558
+        }else {
559 559
             $encoding = $this->getEncoding($part);
560 560
 
561 561
             $content = $this->decodeString($part->content, $part->encoding);
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
         if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) {
593 593
             if ($oAttachment->getId() !== null) {
594 594
                 $this->attachments->put($oAttachment->getId(), $oAttachment);
595
-            } else {
595
+            }else {
596 596
                 $this->attachments->push($oAttachment);
597 597
             }
598 598
         }
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 
727 727
         if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
728 728
             return @iconv($from, $to.'//IGNORE', $str);
729
-        } else {
729
+        }else {
730 730
             if (!$from) {
731 731
                 return mb_convert_encoding($str, $to);
732 732
             }
@@ -747,9 +747,9 @@  discard block
 block discarded – undo
747 747
                     return EncodingAliases::get($parameter->value);
748 748
                 }
749 749
             }
750
-        }elseif (property_exists($structure, 'charset')){
750
+        }elseif (property_exists($structure, 'charset')) {
751 751
             return EncodingAliases::get($structure->charset);
752
-        }elseif (is_string($structure) === true){
752
+        }elseif (is_string($structure) === true) {
753 753
             return mb_detect_encoding($structure);
754 754
         }
755 755
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
      * @throws Exceptions\FolderFetchingException
765 765
      * @throws Exceptions\RuntimeException
766 766
      */
767
-    public function getFolder(){
767
+    public function getFolder() {
768 768
         return $this->client->getFolder($this->folder_path);
769 769
     }
770 770
 
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
      * @throws Exceptions\GetMessagesFailedException
781 781
      * @throws Exceptions\RuntimeException
782 782
      */
783
-    public function thread($sent_folder = null, &$thread = null, $folder = null){
783
+    public function thread($sent_folder = null, &$thread = null, $folder = null) {
784 784
         $thread = $thread ? $thread : MessageCollection::make([]);
785
-        $folder = $folder ? $folder :  $this->getFolder();
785
+        $folder = $folder ? $folder : $this->getFolder();
786 786
         $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent"));
787 787
 
788 788
         /** @var Message $message */
789
-        foreach($thread as $message) {
789
+        foreach ($thread as $message) {
790 790
             if ($message->message_id == $this->message_id) {
791 791
                 return $thread;
792 792
             }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
         $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder);
798 798
 
799 799
         if (is_array($this->in_reply_to)) {
800
-            foreach($this->in_reply_to as $in_reply_to) {
800
+            foreach ($this->in_reply_to as $in_reply_to) {
801 801
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder);
802 802
                 $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder);
803 803
             }
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
      * @throws Exceptions\GetMessagesFailedException
819 819
      * @throws Exceptions\RuntimeException
820 820
      */
821
-    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){
821
+    protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) {
822 822
         $primary_folder->query()->inReplyTo($in_reply_to)
823 823
         ->setFetchBody($this->getFetchBodyOption())
824 824
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
      * @throws Exceptions\GetMessagesFailedException
840 840
      * @throws Exceptions\RuntimeException
841 841
      */
842
-    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){
842
+    protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) {
843 843
         $primary_folder->query()->messageId($message_id)
844 844
         ->setFetchBody($this->getFetchBodyOption())
845 845
         ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){
@@ -932,14 +932,14 @@  discard block
 block discarded – undo
932 932
      * @throws MessageFlagException
933 933
      * @throws MessageHeaderFetchingException
934 934
      */
935
-    protected function fetchNewMail($folder, $next_uid, $event, $expunge){
936
-        if($expunge) $this->client->expunge();
935
+    protected function fetchNewMail($folder, $next_uid, $event, $expunge) {
936
+        if ($expunge) $this->client->expunge();
937 937
 
938 938
         $this->client->openFolder($folder->path);
939 939
 
940 940
         if ($this->sequence === IMAP::ST_UID) {
941 941
             $sequence_id = $next_uid;
942
-        }else{
942
+        }else {
943 943
             $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid);
944 944
         }
945 945
 
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
      */
963 963
     public function delete($expunge = true) {
964 964
         $status = $this->setFlag("Deleted");
965
-        if($expunge) $this->client->expunge();
965
+        if ($expunge) $this->client->expunge();
966 966
 
967 967
         $event = $this->getEvent("message", "deleted");
968 968
         $event::dispatch($this);
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
      */
983 983
     public function restore($expunge = true) {
984 984
         $status = $this->unsetFlag("Deleted");
985
-        if($expunge) $this->client->expunge();
985
+        if ($expunge) $this->client->expunge();
986 986
 
987 987
         $event = $this->getEvent("message", "restored");
988 988
         $event::dispatch($this);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
      *
1088 1088
      * @return AttachmentCollection
1089 1089
      */
1090
-    public function attachments(){
1090
+    public function attachments() {
1091 1091
         return $this->getAttachments();
1092 1092
     }
1093 1093
 
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
      *
1186 1186
      * @return FlagCollection
1187 1187
      */
1188
-    public function flags(){
1188
+    public function flags() {
1189 1189
         return $this->getFlags();
1190 1190
     }
1191 1191
 
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
      *
1195 1195
      * @return Structure|null
1196 1196
      */
1197
-    public function getStructure(){
1197
+    public function getStructure() {
1198 1198
         return $this->structure;
1199 1199
     }
1200 1200
 
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
      *
1221 1221
      * @return array
1222 1222
      */
1223
-    public function getAttributes(){
1223
+    public function getAttributes() {
1224 1224
         return array_merge($this->attributes, $this->header->getAttributes());
1225 1225
     }
1226 1226
 
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
      *
1231 1231
      * @return $this
1232 1232
      */
1233
-    public function setMask($mask){
1234
-        if(class_exists($mask)){
1233
+    public function setMask($mask) {
1234
+        if (class_exists($mask)) {
1235 1235
             $this->mask = $mask;
1236 1236
         }
1237 1237
 
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
      *
1244 1244
      * @return string
1245 1245
      */
1246
-    public function getMask(){
1246
+    public function getMask() {
1247 1247
         return $this->mask;
1248 1248
     }
1249 1249
 
@@ -1254,9 +1254,9 @@  discard block
 block discarded – undo
1254 1254
      * @return mixed
1255 1255
      * @throws MaskNotFoundException
1256 1256
      */
1257
-    public function mask($mask = null){
1257
+    public function mask($mask = null) {
1258 1258
         $mask = $mask !== null ? $mask : $this->mask;
1259
-        if(class_exists($mask)){
1259
+        if (class_exists($mask)) {
1260 1260
             return new $mask($this);
1261 1261
         }
1262 1262
 
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
      *
1270 1270
      * @return $this
1271 1271
      */
1272
-    public function setFolderPath($folder_path){
1272
+    public function setFolderPath($folder_path) {
1273 1273
         $this->folder_path = $folder_path;
1274 1274
 
1275 1275
         return $this;
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
      *
1282 1282
      * @return $this
1283 1283
      */
1284
-    public function setConfig($config){
1284
+    public function setConfig($config) {
1285 1285
         $this->config = $config;
1286 1286
 
1287 1287
         return $this;
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
      *
1294 1294
      * @return $this
1295 1295
      */
1296
-    public function setAvailableFlags($available_flags){
1296
+    public function setAvailableFlags($available_flags) {
1297 1297
         $this->available_flags = $available_flags;
1298 1298
 
1299 1299
         return $this;
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
      *
1306 1306
      * @return $this
1307 1307
      */
1308
-    public function setAttachments($attachments){
1308
+    public function setAttachments($attachments) {
1309 1309
         $this->attachments = $attachments;
1310 1310
 
1311 1311
         return $this;
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
      *
1318 1318
      * @return $this
1319 1319
      */
1320
-    public function setFlags($flags){
1320
+    public function setFlags($flags) {
1321 1321
         $this->flags = $flags;
1322 1322
 
1323 1323
         return $this;
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
      * @throws Exceptions\RuntimeException
1332 1332
      * @throws Exceptions\ConnectionFailedException
1333 1333
      */
1334
-    public function setClient($client){
1334
+    public function setClient($client) {
1335 1335
         $this->client = $client;
1336 1336
         $this->client->openFolder($this->folder_path);
1337 1337
 
@@ -1346,7 +1346,7 @@  discard block
 block discarded – undo
1346 1346
      * @throws Exceptions\RuntimeException
1347 1347
      * @return $this
1348 1348
      */
1349
-    public function setUid($uid){
1349
+    public function setUid($uid) {
1350 1350
         $this->uid = $uid;
1351 1351
         $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid);
1352 1352
         $this->msglist = null;
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
      * @throws Exceptions\RuntimeException
1364 1364
      * @return $this
1365 1365
      */
1366
-    public function setMsgn($msgn, $msglist = null){
1366
+    public function setMsgn($msgn, $msglist = null) {
1367 1367
         $this->msgn = $msgn;
1368 1368
         $this->msglist = $msglist;
1369 1369
         $this->uid = $this->client->getConnection()->getUid($this->msgn);
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
      *
1377 1377
      * @return int
1378 1378
      */
1379
-    public function getSequence(){
1379
+    public function getSequence() {
1380 1380
         return $this->sequence;
1381 1381
     }
1382 1382
 
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
      *
1386 1386
      * @return int
1387 1387
      */
1388
-    public function getSequenceId(){
1388
+    public function getSequenceId() {
1389 1389
         return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn;
1390 1390
     }
1391 1391
 
@@ -1397,11 +1397,11 @@  discard block
 block discarded – undo
1397 1397
      * @throws Exceptions\ConnectionFailedException
1398 1398
      * @throws Exceptions\RuntimeException
1399 1399
      */
1400
-    public function setSequenceId($uid, $msglist = null){
1400
+    public function setSequenceId($uid, $msglist = null) {
1401 1401
         if ($this->getSequence() === IMAP::ST_UID) {
1402 1402
             $this->setUid($uid);
1403 1403
             $this->setMsglist($msglist);
1404
-        }else{
1404
+        }else {
1405 1405
             $this->setMsgn($uid, $msglist);
1406 1406
         }
1407 1407
     }
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);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @throws Exceptions\ConnectionFailedException
140 140
      * @throws Exceptions\RuntimeException
141 141
      */
142
-    public function query($charset = 'UTF-8'){
142
+    public function query($charset = 'UTF-8') {
143 143
         $this->getClient()->checkConnection();
144 144
         $this->getClient()->openFolder($this->path);
145 145
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      * @throws Exceptions\ConnectionFailedException
152 152
      * @throws Exceptions\RuntimeException
153 153
      */
154
-    public function search($charset = 'UTF-8'){
154
+    public function search($charset = 'UTF-8') {
155 155
         return $this->query($charset);
156 156
     }
157 157
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @throws Exceptions\ConnectionFailedException
161 161
      * @throws Exceptions\RuntimeException
162 162
      */
163
-    public function messages($charset = 'UTF-8'){
163
+    public function messages($charset = 'UTF-8') {
164 164
         return $this->query($charset);
165 165
     }
166 166
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
     public function move($new_name, $expunge = true) {
236 236
         $this->client->checkConnection();
237 237
         $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name);
238
-        if($expunge) $this->client->expunge();
238
+        if ($expunge) $this->client->expunge();
239 239
 
240 240
         $folder = $this->client->getFolder($new_name);
241 241
         $event = $this->getEvent("folder", "moved");
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
      * @throws ConnectionFailedException
253 253
      * @throws Exceptions\RuntimeException
254 254
      */
255
-    public function overview($sequence = null){
255
+    public function overview($sequence = null) {
256 256
         $this->client->openFolder($this->path);
257 257
         $sequence = $sequence === null ? "1:*" : $sequence;
258 258
         $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
          */
278 278
 
279 279
         if ($internal_date != null) {
280
-            if ($internal_date instanceof Carbon){
280
+            if ($internal_date instanceof Carbon) {
281 281
                 $internal_date = $internal_date->format('d-M-Y H:i:s O');
282 282
             }
283 283
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public function delete($expunge = true) {
313 313
         $status = $this->client->getConnection()->deleteFolder($this->path);
314
-        if($expunge) $this->client->expunge();
314
+        if ($expunge) $this->client->expunge();
315 315
 
316 316
         $event = $this->getEvent("folder", "deleted");
317 317
         $event::dispatch($this);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
             try {
371 371
                 $line = $connection->nextLine();
372 372
                 if (($pos = strpos($line, "EXISTS")) !== false) {
373
-                    $msgn = (int) substr($line, 2, $pos -2);
373
+                    $msgn = (int) substr($line, 2, $pos - 2);
374 374
                     $connection->done();
375 375
 
376 376
                     $this->client->openFolder($this->path, true);
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 
384 384
                     $connection->idle();
385 385
                 }
386
-            }catch (Exceptions\RuntimeException $e) {
387
-                if(strpos($e->getMessage(), "connection closed") === false) {
386
+            } catch (Exceptions\RuntimeException $e) {
387
+                if (strpos($e->getMessage(), "connection closed") === false) {
388 388
                     throw $e;
389 389
                 }
390 390
             }
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
      * Set the delimiter
427 427
      * @param $delimiter
428 428
      */
429
-    public function setDelimiter($delimiter){
430
-        if(in_array($delimiter, [null, '', ' ', false]) === true) {
429
+    public function setDelimiter($delimiter) {
430
+        if (in_array($delimiter, [null, '', ' ', false]) === true) {
431 431
             $delimiter = ClientManager::get('options.delimiter', '/');
432 432
         }
433 433
 
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
      * @throws MethodNotFoundException
83 83
      */
84 84
     public function __call($method, $arguments) {
85
-        if(strtolower(substr($method, 0, 3)) === 'get') {
85
+        if (strtolower(substr($method, 0, 3)) === 'get') {
86 86
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
87 87
 
88
-            if(in_array($name, array_keys($this->attributes))) {
88
+            if (in_array($name, array_keys($this->attributes))) {
89 89
                 return $this->attributes[$name];
90 90
             }
91 91
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @return Attribute|mixed
112 112
      */
113 113
     public function get($name) {
114
-        if(isset($this->attributes[$name])) {
114
+        if (isset($this->attributes[$name])) {
115 115
             return $this->attributes[$name];
116 116
         }
117 117
 
@@ -127,23 +127,23 @@  discard block
 block discarded – undo
127 127
      * @return Attribute
128 128
      */
129 129
     public function set($name, $value, $strict = false) {
130
-        if(isset($this->attributes[$name]) && $strict === false) {
130
+        if (isset($this->attributes[$name]) && $strict === false) {
131 131
             if ($this->attributize) {
132 132
                 $this->attributes[$name]->add($value, true);
133
-            }else{
134
-                if(isset($this->attributes[$name])) {
133
+            }else {
134
+                if (isset($this->attributes[$name])) {
135 135
                     if (is_array($this->attributes[$name]) == false) {
136 136
                         $this->attributes[$name] = [$this->attributes[$name], $value];
137
-                    }else{
137
+                    }else {
138 138
                         $this->attributes[$name][] = $value;
139 139
                     }
140
-                }else{
140
+                }else {
141 141
                     $this->attributes[$name] = $value;
142 142
                 }
143 143
             }
144
-        }elseif($this->attributize == false){
144
+        }elseif ($this->attributize == false) {
145 145
             $this->attributes[$name] = $value;
146
-        }else{
146
+        }else {
147 147
             $this->attributes[$name] = new Attribute($name, $value);
148 148
         }
149 149
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function find($pattern) {
160 160
         if (preg_match_all($pattern, $this->raw, $matches)) {
161 161
             if (isset($matches[1])) {
162
-                if(count($matches[1]) > 0) {
162
+                if (count($matches[1]) > 0) {
163 163
                     return $matches[1][0];
164 164
                 }
165 165
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      *
173 173
      * @throws InvalidMessageDateException
174 174
      */
175
-    protected function parse(){
175
+    protected function parse() {
176 176
         $header = $this->rfc822_parse_headers($this->raw);
177 177
 
178 178
         $this->extractAddresses($header);
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         $this->parseDate($header);
191 191
         foreach ($header as $key => $value) {
192 192
             $key = trim(rtrim(strtolower($key)));
193
-            if(!isset($this->attributes[$key])){
193
+            if (!isset($this->attributes[$key])) {
194 194
                 $this->set($key, $value);
195 195
             }
196 196
         }
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
      *
207 207
      * @return object
208 208
      */
209
-    public function rfc822_parse_headers($raw_headers){
209
+    public function rfc822_parse_headers($raw_headers) {
210 210
         $headers = [];
211 211
         $imap_headers = [];
212 212
         if (extension_loaded('imap')) {
213 213
             $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw);
214
-            foreach($raw_imap_headers as $key => $values) {
214
+            foreach ($raw_imap_headers as $key => $values) {
215 215
                 $key = str_replace("-", "_", $key);
216 216
                 $imap_headers[$key] = $values;
217 217
             }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
         $lines = explode("\r\n", $raw_headers);
221 221
         $prev_header = null;
222
-        foreach($lines as $line) {
222
+        foreach ($lines as $line) {
223 223
             if (substr($line, 0, 1) === "\n") {
224 224
                 $line = substr($line, 1);
225 225
             }
@@ -239,19 +239,19 @@  discard block
 block discarded – undo
239 239
                     }
240 240
                     if (is_array($headers[$prev_header])) {
241 241
                         $headers[$prev_header][] = $line;
242
-                    }else{
242
+                    }else {
243 243
                         $headers[$prev_header] .= $line;
244 244
                     }
245 245
                 }
246
-            }else{
246
+            }else {
247 247
                 if (($pos = strpos($line, ":")) > 0) {
248 248
                     $key = trim(rtrim(strtolower(substr($line, 0, $pos))));
249 249
                     $key = str_replace("-", "_", $key);
250 250
 
251 251
                     $value = trim(rtrim(substr($line, $pos + 1)));
252 252
                     if (isset($headers[$key])) {
253
-                        $headers[$key][]  = $value;
254
-                    }else{
253
+                        $headers[$key][] = $value;
254
+                    }else {
255 255
                         $headers[$key] = [$value];
256 256
                     }
257 257
                     $prev_header = $key;
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
             }
260 260
         }
261 261
 
262
-        foreach($headers as $key => $values) {
262
+        foreach ($headers as $key => $values) {
263 263
             if (isset($imap_headers[$key])) continue;
264 264
             $value = null;
265
-            switch($key){
265
+            switch ($key) {
266 266
                 case 'from':
267 267
                 case 'to':
268 268
                 case 'cc':
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
                     break;
278 278
                 default:
279 279
                     if (is_array($values)) {
280
-                        foreach($values as $k => $v) {
280
+                        foreach ($values as $k => $v) {
281 281
                             if ($v == "") {
282 282
                                 unset($values[$k]);
283 283
                             }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                             $value = implode(" ", $values);
290 290
                         } elseif ($available_values > 2) {
291 291
                             $value = array_values($values);
292
-                        } else {
292
+                        }else {
293 293
                             $value = "";
294 294
                         }
295 295
                     }
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
      * @return array The decoded elements are returned in an array of objects, where each
310 310
      * object has two properties, charset and text.
311 311
      */
312
-    public function mime_header_decode($text){
312
+    public function mime_header_decode($text) {
313 313
         if (extension_loaded('imap')) {
314 314
             return \imap_mime_header_decode($text);
315 315
         }
316 316
         $charset = $this->getEncoding($text);
317
-        return [(object)[
317
+        return [(object) [
318 318
             "charset" => $charset,
319 319
             "text" => $this->convertEncoding($text, $charset)
320 320
         ]];
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
         try {
369 369
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
370 370
                 return iconv($from, $to, $str);
371
-            } else {
371
+            }else {
372 372
                 if (!$from) {
373 373
                     return mb_convert_encoding($str, $to);
374 374
                 }
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             if (strstr($from, '-')) {
379 379
                 $from = str_replace('-', '', $from);
380 380
                 return $this->convertEncoding($str, $from, $to);
381
-            } else {
381
+            }else {
382 382
                 return $str;
383 383
             }
384 384
         }
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             }
400 400
         }elseif (property_exists($structure, 'charset')) {
401 401
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
402
-        }elseif (is_string($structure) === true){
402
+        }elseif (is_string($structure) === true) {
403 403
             return mb_detect_encoding($structure);
404 404
         }
405 405
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         $decoder = $this->config['decoder']['message'];
421 421
 
422 422
         if ($value !== null) {
423
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
423
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
424 424
                 $value = \imap_utf8($value);
425 425
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
426 426
                     $value = mb_decode_mimeheader($value);
@@ -428,14 +428,14 @@  discard block
 block discarded – undo
428 428
                 if ($this->notDecoded($original_value, $value)) {
429 429
                     $decoded_value = $this->mime_header_decode($value);
430 430
                     if (count($decoded_value) > 0) {
431
-                        if(property_exists($decoded_value[0], "text")) {
431
+                        if (property_exists($decoded_value[0], "text")) {
432 432
                             $value = $decoded_value[0]->text;
433 433
                         }
434 434
                     }
435 435
                 }
436
-            }elseif($decoder === 'iconv') {
436
+            }elseif ($decoder === 'iconv') {
437 437
                 $value = iconv_mime_decode($value);
438
-            }else{
438
+            }else {
439 439
                 $value = mb_decode_mimeheader($value);
440 440
             }
441 441
 
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
      * @return array
459 459
      */
460 460
     private function decodeArray($values) {
461
-        foreach($values as $key => $value) {
461
+        foreach ($values as $key => $value) {
462 462
             $values[$key] = $this->decode($value);
463 463
         }
464 464
         return $values;
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
      * Try to extract the priority from a given raw header string
469 469
      */
470 470
     private function findPriority() {
471
-        if(($priority = $this->get("x_priority")) === null) return;
472
-        switch((int)"$priority"){
471
+        if (($priority = $this->get("x_priority")) === null) return;
472
+        switch ((int) "$priority") {
473 473
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
474 474
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
475 475
                 break;
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      */
502 502
     private function decodeAddresses($values) {
503 503
         $addresses = [];
504
-        foreach($values as $address) {
504
+        foreach ($values as $address) {
505 505
             $address = trim(rtrim($address));
506 506
             if (strpos($address, ",") == strlen($address) - 1) {
507 507
                 $address = substr($address, 0, -1);
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
511 511
                 $address,
512 512
                 $matches
513
-            )){
513
+            )) {
514 514
                 $name = trim(rtrim($matches["name"]));
515 515
                 $email = trim(rtrim($matches["email"]));
516 516
                 list($mailbox, $host) = array_pad(explode("@", $email), 2, null);
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
      * @param object $header
530 530
      */
531 531
     private function extractAddresses($header) {
532
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){
532
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) {
533 533
             if (property_exists($header, $key)) {
534 534
                 $this->set($key, $this->parseAddresses($header->$key));
535 535
             }
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
             }
561 561
             if (!property_exists($address, 'personal')) {
562 562
                 $address->personal = false;
563
-            } else {
563
+            }else {
564 564
                 $personalParts = $this->mime_header_decode($address->personal);
565 565
 
566
-                if(is_array($personalParts)) {
566
+                if (is_array($personalParts)) {
567 567
                     $address->personal = '';
568 568
                     foreach ($personalParts as $p) {
569 569
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -587,23 +587,23 @@  discard block
 block discarded – undo
587 587
     /**
588 588
      * Search and extract potential header extensions
589 589
      */
590
-    private function extractHeaderExtensions(){
590
+    private function extractHeaderExtensions() {
591 591
         foreach ($this->attributes as $key => $value) {
592 592
             if (is_array($value)) {
593 593
                 $value = implode(", ", $value);
594
-            }else{
595
-                $value = (string)$value;
594
+            }else {
595
+                $value = (string) $value;
596 596
             }
597 597
             // Only parse strings and don't parse any attributes like the user-agent
598 598
             if (in_array($key, ["user_agent"]) === false) {
599
-                if (($pos = strpos($value, ";")) !== false){
599
+                if (($pos = strpos($value, ";")) !== false) {
600 600
                     $original = substr($value, 0, $pos);
601 601
                     $this->set($key, trim(rtrim($original)), true);
602 602
 
603 603
                     // Get all potential extensions
604 604
                     $extensions = explode(";", substr($value, $pos + 1));
605
-                    foreach($extensions as $extension) {
606
-                        if (($pos = strpos($extension, "=")) !== false){
605
+                    foreach ($extensions as $extension) {
606
+                        if (($pos = strpos($extension, "=")) !== false) {
607 607
                             $key = substr($extension, 0, $pos);
608 608
                             $key = trim(rtrim(strtolower($key)));
609 609
 
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
             $parsed_date = null;
647 647
             $date = $header->date;
648 648
 
649
-            if(preg_match('/\+0580/', $date)) {
649
+            if (preg_match('/\+0580/', $date)) {
650 650
                 $date = str_replace('+0580', '+0530', $date);
651 651
             }
652 652
 
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
                         $date = trim(array_pop($array));
670 670
                         break;
671 671
                 }
672
-                try{
672
+                try {
673 673
                     $parsed_date = Carbon::parse($date);
674 674
                 } catch (\Exception $_e) {
675 675
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.
src/Address.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
      * @param object   $object
45 45
      */
46 46
     public function __construct($object) {
47
-        if (property_exists($object, "personal")){ $this->personal = $object->personal; }
48
-        if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; }
49
-        if (property_exists($object, "host")){ $this->host = $object->host; }
50
-        if (property_exists($object, "mail")){ $this->mail = $object->mail; }
51
-        if (property_exists($object, "full")){ $this->full = $object->full; }
47
+        if (property_exists($object, "personal")) { $this->personal = $object->personal; }
48
+        if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; }
49
+        if (property_exists($object, "host")) { $this->host = $object->host; }
50
+        if (property_exists($object, "mail")) { $this->mail = $object->mail; }
51
+        if (property_exists($object, "full")) { $this->full = $object->full; }
52 52
     }
53 53
 
54 54
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      *
67 67
      * @return array
68 68
      */
69
-    public function __serialize(){
69
+    public function __serialize() {
70 70
         return [
71 71
             "personal" => $this->personal,
72 72
             "mailbox" => $this->mailbox,
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      *
82 82
      * @return array
83 83
      */
84
-    public function toArray(){
84
+    public function toArray() {
85 85
         return $this->__serialize();
86 86
     }
87 87
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *
91 91
      * @return string
92 92
      */
93
-    public function toString(){
93
+    public function toString() {
94 94
         return $this->__toString();
95 95
     }
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.