Completed
Pull Request — master (#11)
by
unknown
01:44
created
src/Traits/HasEvents.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@
 block discarded – undo
65 65
      *
66 66
      * @return array
67 67
      */
68
-    public function getEvents(){
68
+    public function getEvents() {
69 69
         return $this->events;
70 70
     }
71 71
 
Please login to merge, or discard this patch.
src/Attachment.php 2 patches
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             }
119 119
 
120 120
             return null;
121
-        }elseif (strtolower(substr($method, 0, 3)) === 'set') {
121
+        } elseif (strtolower(substr($method, 0, 3)) === 'set') {
122 122
             $name = Str::snake(substr($method, 3));
123 123
 
124 124
             $this->attributes[$name] = array_pop($arguments);
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         if (($name = $this->part->name) !== null) {
209 209
             $this->setName($name);
210 210
             $this->disposition = $this->part->disposition;
211
-        }elseif (($filename = $this->part->filename) !== null) {
211
+        } elseif (($filename = $this->part->filename) !== null) {
212 212
             $this->setName($filename);
213 213
             $this->disposition = $this->part->disposition;
214 214
         }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         if ($name !== null) {
245 245
             if($decoder === 'utf-8' && extension_loaded('imap')) {
246 246
                 $this->name = \imap_utf8($name);
247
-            }else{
247
+            } else{
248 248
                 $this->name = mb_decode_mimeheader($name);
249 249
             }
250 250
         }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $this->part_number = $part->part_number;
105 105
 
106 106
         $default_mask = $this->oMessage->getClient()->getDefaultAttachmentMask();
107
-        if($default_mask != null) {
107
+        if ($default_mask != null) {
108 108
             $this->mask = $default_mask;
109 109
         }
110 110
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
      * @throws MethodNotFoundException
122 122
      */
123 123
     public function __call($method, $arguments) {
124
-        if(strtolower(substr($method, 0, 3)) === 'get') {
124
+        if (strtolower(substr($method, 0, 3)) === 'get') {
125 125
             $name = Str::snake(substr($method, 3));
126 126
 
127
-            if(isset($this->attributes[$name])) {
127
+            if (isset($this->attributes[$name])) {
128 128
                 return $this->attributes[$name];
129 129
             }
130 130
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      * @return mixed|null
161 161
      */
162 162
     public function __get($name) {
163
-        if(isset($this->attributes[$name])) {
163
+        if (isset($this->attributes[$name])) {
164 164
             return $this->attributes[$name];
165 165
         }
166 166
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         if (IMAP::ATTACHMENT_TYPE_MESSAGE == $this->part->type) {
230 230
             if ($this->part->ifdescription) {
231 231
                 $this->setName($this->part->description);
232
-            } else {
232
+            }else {
233 233
                 $this->setName($this->part->subtype);
234 234
             }
235 235
         }
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
     public function setName($name) {
256 256
         $decoder = $this->config['decoder']['attachment'];
257 257
         if ($name !== null) {
258
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
258
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
259 259
                 $this->name = \imap_utf8($name);
260
-            }else{
260
+            }else {
261 261
                 $this->name = mb_decode_mimeheader($name);
262 262
             }
263 263
         }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @return string|null
270 270
      */
271
-    public function getMimeType(){
271
+    public function getMimeType() {
272 272
         return (new \finfo())->buffer($this->getContent(), FILEINFO_MIME_TYPE);
273 273
     }
274 274
 
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
      *
278 278
      * @return string|null
279 279
      */
280
-    public function getExtension(){
280
+    public function getExtension() {
281 281
         $deprecated_guesser = "\Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesser";
282
-        if (class_exists($deprecated_guesser) !== false){
282
+        if (class_exists($deprecated_guesser) !== false) {
283 283
             return $deprecated_guesser::getInstance()->guess($this->getMimeType());
284 284
         }
285 285
         $guesser = "\Symfony\Component\Mime\MimeTypes";
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
      *
293 293
      * @return array
294 294
      */
295
-    public function getAttributes(){
295
+    public function getAttributes() {
296 296
         return $this->attributes;
297 297
     }
298 298
 
299 299
     /**
300 300
      * @return Message
301 301
      */
302
-    public function getMessage(){
302
+    public function getMessage() {
303 303
         return $this->oMessage;
304 304
     }
305 305
 
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
      *
310 310
      * @return $this
311 311
      */
312
-    public function setMask($mask){
313
-        if(class_exists($mask)){
312
+    public function setMask($mask) {
313
+        if (class_exists($mask)) {
314 314
             $this->mask = $mask;
315 315
         }
316 316
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      *
323 323
      * @return string
324 324
      */
325
-    public function getMask(){
325
+    public function getMask() {
326 326
         return $this->mask;
327 327
     }
328 328
 
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
      * @return mixed
334 334
      * @throws MaskNotFoundException
335 335
      */
336
-    public function mask($mask = null){
336
+    public function mask($mask = null) {
337 337
         $mask = $mask !== null ? $mask : $this->mask;
338
-        if(class_exists($mask)){
338
+        if (class_exists($mask)) {
339 339
             return new $mask($this);
340 340
         }
341 341
 
Please login to merge, or discard this patch.
src/Structure.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
     public function findContentType(){
81 81
         if(stripos($this->header->get("content-type"), 'multipart') === 0) {
82 82
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
83
-        }else{
83
+        } else{
84 84
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
85 85
         }
86 86
     }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @throws MessageContentFetchingException
70 70
      * @throws InvalidMessageDateException
71 71
      */
72
-    protected function parse(){
72
+    protected function parse() {
73 73
         $this->findContentType();
74 74
         $this->parts = $this->find_parts();
75 75
     }
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
     /**
78 78
      * Determine the message content type
79 79
      */
80
-    public function findContentType(){
81
-        if(stripos($this->header->get("content-type"), 'multipart') === 0) {
80
+    public function findContentType() {
81
+        if (stripos($this->header->get("content-type"), 'multipart') === 0) {
82 82
             $this->type = IMAP::MESSAGE_TYPE_MULTIPART;
83
-        }else{
83
+        }else {
84 84
             $this->type = IMAP::MESSAGE_TYPE_TEXT;
85 85
         }
86 86
     }
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * Determine the message content type
90 90
      */
91
-    public function getBoundary(){
91
+    public function getBoundary() {
92 92
         return $this->header->find("/boundary\=\"(.*)\"/");
93 93
     }
94 94
 
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
      * @throws MessageContentFetchingException
98 98
      * @throws InvalidMessageDateException
99 99
      */
100
-    public function find_parts(){
101
-        if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
102
-            if (($boundary = $this->getBoundary()) === null)  {
100
+    public function find_parts() {
101
+        if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) {
102
+            if (($boundary = $this->getBoundary()) === null) {
103 103
                 throw new MessageContentFetchingException("no content found", 0);
104 104
             }
105 105
 
106 106
             $raw_parts = explode($boundary, $this->raw);
107 107
             $parts = [];
108 108
             $part_number = 0;
109
-            foreach($raw_parts as $part) {
109
+            foreach ($raw_parts as $part) {
110 110
                 $part = trim(rtrim($part));
111 111
                 if ($part !== "--") {
112 112
                     $parts[] = new Part($part, null, $part_number);
Please login to merge, or discard this patch.
src/Query/Query.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function __construct(Client $client, $charset = 'UTF-8') {
74 74
         $this->setClient($client);
75 75
 
76
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
76
+        if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
77 77
 
78 78
         $this->date_format = ClientManager::get('date_format', 'd M y');
79 79
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * Instance boot method for additional functionality
87 87
      */
88
-    protected function boot(){}
88
+    protected function boot() {}
89 89
 
90 90
     /**
91 91
      * Parse a given value
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @return string
95 95
      */
96
-    protected function parse_value($value){
97
-        switch(true){
96
+    protected function parse_value($value) {
97
+        switch (true) {
98 98
             case $value instanceof \Carbon\Carbon:
99 99
                 $value = $value->format($this->date_format);
100 100
                 break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      * @throws MessageSearchValidationException
112 112
      */
113 113
     protected function parse_date($date) {
114
-        if($date instanceof \Carbon\Carbon) return $date;
114
+        if ($date instanceof \Carbon\Carbon) return $date;
115 115
 
116 116
         try {
117 117
             $date = Carbon::parse($date);
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @return Collection
151 151
      * @throws GetMessagesFailedException
152 152
      */
153
-    protected function search(){
153
+    protected function search() {
154 154
         $this->generate_query();
155 155
 
156 156
         try {
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 
196 196
                 $options = ClientManager::get('options');
197 197
 
198
-                if(strtolower($options['fetch_order']) === 'desc'){
198
+                if (strtolower($options['fetch_order']) === 'desc') {
199 199
                     $available_messages = $available_messages->reverse();
200 200
                 }
201 201
 
202
-                $query =& $this;
202
+                $query = & $this;
203 203
 
204 204
                 $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) {
205 205
                     $message = $query->getMessage($msgno, $msglist);
206
-                    switch ($options['message_key']){
206
+                    switch ($options['message_key']) {
207 207
                         case 'number':
208 208
                             $message_key = $message->getMessageNo();
209 209
                             break;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
             return $messages;
223 223
         } catch (\Exception $e) {
224
-            throw new GetMessagesFailedException($e->getMessage(),0, $e);
224
+            throw new GetMessagesFailedException($e->getMessage(), 0, $e);
225 225
         }
226 226
     }
227 227
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      * @throws MessageContentFetchingException
238 238
      * @throws MessageHeaderFetchingException
239 239
      */
240
-    public function getMessage($msgno, $msglist = null){
240
+    public function getMessage($msgno, $msglist = null) {
241 241
         return new Message($msgno, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags());
242 242
     }
243 243
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      * @return LengthAwarePaginator
251 251
      * @throws GetMessagesFailedException
252 252
      */
253
-    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
253
+    public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') {
254 254
         $this->page = $page > $this->page ? $page : $this->page;
255 255
         $this->limit = $per_page;
256 256
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
             $messages->each(function($message) use(&$collection){
262 262
                 $collection[] = $message;
263 263
             });
264
-        }else{
264
+        }else {
265 265
             $collection = array_fill(0, $messages->total(), true);
266 266
         }
267 267
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
         $this->query->each(function($statement) use(&$query) {
279 279
             if (count($statement) == 1) {
280 280
                 $query .= $statement[0];
281
-            } else {
282
-                if($statement[1] === null){
281
+            }else {
282
+                if ($statement[1] === null) {
283 283
                     $query .= $statement[0];
284
-                }else{
284
+                }else {
285 285
                     $query .= $statement[0].' "'.$statement[1].'"';
286 286
                 }
287 287
             }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @return $this
312 312
      */
313 313
     public function limit($limit, $page = 1) {
314
-        if($page >= 1) $this->page = $page;
314
+        if ($page >= 1) $this->page = $page;
315 315
         $this->limit = $limit;
316 316
 
317 317
         return $this;
Please login to merge, or discard this patch.
Braces   +11 added lines, -5 removed lines patch added patch discarded remove patch
@@ -73,7 +73,9 @@  discard block
 block discarded – undo
73 73
     public function __construct(Client $client, $charset = 'UTF-8') {
74 74
         $this->setClient($client);
75 75
 
76
-        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread();
76
+        if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) {
77
+            $this->leaveUnread();
78
+        }
77 79
 
78 80
         $this->date_format = ClientManager::get('date_format', 'd M y');
79 81
 
@@ -111,7 +113,9 @@  discard block
 block discarded – undo
111 113
      * @throws MessageSearchValidationException
112 114
      */
113 115
     protected function parse_date($date) {
114
-        if($date instanceof \Carbon\Carbon) return $date;
116
+        if($date instanceof \Carbon\Carbon) {
117
+            return $date;
118
+        }
115 119
 
116 120
         try {
117 121
             $date = Carbon::parse($date);
@@ -261,7 +265,7 @@  discard block
 block discarded – undo
261 265
             $messages->each(function($message) use(&$collection){
262 266
                 $collection[] = $message;
263 267
             });
264
-        }else{
268
+        } else{
265 269
             $collection = array_fill(0, $messages->total(), true);
266 270
         }
267 271
 
@@ -281,7 +285,7 @@  discard block
 block discarded – undo
281 285
             } else {
282 286
                 if($statement[1] === null){
283 287
                     $query .= $statement[0];
284
-                }else{
288
+                } else{
285 289
                     $query .= $statement[0].' "'.$statement[1].'"';
286 290
                 }
287 291
             }
@@ -311,7 +315,9 @@  discard block
 block discarded – undo
311 315
      * @return $this
312 316
      */
313 317
     public function limit($limit, $page = 1) {
314
-        if($page >= 1) $this->page = $page;
318
+        if($page >= 1) {
319
+            $this->page = $page;
320
+        }
315 321
         $this->limit = $limit;
316 322
 
317 323
         return $this;
Please login to merge, or discard this patch.
src/Query/WhereQuery.php 2 patches
Spacing   +16 added lines, -16 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
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      * @return WhereQuery
420 420
      * @throws InvalidWhereQueryCriteriaException
421 421
      */
422
-    public function whereLanguage($country_code){
422
+    public function whereLanguage($country_code) {
423 423
         return $this->where("Content-Language $country_code");
424 424
     }
425 425
 }
426 426
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 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
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
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 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,9 @@  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) {
153
+            $closure($this);
154
+        }
153 155
 
154 156
         return $this;
155 157
     }
@@ -161,7 +163,9 @@  discard block
 block discarded – undo
161 163
      */
162 164
     public function andWhere(\Closure $closure = null) {
163 165
         $this->query->push(['AND']);
164
-        if($closure !== null) $closure($this);
166
+        if($closure !== null) {
167
+            $closure($this);
168
+        }
165 169
 
166 170
         return $this;
167 171
     }
Please login to merge, or discard this patch.
src/ClientManager.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
     public static function get($key, $default = null) {
69 69
         $parts = explode('.', $key);
70 70
         $value = null;
71
-        foreach($parts as $part) {
72
-            if($value === null) {
73
-                if(isset(self::$config[$part])) {
71
+        foreach ($parts as $part) {
72
+            if ($value === null) {
73
+                if (isset(self::$config[$part])) {
74 74
                     $value = self::$config[$part];
75
-                }else{
75
+                }else {
76 76
                     break;
77 77
                 }
78
-            }else{
79
-                if(isset($value[$part])) {
78
+            }else {
79
+                if (isset($value[$part])) {
80 80
                     $value = $value[$part];
81
-                }else{
81
+                }else {
82 82
                     break;
83 83
                 }
84 84
             }
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      */
172 172
     public function setConfig($config) {
173 173
 
174
-        if(is_array($config) === false) {
174
+        if (is_array($config) === false) {
175 175
             $config = require $config;
176 176
         }
177 177
 
@@ -181,17 +181,17 @@  discard block
 block discarded – undo
181 181
         $vendor_config = require $path;
182 182
         $config = $this->array_merge_recursive_distinct($vendor_config, $config);
183 183
 
184
-        if(is_array($config)){
185
-            if(isset($config['default'])){
186
-                if(isset($config['accounts']) && $config['default'] != false){
184
+        if (is_array($config)) {
185
+            if (isset($config['default'])) {
186
+                if (isset($config['accounts']) && $config['default'] != false) {
187 187
 
188 188
                     $default_config = $vendor_config['accounts']['default'];
189
-                    if(isset($config['accounts'][$config['default']])){
189
+                    if (isset($config['accounts'][$config['default']])) {
190 190
                         $default_config = array_merge($default_config, $config['accounts'][$config['default']]);
191 191
                     }
192 192
 
193
-                    if(is_array($config['accounts'])){
194
-                        foreach($config['accounts'] as $account_key => $account){
193
+                    if (is_array($config['accounts'])) {
194
+                        foreach ($config['accounts'] as $account_key => $account) {
195 195
                             $config['accounts'][$account_key] = array_merge($default_config, $account);
196 196
                         }
197 197
                     }
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
         $arrays = func_get_args();
228 228
         $base = array_shift($arrays);
229 229
 
230
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
230
+        if (!is_array($base)) $base = empty($base) ? array() : array($base);
231 231
 
232
-        foreach($arrays as $append) {
232
+        foreach ($arrays as $append) {
233 233
 
234
-            if(!is_array($append)) $append = array($append);
234
+            if (!is_array($append)) $append = array($append);
235 235
 
236
-            foreach($append as $key => $value) {
236
+            foreach ($append as $key => $value) {
237 237
 
238
-                if(!array_key_exists($key, $base) and !is_numeric($key)) {
238
+                if (!array_key_exists($key, $base) and !is_numeric($key)) {
239 239
                     $base[$key] = $append[$key];
240 240
                     continue;
241 241
                 }
242 242
 
243
-                if(is_array($value) or is_array($base[$key])) {
243
+                if (is_array($value) or is_array($base[$key])) {
244 244
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
245
-                } else if(is_numeric($key)) {
246
-                    if(!in_array($value, $base)) $base[] = $value;
247
-                } else {
245
+                }else if (is_numeric($key)) {
246
+                    if (!in_array($value, $base)) $base[] = $value;
247
+                }else {
248 248
                     $base[$key] = $value;
249 249
                 }
250 250
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
             if($value === null) {
73 73
                 if(isset(self::$config[$part])) {
74 74
                     $value = self::$config[$part];
75
-                }else{
75
+                } else{
76 76
                     break;
77 77
                 }
78
-            }else{
78
+            } else{
79 79
                 if(isset($value[$part])) {
80 80
                     $value = $value[$part];
81
-                }else{
81
+                } else{
82 82
                     break;
83 83
                 }
84 84
             }
@@ -227,11 +227,15 @@  discard block
 block discarded – undo
227 227
         $arrays = func_get_args();
228 228
         $base = array_shift($arrays);
229 229
 
230
-        if(!is_array($base)) $base = empty($base) ? array() : array($base);
230
+        if(!is_array($base)) {
231
+            $base = empty($base) ? array() : array($base);
232
+        }
231 233
 
232 234
         foreach($arrays as $append) {
233 235
 
234
-            if(!is_array($append)) $append = array($append);
236
+            if(!is_array($append)) {
237
+                $append = array($append);
238
+            }
235 239
 
236 240
             foreach($append as $key => $value) {
237 241
 
@@ -243,7 +247,9 @@  discard block
 block discarded – undo
243 247
                 if(is_array($value) or is_array($base[$key])) {
244 248
                     $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]);
245 249
                 } else if(is_numeric($key)) {
246
-                    if(!in_array($value, $base)) $base[] = $value;
250
+                    if(!in_array($value, $base)) {
251
+                        $base[] = $value;
252
+                    }
247 253
                 } else {
248 254
                     $base[$key] = $value;
249 255
                 }
Please login to merge, or discard this patch.
examples/message_table.blade.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
     </tr>
27 27
     </thead>
28 28
     <tbody>
29
-    <?php if($paginator->count() > 0): ?>
30
-        <?php foreach($paginator as $message): ?>
29
+    <?php if ($paginator->count() > 0): ?>
30
+        <?php foreach ($paginator as $message): ?>
31 31
             <tr>
32 32
                 <td><?php echo $message->getUid(); ?></td>
33 33
                 <td><?php echo $message->getSubject(); ?></td>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,11 +35,14 @@
 block discarded – undo
35 35
                 <td><?php echo $message->getAttachments()->count() > 0 ? 'yes' : 'no'; ?></td>
36 36
             </tr>
37 37
         <?php endforeach; ?>
38
-    <?php else: ?>
38
+    <?php else {
39
+    : ?>
39 40
         <tr>
40 41
             <td colspan="4">No messages found</td>
41 42
         </tr>
42
-    <?php endif; ?>
43
+    <?php endif;
44
+}
45
+?>
43 46
     </tbody>
44 47
 </table>
45 48
 
Please login to merge, or discard this patch.
examples/folder_structure.blade.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@
 block discarded – undo
24 24
     </tr>
25 25
     </thead>
26 26
     <tbody>
27
-    <?php if($paginator->count() > 0): ?>
28
-        <?php foreach($paginator as $folder): ?>
27
+    <?php if ($paginator->count() > 0): ?>
28
+        <?php foreach ($paginator as $folder): ?>
29 29
                 <tr>
30 30
                     <td><?php echo $folder->name; ?></td>
31 31
                     <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td>
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,11 +31,14 @@
 block discarded – undo
31 31
                     <td><?php echo $folder->search()->unseen()->setFetchBody(false)->count(); ?></td>
32 32
                 </tr>
33 33
         <?php endforeach; ?>
34
-    <?php else: ?>
34
+    <?php else {
35
+    : ?>
35 36
         <tr>
36 37
             <td colspan="4">No folders found</td>
37 38
         </tr>
38
-    <?php endif; ?>
39
+    <?php endif;
40
+}
41
+?>
39 42
     </tbody>
40 43
 </table>
41 44
 
Please login to merge, or discard this patch.
src/Header.php 2 patches
Braces   +11 added lines, -7 removed lines patch added patch discarded remove patch
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                 if ($prev_header !== null) {
169 169
                     $headers[$prev_header][] = $line;
170 170
                 }
171
-            }else{
171
+            } else{
172 172
                 if (($pos = strpos($line, ":")) > 0) {
173 173
                     $key = strtolower(substr($line, 0, $pos));
174 174
                     $value = trim(rtrim(strtolower(substr($line, $pos + 1))));
@@ -179,7 +179,9 @@  discard block
 block discarded – undo
179 179
         }
180 180
 
181 181
         foreach($headers as $key => $values) {
182
-            if (isset($imap_headers[$key])) continue;
182
+            if (isset($imap_headers[$key])) {
183
+                continue;
184
+            }
183 185
             $value = null;
184 186
             switch($key){
185 187
                 case 'from':
@@ -297,9 +299,9 @@  discard block
 block discarded – undo
297 299
                     return EncodingAliases::get($parameter->value, $this->fallback_encoding);
298 300
                 }
299 301
             }
300
-        }elseif (property_exists($structure, 'charset')) {
302
+        } elseif (property_exists($structure, 'charset')) {
301 303
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
302
-        }elseif (is_string($structure) === true){
304
+        } elseif (is_string($structure) === true){
303 305
             return mb_detect_encoding($structure);
304 306
         }
305 307
 
@@ -330,9 +332,9 @@  discard block
 block discarded – undo
330 332
                         }
331 333
                     }
332 334
                 }
333
-            }elseif($decoder === 'iconv') {
335
+            } elseif($decoder === 'iconv') {
334 336
                 $value = iconv_mime_decode($value);
335
-            }else{
337
+            } else{
336 338
                 $value = mb_decode_mimeheader($value);
337 339
             }
338 340
 
@@ -352,7 +354,9 @@  discard block
 block discarded – undo
352 354
      * Try to extract the priority from a given raw header string
353 355
      */
354 356
     private function findPriority() {
355
-        if(($priority = $this->get("x-priority")) === null) return;
357
+        if(($priority = $this->get("x-priority")) === null) {
358
+            return;
359
+        }
356 360
         switch($priority){
357 361
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
358 362
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
      * @throws MethodNotFoundException
74 74
      */
75 75
     public function __call($method, $arguments) {
76
-        if(strtolower(substr($method, 0, 3)) === 'get') {
76
+        if (strtolower(substr($method, 0, 3)) === 'get') {
77 77
             $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3));
78 78
 
79
-            if(in_array($name, array_keys($this->attributes))) {
79
+            if (in_array($name, array_keys($this->attributes))) {
80 80
                 return $this->attributes[$name];
81 81
             }
82 82
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      * @return mixed|null
103 103
      */
104 104
     public function get($name) {
105
-        if(isset($this->attributes[$name])) {
105
+        if (isset($this->attributes[$name])) {
106 106
             return $this->attributes[$name];
107 107
         }
108 108
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function find($pattern) {
119 119
         if (preg_match_all($pattern, $this->raw, $matches)) {
120 120
             if (isset($matches[1])) {
121
-                if(count($matches[1]) > 0) {
121
+                if (count($matches[1]) > 0) {
122 122
                     return $matches[1][0];
123 123
                 }
124 124
             }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      *
132 132
      * @throws InvalidMessageDateException
133 133
      */
134
-    protected function parse(){
134
+    protected function parse() {
135 135
         $header = $this->rfc822_parse_headers($this->raw);
136 136
 
137 137
         $this->extractAddresses($header);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         $this->parseDate($header);
150 150
         foreach ($header as $key => $value) {
151 151
             $key = trim(rtrim(strtolower($key)));
152
-            if(!isset($this->attributes[$key])){
152
+            if (!isset($this->attributes[$key])) {
153 153
                 $this->attributes[$key] = $value;
154 154
             }
155 155
         }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
      *
166 166
      * @return object
167 167
      */
168
-    public function rfc822_parse_headers($raw_headers){
168
+    public function rfc822_parse_headers($raw_headers) {
169 169
         $headers = [];
170 170
         $imap_headers = [];
171 171
         if (extension_loaded('imap')) {
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
 
175 175
         $lines = explode("\r\n", $raw_headers);
176 176
         $prev_header = null;
177
-        foreach($lines as $line) {
177
+        foreach ($lines as $line) {
178 178
             if (substr($line, 0, 1) === "\t") {
179 179
                 $line = substr($line, 2);
180 180
                 if ($prev_header !== null) {
181 181
                     $headers[$prev_header][] = $line;
182 182
                 }
183
-            }else{
183
+            }else {
184 184
                 if (($pos = strpos($line, ":")) > 0) {
185 185
                     $key = strtolower(substr($line, 0, $pos));
186 186
                     $value = trim(rtrim(strtolower(substr($line, $pos + 1))));
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
             }
191 191
         }
192 192
 
193
-        foreach($headers as $key => $values) {
193
+        foreach ($headers as $key => $values) {
194 194
             if (isset($imap_headers[$key])) continue;
195 195
             $value = null;
196
-            switch($key){
196
+            switch ($key) {
197 197
                 case 'from':
198 198
                 case 'to':
199 199
                 case 'cc':
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
      * @return array The decoded elements are returned in an array of objects, where each
222 222
      * object has two properties, charset and text.
223 223
      */
224
-    public function mime_header_decode($text){
224
+    public function mime_header_decode($text) {
225 225
         if (extension_loaded('imap')) {
226 226
             return \imap_mime_header_decode($text);
227 227
         }
228 228
         $charset = $this->getEncoding($text);
229
-        return [(object)[
229
+        return [(object) [
230 230
             "charset" => $charset,
231 231
             "text" => $this->convertEncoding($text, $charset)
232 232
         ]];
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         try {
281 281
             if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') {
282 282
                 return iconv($from, $to, $str);
283
-            } else {
283
+            }else {
284 284
                 if (!$from) {
285 285
                     return mb_convert_encoding($str, $to);
286 286
                 }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             if (strstr($from, '-')) {
291 291
                 $from = str_replace('-', '', $from);
292 292
                 return $this->convertEncoding($str, $from, $to);
293
-            } else {
293
+            }else {
294 294
                 return $str;
295 295
             }
296 296
         }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
             }
312 312
         }elseif (property_exists($structure, 'charset')) {
313 313
             return EncodingAliases::get($structure->charset, $this->fallback_encoding);
314
-        }elseif (is_string($structure) === true){
314
+        }elseif (is_string($structure) === true) {
315 315
             return mb_detect_encoding($structure);
316 316
         }
317 317
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         $decoder = $this->config['decoder']['message'];
330 330
 
331 331
         if ($value !== null) {
332
-            if($decoder === 'utf-8' && extension_loaded('imap')) {
332
+            if ($decoder === 'utf-8' && extension_loaded('imap')) {
333 333
                 $value = \imap_utf8($value);
334 334
                 if (strpos(strtolower($value), '=?utf-8?') === 0) {
335 335
                     $value = mb_decode_mimeheader($value);
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
                 if ($this->notDecoded($original_value, $value)) {
338 338
                     $decoded_value = $this->mime_header_decode($value);
339 339
                     if (count($decoded_value) > 0) {
340
-                        if(property_exists($decoded_value[0], "text")) {
340
+                        if (property_exists($decoded_value[0], "text")) {
341 341
                             $value = $decoded_value[0]->text;
342 342
                         }
343 343
                     }
344 344
                 }
345
-            }elseif($decoder === 'iconv') {
345
+            }elseif ($decoder === 'iconv') {
346 346
                 $value = iconv_mime_decode($value);
347
-            }else{
347
+            }else {
348 348
                 $value = mb_decode_mimeheader($value);
349 349
             }
350 350
 
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
      * Try to extract the priority from a given raw header string
365 365
      */
366 366
     private function findPriority() {
367
-        if(($priority = $this->get("x-priority")) === null) return;
368
-        switch($priority){
367
+        if (($priority = $this->get("x-priority")) === null) return;
368
+        switch ($priority) {
369 369
             case IMAP::MESSAGE_PRIORITY_HIGHEST;
370 370
                 $priority = IMAP::MESSAGE_PRIORITY_HIGHEST;
371 371
                 break;
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
      */
398 398
     private function decodeAddresses($values) {
399 399
         $addresses = [];
400
-        foreach($values as $address) {
400
+        foreach ($values as $address) {
401 401
             if (preg_match(
402 402
                 '/^(?:(?P<name>.+)\s)?(?(name)<|<?)(?P<email>[^\s]+?)(?(name)>|>?)$/',
403 403
                 $address,
404 404
                 $matches
405
-            )){
405
+            )) {
406 406
                 $name = trim(rtrim($matches["name"]));
407 407
                 $email = trim(rtrim($matches["email"]));
408 408
                 list($mailbox, $host) = explode("@", $email);
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      * @param object $header
422 422
      */
423 423
     private function extractAddresses($header) {
424
-        foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key){
424
+        foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender', 'in_reply_to'] as $key) {
425 425
             if (property_exists($header, $key)) {
426 426
                 $this->attributes[$key] = $this->parseAddresses($header->$key);
427 427
             }
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
             }
449 449
             if (!property_exists($address, 'personal')) {
450 450
                 $address->personal = false;
451
-            } else {
451
+            }else {
452 452
                 $personalParts = $this->mime_header_decode($address->personal);
453 453
 
454
-                if(is_array($personalParts)) {
454
+                if (is_array($personalParts)) {
455 455
                     $address->personal = '';
456 456
                     foreach ($personalParts as $p) {
457 457
                         $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p));
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
     /**
472 472
      * Search and extract potential header extensions
473 473
      */
474
-    private function extractHeaderExtensions(){
474
+    private function extractHeaderExtensions() {
475 475
         foreach ($this->attributes as $key => $value) {
476 476
             if (is_string($value) === true) {
477
-                if (($pos = strpos($value, ";")) !== false){
477
+                if (($pos = strpos($value, ";")) !== false) {
478 478
                     $original = substr($value, 0, $pos);
479 479
                     $this->attributes[$key] = trim(rtrim($original));
480 480
                     $extensions = explode(";", substr($value, $pos + 1));
481
-                    foreach($extensions as $extension) {
482
-                        if (($pos = strpos($extension, "=")) !== false){
481
+                    foreach ($extensions as $extension) {
482
+                        if (($pos = strpos($extension, "=")) !== false) {
483 483
                             $key = substr($extension, 0, $pos);
484 484
                             $value = substr($extension, $pos + 1);
485 485
                             $value = str_replace('"', "", $value);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             $parsed_date = null;
517 517
             $date = $header->date;
518 518
 
519
-            if(preg_match('/\+0580/', $date)) {
519
+            if (preg_match('/\+0580/', $date)) {
520 520
                 $date = str_replace('+0580', '+0530', $date);
521 521
             }
522 522
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
                         $date = trim(array_pop($array));
540 540
                         break;
541 541
                 }
542
-                try{
542
+                try {
543 543
                     $parsed_date = Carbon::parse($date);
544 544
                 } catch (\Exception $_e) {
545 545
                     throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e);
Please login to merge, or discard this patch.