@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return null |
32 | 32 | */ |
33 | - public function getHtmlBody(){ |
|
33 | + public function getHtmlBody() { |
|
34 | 34 | $bodies = $this->parent->getBodies(); |
35 | 35 | if (!isset($bodies['html'])) { |
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | |
39 | - if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
39 | + if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
40 | 40 | return $bodies['html']->content; |
41 | 41 | } |
42 | 42 | return $bodies['html']; |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function getCustomHTMLBody($callback = false) { |
52 | 52 | $body = $this->getHtmlBody(); |
53 | - if($body === null) return null; |
|
53 | + if ($body === null) return null; |
|
54 | 54 | |
55 | 55 | if ($callback !== false) { |
56 | 56 | $aAttachment = $this->parent->getAttachments(); |
57 | 57 | $aAttachment->each(function($oAttachment) use(&$body, $callback) { |
58 | 58 | /** @var Attachment $oAttachment */ |
59 | - if(is_callable($callback)) { |
|
59 | + if (is_callable($callback)) { |
|
60 | 60 | $body = $callback($body, $oAttachment); |
61 | - }elseif(is_string($callback)) { |
|
61 | + }elseif (is_string($callback)) { |
|
62 | 62 | call_user_func($callback, [$body, $oAttachment]); |
63 | 63 | } |
64 | 64 | }); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @return string|null |
75 | 75 | */ |
76 | 76 | public function getHTMLBodyWithEmbeddedBase64Images() { |
77 | - return $this->getCustomHTMLBody(function($body, $oAttachment){ |
|
77 | + return $this->getCustomHTMLBody(function($body, $oAttachment) { |
|
78 | 78 | /** @var Attachment $oAttachment */ |
79 | 79 | if ($oAttachment->id) { |
80 | 80 | $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body); |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | * @param array $config |
204 | 204 | * @param array $default_config |
205 | 205 | */ |
206 | - private function setAccountConfig($key, $config, $default_config){ |
|
206 | + private function setAccountConfig($key, $config, $default_config) { |
|
207 | 207 | $value = $this->default_account_config[$key]; |
208 | - if(isset($config[$key])) { |
|
208 | + if (isset($config[$key])) { |
|
209 | 209 | $value = $config[$key]; |
210 | - }elseif(isset($default_config[$key])) { |
|
210 | + }elseif (isset($default_config[$key])) { |
|
211 | 211 | $value = $default_config[$key]; |
212 | 212 | } |
213 | 213 | $this->$key = $value; |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | */ |
220 | 220 | protected function setEventsFromConfig($config) { |
221 | 221 | $this->events = ClientManager::get("events"); |
222 | - if(isset($config['events'])){ |
|
223 | - foreach($config['events'] as $section => $events) { |
|
222 | + if (isset($config['events'])) { |
|
223 | + foreach ($config['events'] as $section => $events) { |
|
224 | 224 | $this->events[$section] = array_merge($this->events[$section], $events); |
225 | 225 | } |
226 | 226 | } |
@@ -233,45 +233,45 @@ discard block |
||
233 | 233 | * @throws MaskNotFoundException |
234 | 234 | */ |
235 | 235 | protected function setMaskFromConfig($config) { |
236 | - $default_config = ClientManager::get("masks"); |
|
236 | + $default_config = ClientManager::get("masks"); |
|
237 | 237 | |
238 | - if(isset($config['masks'])){ |
|
239 | - if(isset($config['masks']['message'])) { |
|
240 | - if(class_exists($config['masks']['message'])) { |
|
238 | + if (isset($config['masks'])) { |
|
239 | + if (isset($config['masks']['message'])) { |
|
240 | + if (class_exists($config['masks']['message'])) { |
|
241 | 241 | $this->default_message_mask = $config['masks']['message']; |
242 | - }else{ |
|
242 | + }else { |
|
243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
244 | 244 | } |
245 | - }else{ |
|
246 | - if(class_exists($default_config['message'])) { |
|
245 | + }else { |
|
246 | + if (class_exists($default_config['message'])) { |
|
247 | 247 | $this->default_message_mask = $default_config['message']; |
248 | - }else{ |
|
248 | + }else { |
|
249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
250 | 250 | } |
251 | 251 | } |
252 | - if(isset($config['masks']['attachment'])) { |
|
253 | - if(class_exists($config['masks']['attachment'])) { |
|
252 | + if (isset($config['masks']['attachment'])) { |
|
253 | + if (class_exists($config['masks']['attachment'])) { |
|
254 | 254 | $this->default_attachment_mask = $config['masks']['attachment']; |
255 | - }else{ |
|
255 | + }else { |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
257 | 257 | } |
258 | - }else{ |
|
259 | - if(class_exists($default_config['attachment'])) { |
|
258 | + }else { |
|
259 | + if (class_exists($default_config['attachment'])) { |
|
260 | 260 | $this->default_attachment_mask = $default_config['attachment']; |
261 | - }else{ |
|
261 | + }else { |
|
262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
263 | 263 | } |
264 | 264 | } |
265 | - }else{ |
|
266 | - if(class_exists($default_config['message'])) { |
|
265 | + }else { |
|
266 | + if (class_exists($default_config['message'])) { |
|
267 | 267 | $this->default_message_mask = $default_config['message']; |
268 | - }else{ |
|
268 | + }else { |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
270 | 270 | } |
271 | 271 | |
272 | - if(class_exists($default_config['attachment'])) { |
|
272 | + if (class_exists($default_config['attachment'])) { |
|
273 | 273 | $this->default_attachment_mask = $default_config['attachment']; |
274 | - }else{ |
|
274 | + }else { |
|
275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
276 | 276 | } |
277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
337 | 337 | $this->connection->setProxy($this->proxy); |
338 | - }else{ |
|
338 | + }else { |
|
339 | 339 | if (extension_loaded('imap') === false) { |
340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
341 | 341 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | |
409 | 409 | // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names) |
410 | 410 | $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter; |
411 | - if (strpos($folder_name, (string)$delimiter) !== false) { |
|
411 | + if (strpos($folder_name, (string) $delimiter) !== false) { |
|
412 | 412 | return $this->getFolderByPath($folder_name); |
413 | 413 | } |
414 | 414 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
461 | 461 | $items = $this->connection->folders('', $pattern); |
462 | 462 | |
463 | - if(is_array($items)){ |
|
463 | + if (is_array($items)) { |
|
464 | 464 | foreach ($items as $folder_name => $item) { |
465 | 465 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
466 | 466 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | } |
476 | 476 | |
477 | 477 | return $folders; |
478 | - }else{ |
|
478 | + }else { |
|
479 | 479 | throw new FolderFetchingException("failed to fetch any folders"); |
480 | 480 | } |
481 | 481 | } |
@@ -513,10 +513,10 @@ discard block |
||
513 | 513 | $this->checkConnection(); |
514 | 514 | $status = $this->connection->createFolder($folder); |
515 | 515 | |
516 | - if($expunge) $this->expunge(); |
|
516 | + if ($expunge) $this->expunge(); |
|
517 | 517 | |
518 | 518 | $folder = $this->getFolder($folder); |
519 | - if($status && $folder) { |
|
519 | + if ($status && $folder) { |
|
520 | 520 | $event = $this->getEvent("folder", "new"); |
521 | 521 | $event::dispatch($folder); |
522 | 522 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return string |
544 | 544 | */ |
545 | - public function getFolderPath(){ |
|
545 | + public function getFolderPath() { |
|
546 | 546 | return $this->active_folder; |
547 | 547 | } |
548 | 548 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @return int |
601 | 601 | * @throws ConnectionFailedException |
602 | 602 | */ |
603 | - public function getTimeout(){ |
|
603 | + public function getTimeout() { |
|
604 | 604 | $this->checkConnection(); |
605 | 605 | return $this->connection->getConnectionTimeout(); |
606 | 606 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string |
612 | 612 | */ |
613 | - public function getDefaultMessageMask(){ |
|
613 | + public function getDefaultMessageMask() { |
|
614 | 614 | return $this->default_message_mask; |
615 | 615 | } |
616 | 616 | |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return array |
622 | 622 | */ |
623 | - public function getDefaultEvents($section){ |
|
623 | + public function getDefaultEvents($section) { |
|
624 | 624 | return $this->events[$section]; |
625 | 625 | } |
626 | 626 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @throws MaskNotFoundException |
633 | 633 | */ |
634 | 634 | public function setDefaultMessageMask($mask) { |
635 | - if(class_exists($mask)) { |
|
635 | + if (class_exists($mask)) { |
|
636 | 636 | $this->default_message_mask = $mask; |
637 | 637 | |
638 | 638 | return $this; |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * |
647 | 647 | * @return string |
648 | 648 | */ |
649 | - public function getDefaultAttachmentMask(){ |
|
649 | + public function getDefaultAttachmentMask() { |
|
650 | 650 | return $this->default_attachment_mask; |
651 | 651 | } |
652 | 652 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @throws MaskNotFoundException |
659 | 659 | */ |
660 | 660 | public function setDefaultAttachmentMask($mask) { |
661 | - if(class_exists($mask)) { |
|
661 | + if (class_exists($mask)) { |
|
662 | 662 | $this->default_attachment_mask = $mask; |
663 | 663 | |
664 | 664 | return $this; |
@@ -233,7 +233,7 @@ |
||
233 | 233 | return "UID"; |
234 | 234 | } |
235 | 235 | if (strlen($uid) > 0 && !is_numeric($uid)) { |
236 | - return (string)$uid; |
|
236 | + return (string) $uid; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | return ""; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $this->setDelimiter($delimiter); |
124 | 124 | $this->path = $folder_name; |
125 | - $this->full_name = $this->decodeName($folder_name); |
|
125 | + $this->full_name = $this->decodeName($folder_name); |
|
126 | 126 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
127 | 127 | |
128 | 128 | $this->parseAttributes($attributes); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @throws Exceptions\ConnectionFailedException |
137 | 137 | * @throws Exceptions\RuntimeException |
138 | 138 | */ |
139 | - public function query($extensions = []){ |
|
139 | + public function query($extensions = []) { |
|
140 | 140 | $this->getClient()->checkConnection(); |
141 | 141 | $this->getClient()->openFolder($this->path); |
142 | 142 | $extensions = count($extensions) > 0 ? $extensions : $this->getClient()->extensions; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @throws Exceptions\ConnectionFailedException |
150 | 150 | * @throws Exceptions\RuntimeException |
151 | 151 | */ |
152 | - public function search($extensions = 'UTF-8'){ |
|
152 | + public function search($extensions = 'UTF-8') { |
|
153 | 153 | return $this->query($extensions); |
154 | 154 | } |
155 | 155 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @throws Exceptions\ConnectionFailedException |
159 | 159 | * @throws Exceptions\RuntimeException |
160 | 160 | */ |
161 | - public function messages($extensions = []){ |
|
161 | + public function messages($extensions = []) { |
|
162 | 162 | return $this->query($extensions); |
163 | 163 | } |
164 | 164 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | public function move($new_name, $expunge = true) { |
234 | 234 | $this->client->checkConnection(); |
235 | 235 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
236 | - if($expunge) $this->client->expunge(); |
|
236 | + if ($expunge) $this->client->expunge(); |
|
237 | 237 | |
238 | 238 | $folder = $this->client->getFolder($new_name); |
239 | 239 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @throws Exceptions\MessageNotFoundException |
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 |
||
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 |
||
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); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | try { |
373 | 373 | $line = $connection->nextLine(); |
374 | 374 | if (($pos = strpos($line, "EXISTS")) !== false) { |
375 | - $msgn = (int) substr($line, 2, $pos -2); |
|
375 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
376 | 376 | $connection->done(); |
377 | 377 | |
378 | 378 | $this->client->openFolder($this->path, true); |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | |
386 | 386 | $connection->idle(); |
387 | 387 | } |
388 | - }catch (Exceptions\RuntimeException $e) { |
|
389 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
388 | + } catch (Exceptions\RuntimeException $e) { |
|
389 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
390 | 390 | throw $e; |
391 | 391 | } |
392 | 392 | if ($auto_reconnect === true) { |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | * Set the delimiter |
436 | 436 | * @param $delimiter |
437 | 437 | */ |
438 | - public function setDelimiter($delimiter){ |
|
439 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
438 | + public function setDelimiter($delimiter) { |
|
439 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
440 | 440 | $delimiter = ClientManager::get('options.delimiter', '/'); |
441 | 441 | } |
442 | 442 |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $this->boot(); |
193 | 193 | |
194 | 194 | $default_mask = $client->getDefaultMessageMask(); |
195 | - if($default_mask != null) { |
|
195 | + if ($default_mask != null) { |
|
196 | 196 | $this->mask = $default_mask; |
197 | 197 | } |
198 | 198 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | * @throws Exceptions\RuntimeException |
247 | 247 | * @throws Exceptions\MessageNotFoundException |
248 | 248 | */ |
249 | - public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){ |
|
249 | + public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) { |
|
250 | 250 | $reflection = new ReflectionClass(self::class); |
251 | 251 | /** @var self $instance */ |
252 | 252 | $instance = $reflection->newInstanceWithoutConstructor(); |
253 | 253 | $instance->boot(); |
254 | 254 | |
255 | 255 | $default_mask = $client->getDefaultMessageMask(); |
256 | - if($default_mask != null) { |
|
256 | + if ($default_mask != null) { |
|
257 | 257 | $instance->setMask($default_mask); |
258 | 258 | } |
259 | 259 | $instance->setEvents([ |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Boot a new instance |
280 | 280 | */ |
281 | - public function boot(){ |
|
281 | + public function boot() { |
|
282 | 282 | $this->attributes = []; |
283 | 283 | |
284 | 284 | $this->config = ClientManager::get('options'); |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * @throws MethodNotFoundException |
298 | 298 | */ |
299 | 299 | public function __call($method, $arguments) { |
300 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
300 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
301 | 301 | $name = Str::snake(substr($method, 3)); |
302 | 302 | return $this->get($name); |
303 | 303 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
304 | 304 | $name = Str::snake(substr($method, 3)); |
305 | 305 | |
306 | - if(in_array($name, array_keys($this->attributes))) { |
|
306 | + if (in_array($name, array_keys($this->attributes))) { |
|
307 | 307 | return $this->__set($name, array_pop($arguments)); |
308 | 308 | } |
309 | 309 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @return Attribute|mixed|null |
343 | 343 | */ |
344 | 344 | public function get($name) { |
345 | - if(isset($this->attributes[$name])) { |
|
345 | + if (isset($this->attributes[$name])) { |
|
346 | 346 | return $this->attributes[$name]; |
347 | 347 | } |
348 | 348 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * |
417 | 417 | * @throws InvalidMessageDateException |
418 | 418 | */ |
419 | - public function parseRawHeader($raw_header){ |
|
419 | + public function parseRawHeader($raw_header) { |
|
420 | 420 | $this->header = new Header($raw_header); |
421 | 421 | } |
422 | 422 | |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | public function parseRawFlags($raw_flags) { |
428 | 428 | $this->flags = FlagCollection::make([]); |
429 | 429 | |
430 | - foreach($raw_flags as $flag) { |
|
431 | - if (strpos($flag, "\\") === 0){ |
|
430 | + foreach ($raw_flags as $flag) { |
|
431 | + if (strpos($flag, "\\") === 0) { |
|
432 | 432 | $flag = substr($flag, 1); |
433 | 433 | } |
434 | 434 | $flag_key = strtolower($flag); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @throws MessageFlagException |
502 | 502 | * @throws Exceptions\RuntimeException |
503 | 503 | */ |
504 | - public function peek(){ |
|
504 | + public function peek() { |
|
505 | 505 | if ($this->fetch_options == IMAP::FT_PEEK) { |
506 | 506 | if ($this->getFlags()->get("seen") == null) { |
507 | 507 | $this->unsetFlag("Seen"); |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | private function fetchPart(Part $part) { |
551 | 551 | if ($part->isAttachment()) { |
552 | 552 | $this->fetchAttachment($part); |
553 | - }else{ |
|
553 | + }else { |
|
554 | 554 | $encoding = $this->getEncoding($part); |
555 | 555 | |
556 | 556 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | if (isset($this->bodies[$subtype])) { |
577 | 577 | $this->bodies[$subtype] .= "\n".$content; |
578 | - }else{ |
|
578 | + }else { |
|
579 | 579 | $this->bodies[$subtype] = $content; |
580 | 580 | } |
581 | 581 | } |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
592 | 592 | if ($oAttachment->getId() !== null) { |
593 | 593 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
594 | - } else { |
|
594 | + }else { |
|
595 | 595 | $this->attachments->push($oAttachment); |
596 | 596 | } |
597 | 597 | } |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | |
726 | 726 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
727 | 727 | return @iconv($from, $to.'//IGNORE', $str); |
728 | - } else { |
|
728 | + }else { |
|
729 | 729 | if (!$from) { |
730 | 730 | return mb_convert_encoding($str, $to); |
731 | 731 | } |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | return EncodingAliases::get($parameter->value); |
747 | 747 | } |
748 | 748 | } |
749 | - }elseif (property_exists($structure, 'charset')){ |
|
749 | + }elseif (property_exists($structure, 'charset')) { |
|
750 | 750 | return EncodingAliases::get($structure->charset); |
751 | - }elseif (is_string($structure) === true){ |
|
751 | + }elseif (is_string($structure) === true) { |
|
752 | 752 | return mb_detect_encoding($structure); |
753 | 753 | } |
754 | 754 | |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | * @throws Exceptions\FolderFetchingException |
764 | 764 | * @throws Exceptions\RuntimeException |
765 | 765 | */ |
766 | - public function getFolder(){ |
|
766 | + public function getFolder() { |
|
767 | 767 | return $this->client->getFolderByPath($this->folder_path); |
768 | 768 | } |
769 | 769 | |
@@ -779,13 +779,13 @@ discard block |
||
779 | 779 | * @throws Exceptions\GetMessagesFailedException |
780 | 780 | * @throws Exceptions\RuntimeException |
781 | 781 | */ |
782 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
782 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
783 | 783 | $thread = $thread ? $thread : MessageCollection::make([]); |
784 | - $folder = $folder ? $folder : $this->getFolder(); |
|
784 | + $folder = $folder ? $folder : $this->getFolder(); |
|
785 | 785 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolderByPath(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
786 | 786 | |
787 | 787 | /** @var Message $message */ |
788 | - foreach($thread as $message) { |
|
788 | + foreach ($thread as $message) { |
|
789 | 789 | if ($message->message_id->first() == $this->message_id->first()) { |
790 | 790 | return $thread; |
791 | 791 | } |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
797 | 797 | |
798 | 798 | if (is_array($this->in_reply_to)) { |
799 | - foreach($this->in_reply_to as $in_reply_to) { |
|
799 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
800 | 800 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
801 | 801 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
802 | 802 | } |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * @throws Exceptions\GetMessagesFailedException |
818 | 818 | * @throws Exceptions\RuntimeException |
819 | 819 | */ |
820 | - protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){ |
|
820 | + protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) { |
|
821 | 821 | $primary_folder->query()->inReplyTo($in_reply_to) |
822 | 822 | ->setFetchBody($this->getFetchBodyOption()) |
823 | 823 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | * @throws Exceptions\GetMessagesFailedException |
839 | 839 | * @throws Exceptions\RuntimeException |
840 | 840 | */ |
841 | - protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){ |
|
841 | + protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) { |
|
842 | 842 | $primary_folder->query()->messageId($message_id) |
843 | 843 | ->setFetchBody($this->getFetchBodyOption()) |
844 | 844 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -934,14 +934,14 @@ discard block |
||
934 | 934 | * @throws MessageFlagException |
935 | 935 | * @throws MessageHeaderFetchingException |
936 | 936 | */ |
937 | - protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
|
938 | - if($expunge) $this->client->expunge(); |
|
937 | + protected function fetchNewMail($folder, $next_uid, $event, $expunge) { |
|
938 | + if ($expunge) $this->client->expunge(); |
|
939 | 939 | |
940 | 940 | $this->client->openFolder($folder->path); |
941 | 941 | |
942 | 942 | if ($this->sequence === IMAP::ST_UID) { |
943 | 943 | $sequence_id = $next_uid; |
944 | - }else{ |
|
944 | + }else { |
|
945 | 945 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
946 | 946 | } |
947 | 947 | |
@@ -966,11 +966,11 @@ discard block |
||
966 | 966 | */ |
967 | 967 | public function delete($expunge = true, $trash_path = null, $force_move = false) { |
968 | 968 | $status = $this->setFlag("Deleted"); |
969 | - if($force_move) { |
|
970 | - $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"]: $trash_path; |
|
969 | + if ($force_move) { |
|
970 | + $trash_path = $trash_path === null ? $this->config["common_folders"]["trash"] : $trash_path; |
|
971 | 971 | $status = $this->move($trash_path); |
972 | 972 | } |
973 | - if($expunge) $this->client->expunge(); |
|
973 | + if ($expunge) $this->client->expunge(); |
|
974 | 974 | |
975 | 975 | $event = $this->getEvent("message", "deleted"); |
976 | 976 | $event::dispatch($this); |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | */ |
991 | 991 | public function restore($expunge = true) { |
992 | 992 | $status = $this->unsetFlag("Deleted"); |
993 | - if($expunge) $this->client->expunge(); |
|
993 | + if ($expunge) $this->client->expunge(); |
|
994 | 994 | |
995 | 995 | $event = $this->getEvent("message", "restored"); |
996 | 996 | $event::dispatch($this); |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | * |
1096 | 1096 | * @return AttachmentCollection |
1097 | 1097 | */ |
1098 | - public function attachments(){ |
|
1098 | + public function attachments() { |
|
1099 | 1099 | return $this->getAttachments(); |
1100 | 1100 | } |
1101 | 1101 | |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | * |
1194 | 1194 | * @return FlagCollection |
1195 | 1195 | */ |
1196 | - public function flags(){ |
|
1196 | + public function flags() { |
|
1197 | 1197 | return $this->getFlags(); |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | * |
1203 | 1203 | * @return Structure|null |
1204 | 1204 | */ |
1205 | - public function getStructure(){ |
|
1205 | + public function getStructure() { |
|
1206 | 1206 | return $this->structure; |
1207 | 1207 | } |
1208 | 1208 | |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | * |
1229 | 1229 | * @return array |
1230 | 1230 | */ |
1231 | - public function getAttributes(){ |
|
1231 | + public function getAttributes() { |
|
1232 | 1232 | return array_merge($this->attributes, $this->header->getAttributes()); |
1233 | 1233 | } |
1234 | 1234 | |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | * |
1239 | 1239 | * @return $this |
1240 | 1240 | */ |
1241 | - public function setMask($mask){ |
|
1242 | - if(class_exists($mask)){ |
|
1241 | + public function setMask($mask) { |
|
1242 | + if (class_exists($mask)) { |
|
1243 | 1243 | $this->mask = $mask; |
1244 | 1244 | } |
1245 | 1245 | |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | * |
1252 | 1252 | * @return string |
1253 | 1253 | */ |
1254 | - public function getMask(){ |
|
1254 | + public function getMask() { |
|
1255 | 1255 | return $this->mask; |
1256 | 1256 | } |
1257 | 1257 | |
@@ -1262,9 +1262,9 @@ discard block |
||
1262 | 1262 | * @return mixed |
1263 | 1263 | * @throws MaskNotFoundException |
1264 | 1264 | */ |
1265 | - public function mask($mask = null){ |
|
1265 | + public function mask($mask = null) { |
|
1266 | 1266 | $mask = $mask !== null ? $mask : $this->mask; |
1267 | - if(class_exists($mask)){ |
|
1267 | + if (class_exists($mask)) { |
|
1268 | 1268 | return new $mask($this); |
1269 | 1269 | } |
1270 | 1270 | |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | * |
1277 | 1277 | * @return string |
1278 | 1278 | */ |
1279 | - public function getFolderPath(){ |
|
1279 | + public function getFolderPath() { |
|
1280 | 1280 | return $this->folder_path; |
1281 | 1281 | } |
1282 | 1282 | |
@@ -1286,7 +1286,7 @@ discard block |
||
1286 | 1286 | * |
1287 | 1287 | * @return $this |
1288 | 1288 | */ |
1289 | - public function setFolderPath($folder_path){ |
|
1289 | + public function setFolderPath($folder_path) { |
|
1290 | 1290 | $this->folder_path = $folder_path; |
1291 | 1291 | |
1292 | 1292 | return $this; |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | * |
1299 | 1299 | * @return $this |
1300 | 1300 | */ |
1301 | - public function setConfig($config){ |
|
1301 | + public function setConfig($config) { |
|
1302 | 1302 | $this->config = $config; |
1303 | 1303 | |
1304 | 1304 | return $this; |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | * |
1311 | 1311 | * @return $this |
1312 | 1312 | */ |
1313 | - public function setAvailableFlags($available_flags){ |
|
1313 | + public function setAvailableFlags($available_flags) { |
|
1314 | 1314 | $this->available_flags = $available_flags; |
1315 | 1315 | |
1316 | 1316 | return $this; |
@@ -1322,7 +1322,7 @@ discard block |
||
1322 | 1322 | * |
1323 | 1323 | * @return $this |
1324 | 1324 | */ |
1325 | - public function setAttachments($attachments){ |
|
1325 | + public function setAttachments($attachments) { |
|
1326 | 1326 | $this->attachments = $attachments; |
1327 | 1327 | |
1328 | 1328 | return $this; |
@@ -1334,7 +1334,7 @@ discard block |
||
1334 | 1334 | * |
1335 | 1335 | * @return $this |
1336 | 1336 | */ |
1337 | - public function setFlags($flags){ |
|
1337 | + public function setFlags($flags) { |
|
1338 | 1338 | $this->flags = $flags; |
1339 | 1339 | |
1340 | 1340 | return $this; |
@@ -1348,7 +1348,7 @@ discard block |
||
1348 | 1348 | * @throws Exceptions\RuntimeException |
1349 | 1349 | * @throws Exceptions\ConnectionFailedException |
1350 | 1350 | */ |
1351 | - public function setClient($client){ |
|
1351 | + public function setClient($client) { |
|
1352 | 1352 | $this->client = $client; |
1353 | 1353 | $this->client->openFolder($this->folder_path); |
1354 | 1354 | |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * @throws Exceptions\MessageNotFoundException |
1364 | 1364 | * @throws Exceptions\ConnectionFailedException |
1365 | 1365 | */ |
1366 | - public function setUid($uid){ |
|
1366 | + public function setUid($uid) { |
|
1367 | 1367 | $this->uid = $uid; |
1368 | 1368 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
1369 | 1369 | $this->msglist = null; |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | * @throws Exceptions\MessageNotFoundException |
1381 | 1381 | * @throws Exceptions\ConnectionFailedException |
1382 | 1382 | */ |
1383 | - public function setMsgn($msgn, $msglist = null){ |
|
1383 | + public function setMsgn($msgn, $msglist = null) { |
|
1384 | 1384 | $this->msgn = $msgn; |
1385 | 1385 | $this->msglist = $msglist; |
1386 | 1386 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -1393,7 +1393,7 @@ discard block |
||
1393 | 1393 | * |
1394 | 1394 | * @return int |
1395 | 1395 | */ |
1396 | - public function getSequence(){ |
|
1396 | + public function getSequence() { |
|
1397 | 1397 | return $this->sequence; |
1398 | 1398 | } |
1399 | 1399 | |
@@ -1402,7 +1402,7 @@ discard block |
||
1402 | 1402 | * |
1403 | 1403 | * @return int |
1404 | 1404 | */ |
1405 | - public function getSequenceId(){ |
|
1405 | + public function getSequenceId() { |
|
1406 | 1406 | return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn; |
1407 | 1407 | } |
1408 | 1408 | |
@@ -1414,11 +1414,11 @@ discard block |
||
1414 | 1414 | * @throws Exceptions\ConnectionFailedException |
1415 | 1415 | * @throws Exceptions\MessageNotFoundException |
1416 | 1416 | */ |
1417 | - public function setSequenceId($uid, $msglist = null){ |
|
1417 | + public function setSequenceId($uid, $msglist = null) { |
|
1418 | 1418 | if ($this->getSequence() === IMAP::ST_UID) { |
1419 | 1419 | $this->setUid($uid); |
1420 | 1420 | $this->setMsglist($msglist); |
1421 | - }else{ |
|
1421 | + }else { |
|
1422 | 1422 | $this->setMsgn($uid, $msglist); |
1423 | 1423 | } |
1424 | 1424 | } |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | } |
86 | 86 | |
87 | 87 | if (strpos(strtolower($name), "where") === false) { |
88 | - $method = 'where' . ucfirst($name); |
|
89 | - } else { |
|
88 | + $method = 'where'.ucfirst($name); |
|
89 | + }else { |
|
90 | 90 | $method = lcfirst($name); |
91 | 91 | } |
92 | 92 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | return call_user_func_array([$that, $method], $arguments); |
95 | 95 | } |
96 | 96 | |
97 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
97 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | foreach ($criteria as $key => $value) { |
138 | 138 | if (is_numeric($key)) { |
139 | 139 | $this->where($value); |
140 | - }else{ |
|
140 | + }else { |
|
141 | 141 | $this->where($key, $value); |
142 | 142 | } |
143 | 143 | } |
144 | - } else { |
|
144 | + }else { |
|
145 | 145 | $this->push_search_criteria($criteria, $value); |
146 | 146 | } |
147 | 147 | |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @throws InvalidWhereQueryCriteriaException |
157 | 157 | */ |
158 | - protected function push_search_criteria($criteria, $value){ |
|
158 | + protected function push_search_criteria($criteria, $value) { |
|
159 | 159 | $criteria = $this->validate_criteria($criteria); |
160 | 160 | $value = $this->parse_value($value); |
161 | 161 | |
162 | 162 | if ($value === null || $value === '') { |
163 | 163 | $this->query->push([$criteria]); |
164 | - } else { |
|
164 | + }else { |
|
165 | 165 | $this->query->push([$criteria, $value]); |
166 | 166 | } |
167 | 167 | } |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | public static function get($key, $default = null) { |
77 | 77 | $parts = explode('.', $key); |
78 | 78 | $value = null; |
79 | - foreach($parts as $part) { |
|
80 | - if($value === null) { |
|
81 | - if(isset(self::$config[$part])) { |
|
79 | + foreach ($parts as $part) { |
|
80 | + if ($value === null) { |
|
81 | + if (isset(self::$config[$part])) { |
|
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + }else { |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
87 | - if(isset($value[$part])) { |
|
86 | + }else { |
|
87 | + if (isset($value[$part])) { |
|
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + }else { |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public function setConfig($config) { |
178 | 178 | |
179 | - if(is_array($config) === false) { |
|
179 | + if (is_array($config) === false) { |
|
180 | 180 | $config = require $config; |
181 | 181 | } |
182 | 182 | |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | $vendor_config = require $path; |
187 | 187 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
188 | 188 | |
189 | - if(is_array($config)){ |
|
190 | - if(isset($config['default'])){ |
|
191 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
189 | + if (is_array($config)) { |
|
190 | + if (isset($config['default'])) { |
|
191 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
192 | 192 | |
193 | 193 | $default_config = $vendor_config['accounts']['default']; |
194 | - if(isset($config['accounts'][$config['default']])){ |
|
194 | + if (isset($config['accounts'][$config['default']])) { |
|
195 | 195 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
196 | 196 | } |
197 | 197 | |
198 | - if(is_array($config['accounts'])){ |
|
199 | - foreach($config['accounts'] as $account_key => $account){ |
|
198 | + if (is_array($config['accounts'])) { |
|
199 | + foreach ($config['accounts'] as $account_key => $account) { |
|
200 | 200 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
201 | 201 | } |
202 | 202 | } |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | return array_keys($arr) !== range(0, count($arr) - 1); |
239 | 239 | }; |
240 | 240 | |
241 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
241 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
242 | 242 | |
243 | - foreach($arrays as $append) { |
|
243 | + foreach ($arrays as $append) { |
|
244 | 244 | |
245 | - if(!is_array($append)) $append = array($append); |
|
245 | + if (!is_array($append)) $append = array($append); |
|
246 | 246 | |
247 | - foreach($append as $key => $value) { |
|
247 | + foreach ($append as $key => $value) { |
|
248 | 248 | |
249 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
249 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
250 | 250 | $base[$key] = $append[$key]; |
251 | 251 | continue; |
252 | 252 | } |
253 | 253 | |
254 | - if( |
|
254 | + if ( |
|
255 | 255 | ( |
256 | 256 | is_array($value) |
257 | 257 | && $isAssoc($value) |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment'] |
266 | 266 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
267 | 267 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
268 | - } else if(is_numeric($key)) { |
|
269 | - if(!in_array($value, $base)) $base[] = $value; |
|
270 | - } else { |
|
268 | + }else if (is_numeric($key)) { |
|
269 | + if (!in_array($value, $base)) $base[] = $value; |
|
270 | + }else { |
|
271 | 271 | $base[$key] = $value; |
272 | 272 | } |
273 | 273 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @throws ConnectionFailedException |
90 | 90 | * @throws RuntimeException |
91 | 91 | */ |
92 | - protected function enableStartTls(){ |
|
92 | + protected function enableStartTls() { |
|
93 | 93 | $response = $this->requestAndResponse('STARTTLS'); |
94 | 94 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
95 | 95 | if (!$result) { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $stack = []; |
152 | 152 | |
153 | 153 | // replace any trailing <NL> including spaces with a single space |
154 | - $line = rtrim($line) . ' '; |
|
154 | + $line = rtrim($line).' '; |
|
155 | 155 | while (($pos = strpos($line, ' ')) !== false) { |
156 | 156 | $token = substr($line, 0, $pos); |
157 | 157 | if (!strlen($token)) { |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | if (strlen($token) > $chars) { |
182 | 182 | $line = substr($token, $chars); |
183 | 183 | $token = substr($token, 0, $chars); |
184 | - } else { |
|
184 | + }else { |
|
185 | 185 | $line .= $this->nextLine(); |
186 | 186 | } |
187 | 187 | $tokens[] = $token; |
188 | - $line = trim($line) . ' '; |
|
188 | + $line = trim($line).' '; |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $line = $this->nextTaggedLine($tag); // get next tag |
236 | 236 | if (!$dontParse) { |
237 | 237 | $tokens = $this->decodeLine($line); |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | $tokens = $line; |
240 | 240 | } |
241 | 241 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -286,27 +286,27 @@ discard block |
||
286 | 286 | public function sendRequest($command, $tokens = [], &$tag = null) { |
287 | 287 | if (!$tag) { |
288 | 288 | $this->noun++; |
289 | - $tag = 'TAG' . $this->noun; |
|
289 | + $tag = 'TAG'.$this->noun; |
|
290 | 290 | } |
291 | 291 | |
292 | - $line = $tag . ' ' . $command; |
|
292 | + $line = $tag.' '.$command; |
|
293 | 293 | |
294 | 294 | foreach ($tokens as $token) { |
295 | 295 | if (is_array($token)) { |
296 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
296 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
297 | 297 | throw new RuntimeException('failed to write - connection closed?'); |
298 | 298 | } |
299 | 299 | if (!$this->assumedNextLine('+ ')) { |
300 | 300 | throw new RuntimeException('failed to send literal string'); |
301 | 301 | } |
302 | 302 | $line = $token[1]; |
303 | - } else { |
|
304 | - $line .= ' ' . $token; |
|
303 | + }else { |
|
304 | + $line .= ' '.$token; |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | if ($this->debug) echo ">> ".$line."\n"; |
308 | 308 | |
309 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
309 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
310 | 310 | throw new RuntimeException('failed to write - connection closed?'); |
311 | 311 | } |
312 | 312 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | public function escapeString($string) { |
337 | 337 | if (func_num_args() < 2) { |
338 | 338 | if (strpos($string, "\n") !== false) { |
339 | - return ['{' . strlen($string) . '}', $string]; |
|
340 | - } else { |
|
341 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
339 | + return ['{'.strlen($string).'}', $string]; |
|
340 | + }else { |
|
341 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | $result = []; |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | } |
364 | 364 | $result[] = $this->escapeList($v); |
365 | 365 | } |
366 | - return '(' . implode(' ', $result) . ')'; |
|
366 | + return '('.implode(' ', $result).')'; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -403,12 +403,12 @@ discard block |
||
403 | 403 | error_log("got an extra server challenge: $response"); |
404 | 404 | // respond with an empty response. |
405 | 405 | $this->sendRequest(''); |
406 | - } else { |
|
406 | + }else { |
|
407 | 407 | if (preg_match('/^NO /i', $response) || |
408 | 408 | preg_match('/^BAD /i', $response)) { |
409 | 409 | error_log("got failure response: $response"); |
410 | 410 | return false; |
411 | - } else if (preg_match("/^OK /i", $response)) { |
|
411 | + }else if (preg_match("/^OK /i", $response)) { |
|
412 | 412 | return true; |
413 | 413 | } |
414 | 414 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return bool |
445 | 445 | */ |
446 | - public function connected(){ |
|
446 | + public function connected() { |
|
447 | 447 | return (boolean) $this->stream; |
448 | 448 | } |
449 | 449 | |
@@ -490,10 +490,10 @@ discard block |
||
490 | 490 | $result[strtolower($tokens[1])] = $tokens[0]; |
491 | 491 | break; |
492 | 492 | case '[UIDVALIDITY': |
493 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
493 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
494 | 494 | break; |
495 | 495 | case '[UIDNEXT': |
496 | - $result['uidnext'] = (int)$tokens[2]; |
|
496 | + $result['uidnext'] = (int) $tokens[2]; |
|
497 | 497 | break; |
498 | 498 | default: |
499 | 499 | // ignore |
@@ -550,14 +550,14 @@ discard block |
||
550 | 550 | if (is_array($from)) { |
551 | 551 | $set = implode(',', $from); |
552 | 552 | } elseif ($to === null) { |
553 | - $set = (int)$from; |
|
553 | + $set = (int) $from; |
|
554 | 554 | } elseif ($to === INF) { |
555 | - $set = (int)$from . ':*'; |
|
556 | - } else { |
|
557 | - $set = (int)$from . ':' . (int)$to; |
|
555 | + $set = (int) $from.':*'; |
|
556 | + }else { |
|
557 | + $set = (int) $from.':'.(int) $to; |
|
558 | 558 | } |
559 | 559 | |
560 | - $items = (array)$items; |
|
560 | + $items = (array) $items; |
|
561 | 561 | $itemList = $this->escapeList($items); |
562 | 562 | |
563 | 563 | $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag); |
@@ -574,9 +574,9 @@ discard block |
||
574 | 574 | $count = count($tokens[2]); |
575 | 575 | if ($tokens[2][$count - 2] == 'UID') { |
576 | 576 | $uidKey = $count - 1; |
577 | - } else if ($tokens[2][0] == 'UID') { |
|
577 | + }else if ($tokens[2][0] == 'UID') { |
|
578 | 578 | $uidKey = 1; |
579 | - } else { |
|
579 | + }else { |
|
580 | 580 | $uidKey = array_search('UID', $tokens[2]) + 1; |
581 | 581 | } |
582 | 582 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | $data = $tokens[2][1]; |
593 | 593 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
594 | 594 | $data = $tokens[2][3]; |
595 | - } else { |
|
595 | + }else { |
|
596 | 596 | // maybe the server send an other field we didn't wanted |
597 | 597 | $count = count($tokens[2]); |
598 | 598 | // we start with 2, because 0 was already checked |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | break; |
605 | 605 | } |
606 | 606 | } |
607 | - } else { |
|
607 | + }else { |
|
608 | 608 | $data = []; |
609 | 609 | while (key($tokens[2]) !== null) { |
610 | 610 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | } |
622 | 622 | if ($uid) { |
623 | 623 | $result[$tokens[2][$uidKey]] = $data; |
624 | - }else{ |
|
624 | + }else { |
|
625 | 625 | $result[$tokens[0]] = $data; |
626 | 626 | } |
627 | 627 | } |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * @return array |
658 | 658 | * @throws RuntimeException |
659 | 659 | */ |
660 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
660 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
661 | 661 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
662 | 662 | } |
663 | 663 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | * @return array |
671 | 671 | * @throws RuntimeException |
672 | 672 | */ |
673 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
673 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
674 | 674 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
675 | 675 | } |
676 | 676 | |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | |
686 | 686 | if ($this->enable_uid_cache && $this->uid_cache) { |
687 | 687 | $uids = $this->uid_cache; |
688 | - } else { |
|
688 | + }else { |
|
689 | 689 | try { |
690 | 690 | $uids = $this->fetch('UID', 1, INF); |
691 | 691 | $this->setUidCache($uids); // set cache for this folder |
@@ -779,7 +779,7 @@ discard block |
||
779 | 779 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
780 | 780 | |
781 | 781 | if ($silent) { |
782 | - return (bool)$response; |
|
782 | + return (bool) $response; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $result = []; |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | $ids = []; |
1081 | 1081 | foreach ($uids as $msgn => $v) { |
1082 | 1082 | $id = $uid ? $v : $msgn; |
1083 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1083 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1084 | 1084 | $ids[] = $id; |
1085 | 1085 | } |
1086 | 1086 | } |
@@ -1094,14 +1094,14 @@ discard block |
||
1094 | 1094 | /** |
1095 | 1095 | * Enable the debug mode |
1096 | 1096 | */ |
1097 | - public function enableDebug(){ |
|
1097 | + public function enableDebug() { |
|
1098 | 1098 | $this->debug = true; |
1099 | 1099 | } |
1100 | 1100 | |
1101 | 1101 | /** |
1102 | 1102 | * Disable the debug mode |
1103 | 1103 | */ |
1104 | - public function disableDebug(){ |
|
1104 | + public function disableDebug() { |
|
1105 | 1105 | $this->debug = false; |
1106 | 1106 | } |
1107 | 1107 | |
@@ -1113,9 +1113,9 @@ discard block |
||
1113 | 1113 | * @return int|string |
1114 | 1114 | */ |
1115 | 1115 | public function buildSet($from, $to = null) { |
1116 | - $set = (int)$from; |
|
1116 | + $set = (int) $from; |
|
1117 | 1117 | if ($to !== null) { |
1118 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
1118 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
1119 | 1119 | } |
1120 | 1120 | return $set; |
1121 | 1121 | } |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | throw new AuthFailedException($message); |
90 | 90 | } |
91 | 91 | |
92 | - if(!$this->stream) { |
|
92 | + if (!$this->stream) { |
|
93 | 93 | $errors = \imap_errors(); |
94 | 94 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
95 | 95 | throw new AuthFailedException($message); |
96 | 96 | } |
97 | 97 | |
98 | 98 | $errors = \imap_errors(); |
99 | - if(is_array($errors)) { |
|
99 | + if (is_array($errors)) { |
|
100 | 100 | $status = $this->examineFolder(); |
101 | - if($status['exists'] !== 0) { |
|
101 | + if ($status['exists'] !== 0) { |
|
102 | 102 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
103 | 103 | throw new RuntimeException($message); |
104 | 104 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | if (!$this->cert_validation) { |
130 | 130 | $address .= '/novalidate-cert'; |
131 | 131 | } |
132 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
132 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
133 | 133 | $address .= '/'.$this->encryption; |
134 | 134 | } elseif ($this->encryption === "starttls") { |
135 | 135 | $address .= '/tls'; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return bool |
162 | 162 | */ |
163 | - public function connected(){ |
|
163 | + public function connected() { |
|
164 | 164 | return boolval($this->stream); |
165 | 165 | } |
166 | 166 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return array |
235 | 235 | */ |
236 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
236 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
237 | 237 | $result = []; |
238 | 238 | $uids = is_array($uids) ? $uids : [$uids]; |
239 | 239 | foreach ($uids as $id) { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @return array |
251 | 251 | */ |
252 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
252 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
253 | 253 | $result = []; |
254 | 254 | $uids = is_array($uids) ? $uids : [$uids]; |
255 | 255 | foreach ($uids as $id) { |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | $flags = []; |
258 | 258 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
259 | 259 | $raw_flags = (array) $raw_flags[0]; |
260 | - foreach($raw_flags as $flag => $value) { |
|
261 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
260 | + foreach ($raw_flags as $flag => $value) { |
|
261 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
262 | 262 | $flags[] = "\\".ucfirst($flag); |
263 | 263 | } |
264 | 264 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $overview = $this->overview("1:*"); |
285 | 285 | $uids = []; |
286 | - foreach($overview as $set){ |
|
286 | + foreach ($overview as $set) { |
|
287 | 287 | $uids[$set->msgno] = $set->uid; |
288 | 288 | } |
289 | 289 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return array |
313 | 313 | */ |
314 | 314 | public function overview($sequence, $uid = IMAP::ST_UID) { |
315 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
315 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | $result = []; |
328 | 328 | |
329 | 329 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
330 | - if(is_array($items)){ |
|
330 | + if (is_array($items)) { |
|
331 | 331 | foreach ($items as $item) { |
332 | 332 | $name = $this->decodeFolderName($item->name); |
333 | 333 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
334 | 334 | } |
335 | - }else{ |
|
335 | + }else { |
|
336 | 336 | throw new RuntimeException(\imap_last_error()); |
337 | 337 | } |
338 | 338 | |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID) { |
355 | 355 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
356 | 356 | |
357 | - if ($mode == "+"){ |
|
357 | + if ($mode == "+") { |
|
358 | 358 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
359 | - }else{ |
|
359 | + }else { |
|
360 | 360 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
361 | 361 | } |
362 | 362 | |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
380 | 380 | if ($date != null) { |
381 | - if ($date instanceof \Carbon\Carbon){ |
|
381 | + if ($date instanceof \Carbon\Carbon) { |
|
382 | 382 | $date = $date->format('d-M-Y H:i:s O'); |
383 | 383 | } |
384 | 384 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return array|bool Tokens if operation successful, false if an error occurred |
411 | 411 | */ |
412 | 412 | public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
413 | - foreach($messages as $msg) { |
|
413 | + foreach ($messages as $msg) { |
|
414 | 414 | if ($this->copyMessage($folder, $msg, null, $uid) == false) { |
415 | 415 | return false; |
416 | 416 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @return array|bool Tokens if operation successful, false if an error occurred |
443 | 443 | */ |
444 | 444 | public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
445 | - foreach($messages as $msg) { |
|
445 | + foreach ($messages as $msg) { |
|
446 | 446 | if ($this->moveMessage($folder, $msg, null, $uid) == false) { |
447 | 447 | return false; |
448 | 448 | } |
@@ -565,14 +565,14 @@ discard block |
||
565 | 565 | /** |
566 | 566 | * Enable the debug mode |
567 | 567 | */ |
568 | - public function enableDebug(){ |
|
568 | + public function enableDebug() { |
|
569 | 569 | $this->debug = true; |
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
573 | 573 | * Disable the debug mode |
574 | 574 | */ |
575 | - public function disableDebug(){ |
|
575 | + public function disableDebug() { |
|
576 | 576 | $this->debug = false; |
577 | 577 | } |
578 | 578 |