@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function __construct(Client $client, $charset = 'UTF-8') { |
70 | 70 | $this->setClient($client); |
71 | 71 | |
72 | - if(config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
72 | + if (config('imap.options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
73 | 73 | |
74 | 74 | $this->date_format = config('imap.date_format', 'd M y'); |
75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * Instance boot method for additional functionality |
83 | 83 | */ |
84 | - protected function boot(){} |
|
84 | + protected function boot() {} |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Parse a given value |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - protected function parse_value($value){ |
|
93 | - switch(true){ |
|
92 | + protected function parse_value($value) { |
|
93 | + switch (true) { |
|
94 | 94 | case $value instanceof \Carbon\Carbon: |
95 | 95 | $value = $value->format($this->date_format); |
96 | 96 | break; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @throws MessageSearchValidationException |
108 | 108 | */ |
109 | 109 | protected function parse_date($date) { |
110 | - if($date instanceof \Carbon\Carbon) return $date; |
|
110 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
111 | 111 | |
112 | 112 | try { |
113 | 113 | $date = Carbon::parse($date); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return \Illuminate\Support\Collection |
147 | 147 | * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException |
148 | 148 | */ |
149 | - protected function search(){ |
|
149 | + protected function search() { |
|
150 | 150 | $this->generate_query(); |
151 | 151 | $available_messages = []; |
152 | 152 | |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | try { |
160 | 160 | if ($this->getCharset() == null) { |
161 | 161 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID); |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $available_messages = \imap_search($this->getClient()->getConnection(), $this->getRawQuery(), IMAP::SE_UID, $this->getCharset()); |
164 | 164 | } |
165 | 165 | } catch (\Exception $e) { |
166 | 166 | if (strpos($e, ' [BADCHARSET (')) { |
167 | 167 | preg_match('/ \[BADCHARSET \((.*)\)\]/', $e, $matches); |
168 | 168 | if (isset($matches[1])) { |
169 | - if ($matches[1] !== $this->getCharset()){ |
|
169 | + if ($matches[1] !== $this->getCharset()) { |
|
170 | 170 | $this->setCharset($matches[1]); |
171 | 171 | return $this->search(); |
172 | 172 | } |
@@ -210,15 +210,15 @@ discard block |
||
210 | 210 | |
211 | 211 | $options = config('imap.options'); |
212 | 212 | |
213 | - if(strtolower($options['fetch_order']) === 'desc'){ |
|
213 | + if (strtolower($options['fetch_order']) === 'desc') { |
|
214 | 214 | $available_messages = $available_messages->reverse(); |
215 | 215 | } |
216 | 216 | |
217 | - $query =& $this; |
|
217 | + $query = & $this; |
|
218 | 218 | |
219 | 219 | $available_messages->forPage($this->page, $this->limit)->each(function($msgno, $msglist) use(&$messages, $options, $query) { |
220 | 220 | $oMessage = new Message($msgno, $msglist, $query->getClient(), $query->getFetchOptions(), $query->getFetchBody(), $query->getFetchAttachment(), $query->getFetchFlags()); |
221 | - switch ($options['message_key']){ |
|
221 | + switch ($options['message_key']) { |
|
222 | 222 | case 'number': |
223 | 223 | $message_key = $oMessage->getMessageNo(); |
224 | 224 | break; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @return \Illuminate\Pagination\LengthAwarePaginator |
250 | 250 | * @throws GetMessagesFailedException |
251 | 251 | */ |
252 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
252 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
253 | 253 | $this->page = $page > $this->page ? $page : $this->page; |
254 | 254 | $this->limit = $per_page; |
255 | 255 | |
@@ -264,13 +264,13 @@ discard block |
||
264 | 264 | * @throws \Webklex\IMAP\Exceptions\ConnectionFailedException |
265 | 265 | * @throws \Webklex\IMAP\Exceptions\InvalidMessageDateException |
266 | 266 | */ |
267 | - public function idle(callable $callback = null, $timeout = 10){ |
|
267 | + public function idle(callable $callback = null, $timeout = 10) { |
|
268 | 268 | $known_messages = []; |
269 | 269 | $this->getClient()->overview()->each(function($message) use(&$known_messages){ |
270 | 270 | /** @var object $message */ |
271 | 271 | $known_messages[] = $message->uid; |
272 | 272 | }); |
273 | - while ($this->getClient()->isConnected()){ |
|
273 | + while ($this->getClient()->isConnected()) { |
|
274 | 274 | $this->getClient()->expunge(); |
275 | 275 | $new_messages = []; |
276 | 276 | $this->getClient()->overview()->each(function($message) use(&$new_messages, &$known_messages){ |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | } |
282 | 282 | }); |
283 | 283 | |
284 | - foreach($new_messages as $msg) { |
|
284 | + foreach ($new_messages as $msg) { |
|
285 | 285 | $message = new Message($msg->uid, $msg->msgno, $this->getClient()); |
286 | 286 | MessageNewEvent::dispatch($message); |
287 | - if ($callback){ |
|
287 | + if ($callback) { |
|
288 | 288 | $callback($message); |
289 | 289 | } |
290 | 290 | } |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | if (count($statement) == 1) { |
305 | 305 | $query .= $statement[0]; |
306 | 306 | } else { |
307 | - if($statement[1] === null){ |
|
307 | + if ($statement[1] === null) { |
|
308 | 308 | $query .= $statement[0]; |
309 | - }else{ |
|
309 | + } else { |
|
310 | 310 | $query .= $statement[0].' "'.$statement[1].'"'; |
311 | 311 | } |
312 | 312 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @return $this |
337 | 337 | */ |
338 | 338 | public function limit($limit, $page = 1) { |
339 | - if($page >= 1) $this->page = $page; |
|
339 | + if ($page >= 1) $this->page = $page; |
|
340 | 340 | $this->limit = $limit; |
341 | 341 | |
342 | 342 | return $this; |