@@ -16,7 +16,7 @@ |
||
16 | 16 | * New custom method which can be called through a mask |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - public function token(){ |
|
19 | + public function token() { |
|
20 | 20 | return implode('-', [$this->message_id, $this->uid, $this->message_no]); |
21 | 21 | } |
22 | 22 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * New custom method which can be called through a mask |
17 | 17 | * @return string |
18 | 18 | */ |
19 | - public function token(){ |
|
19 | + public function token() { |
|
20 | 20 | return implode('-', [$this->id, $this->getMessage()->getUid(), $this->name]); |
21 | 21 | } |
22 | 22 |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $this->setDelimiter($delimiter); |
127 | 127 | $this->path = $folder_name; |
128 | - $this->full_name = $this->decodeName($folder_name); |
|
128 | + $this->full_name = $this->decodeName($folder_name); |
|
129 | 129 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
130 | 130 | |
131 | 131 | $this->parseAttributes($attributes); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return WhereQuery |
139 | 139 | * @throws Exceptions\ConnectionFailedException |
140 | 140 | */ |
141 | - public function query($charset = 'UTF-8'){ |
|
141 | + public function query($charset = 'UTF-8') { |
|
142 | 142 | $this->getClient()->checkConnection(); |
143 | 143 | $this->getClient()->openFolder($this->path); |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @inheritdoc self::query($charset = 'UTF-8') |
150 | 150 | * @throws Exceptions\ConnectionFailedException |
151 | 151 | */ |
152 | - public function search($charset = 'UTF-8'){ |
|
152 | + public function search($charset = 'UTF-8') { |
|
153 | 153 | return $this->query($charset); |
154 | 154 | } |
155 | 155 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @inheritdoc self::query($charset = 'UTF-8') |
158 | 158 | * @throws Exceptions\ConnectionFailedException |
159 | 159 | */ |
160 | - public function messages($charset = 'UTF-8'){ |
|
160 | + public function messages($charset = 'UTF-8') { |
|
161 | 161 | return $this->query($charset); |
162 | 162 | } |
163 | 163 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | public function move($new_name, $expunge = true) { |
238 | 238 | $this->client->checkConnection(); |
239 | 239 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
240 | - if($expunge) $this->client->expunge(); |
|
240 | + if ($expunge) $this->client->expunge(); |
|
241 | 241 | |
242 | 242 | $folder = $this->client->getFolder($new_name); |
243 | 243 | $event = $this->getEvent("folder", "moved"); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | |
267 | 267 | if ($internal_date != null) { |
268 | - if ($internal_date instanceof Carbon){ |
|
268 | + if ($internal_date instanceof Carbon) { |
|
269 | 269 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
270 | 270 | } |
271 | 271 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function delete($expunge = true) { |
302 | 302 | $status = $this->client->getConnection()->deleteFolder($this->path); |
303 | - if($expunge) $this->client->expunge(); |
|
303 | + if ($expunge) $this->client->expunge(); |
|
304 | 304 | |
305 | 305 | $event = $this->getEvent("folder", "deleted"); |
306 | 306 | $event::dispatch($this); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | try { |
358 | 358 | $line = $connection->nextLine(); |
359 | 359 | if (($pos = strpos($line, "EXISTS")) !== false) { |
360 | - $msgn = (int) substr($line, 2, $pos -2); |
|
360 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
361 | 361 | $connection->done(); |
362 | 362 | |
363 | 363 | $message = $this->query()->getMessage($msgn); |
@@ -368,10 +368,10 @@ discard block |
||
368 | 368 | |
369 | 369 | $connection->idle(); |
370 | 370 | } |
371 | - }catch (Exceptions\RuntimeException $e) { |
|
372 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
371 | + } catch (Exceptions\RuntimeException $e) { |
|
372 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
373 | 373 | throw $e; |
374 | - }else{ |
|
374 | + }else { |
|
375 | 375 | $this->client->connect(); |
376 | 376 | $this->client->openFolder($this->path); |
377 | 377 | $connection = $this->client->getConnection(); |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | /** |
417 | 417 | * @param $delimiter |
418 | 418 | */ |
419 | - public function setDelimiter($delimiter){ |
|
420 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
419 | + public function setDelimiter($delimiter) { |
|
420 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
421 | 421 | $delimiter = ClientManager::get('options.delimiter', '/'); |
422 | 422 | } |
423 | 423 |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
179 | 179 | |
180 | 180 | $default_mask = $client->getDefaultMessageMask(); |
181 | - if($default_mask != null) { |
|
181 | + if ($default_mask != null) { |
|
182 | 182 | $this->mask = $default_mask; |
183 | 183 | } |
184 | 184 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | * @throws MethodNotFoundException |
224 | 224 | */ |
225 | 225 | public function __call($method, $arguments) { |
226 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
226 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
227 | 227 | $name = Str::snake(substr($method, 3)); |
228 | 228 | return $this->get($name); |
229 | 229 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
230 | 230 | $name = Str::snake(substr($method, 3)); |
231 | 231 | |
232 | - if(in_array($name, array_keys($this->attributes))) { |
|
232 | + if (in_array($name, array_keys($this->attributes))) { |
|
233 | 233 | $this->attributes[$name] = array_pop($arguments); |
234 | 234 | |
235 | 235 | return $this->attributes[$name]; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return mixed|null |
268 | 268 | */ |
269 | 269 | public function get($name) { |
270 | - if(isset($this->attributes[$name])) { |
|
270 | + if (isset($this->attributes[$name])) { |
|
271 | 271 | return $this->attributes[$name]; |
272 | 272 | } |
273 | 273 | |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | $flags = $this->client->getConnection()->flags([$this->msgn]); |
350 | 350 | |
351 | 351 | if (isset($flags[$this->msgn])) { |
352 | - foreach($flags[$this->msgn] as $flag) { |
|
353 | - if (strpos($flag, "\\") === 0){ |
|
352 | + foreach ($flags[$this->msgn] as $flag) { |
|
353 | + if (strpos($flag, "\\") === 0) { |
|
354 | 354 | $flag = substr($flag, 1); |
355 | 355 | } |
356 | 356 | $flag_key = strtolower($flag); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | } elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') { |
450 | 450 | $this->fetchAttachment($part); |
451 | 451 | } |
452 | - } else { |
|
452 | + }else { |
|
453 | 453 | $this->fetchAttachment($part); |
454 | 454 | } |
455 | 455 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | if ($oAttachment->getName() !== null) { |
469 | 469 | if ($oAttachment->getId() !== null) { |
470 | 470 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
471 | - } else { |
|
471 | + }else { |
|
472 | 472 | $this->attachments->push($oAttachment); |
473 | 473 | } |
474 | 474 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
592 | 592 | return @iconv($from, $to.'//IGNORE', $str); |
593 | - } else { |
|
593 | + }else { |
|
594 | 594 | if (!$from) { |
595 | 595 | return mb_convert_encoding($str, $to); |
596 | 596 | } |
@@ -612,9 +612,9 @@ discard block |
||
612 | 612 | return EncodingAliases::get($parameter->value); |
613 | 613 | } |
614 | 614 | } |
615 | - }elseif (property_exists($structure, 'charset')){ |
|
615 | + }elseif (property_exists($structure, 'charset')) { |
|
616 | 616 | return EncodingAliases::get($structure->charset); |
617 | - }elseif (is_string($structure) === true){ |
|
617 | + }elseif (is_string($structure) === true) { |
|
618 | 618 | return mb_detect_encoding($structure); |
619 | 619 | } |
620 | 620 | |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @throws Exceptions\ConnectionFailedException |
629 | 629 | * @throws Exceptions\FolderFetchingException |
630 | 630 | */ |
631 | - public function getFolder(){ |
|
631 | + public function getFolder() { |
|
632 | 632 | return $this->client->getFolder($this->folder_path); |
633 | 633 | } |
634 | 634 | |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | */ |
706 | 706 | public function delete($expunge = true) { |
707 | 707 | $status = $this->setFlag("Deleted"); |
708 | - if($expunge) $this->client->expunge(); |
|
708 | + if ($expunge) $this->client->expunge(); |
|
709 | 709 | |
710 | 710 | $event = $this->getEvent("message", "deleted"); |
711 | 711 | $event::dispatch($this); |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | */ |
725 | 725 | public function restore($expunge = true) { |
726 | 726 | $status = $this->unsetFlag("Deleted"); |
727 | - if($expunge) $this->client->expunge(); |
|
727 | + if ($expunge) $this->client->expunge(); |
|
728 | 728 | |
729 | 729 | $event = $this->getEvent("message", "restored"); |
730 | 730 | $event::dispatch($this); |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | /** |
860 | 860 | * @return object|null |
861 | 861 | */ |
862 | - public function getStructure(){ |
|
862 | + public function getStructure() { |
|
863 | 863 | return $this->structure; |
864 | 864 | } |
865 | 865 | |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | /** |
886 | 886 | * @return array |
887 | 887 | */ |
888 | - public function getAttributes(){ |
|
888 | + public function getAttributes() { |
|
889 | 889 | return $this->attributes; |
890 | 890 | } |
891 | 891 | |
@@ -893,8 +893,8 @@ discard block |
||
893 | 893 | * @param $mask |
894 | 894 | * @return $this |
895 | 895 | */ |
896 | - public function setMask($mask){ |
|
897 | - if(class_exists($mask)){ |
|
896 | + public function setMask($mask) { |
|
897 | + if (class_exists($mask)) { |
|
898 | 898 | $this->mask = $mask; |
899 | 899 | } |
900 | 900 | |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | /** |
905 | 905 | * @return string |
906 | 906 | */ |
907 | - public function getMask(){ |
|
907 | + public function getMask() { |
|
908 | 908 | return $this->mask; |
909 | 909 | } |
910 | 910 | |
@@ -915,9 +915,9 @@ discard block |
||
915 | 915 | * @return mixed |
916 | 916 | * @throws MaskNotFoundException |
917 | 917 | */ |
918 | - public function mask($mask = null){ |
|
918 | + public function mask($mask = null) { |
|
919 | 919 | $mask = $mask !== null ? $mask : $this->mask; |
920 | - if(class_exists($mask)){ |
|
920 | + if (class_exists($mask)) { |
|
921 | 921 | return new $mask($this); |
922 | 922 | } |
923 | 923 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * Get the message html body |
30 | 30 | * @return null |
31 | 31 | */ |
32 | - public function getHtmlBody(){ |
|
32 | + public function getHtmlBody() { |
|
33 | 33 | $bodies = $this->parent->getBodies(); |
34 | 34 | if (!isset($bodies['html'])) { |
35 | 35 | return null; |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function getCustomHTMLBody($callback = false) { |
48 | 48 | $body = $this->getHtmlBody(); |
49 | - if($body === null) return null; |
|
49 | + if ($body === null) return null; |
|
50 | 50 | |
51 | 51 | if ($callback !== false) { |
52 | 52 | $aAttachment = $this->parent->getAttachments(); |
53 | 53 | $aAttachment->each(function($oAttachment) use(&$body, $callback) { |
54 | 54 | /** @var Attachment $oAttachment */ |
55 | - if(is_callable($callback)) { |
|
55 | + if (is_callable($callback)) { |
|
56 | 56 | $body = $callback($body, $oAttachment); |
57 | - }elseif(is_string($callback)) { |
|
57 | + }elseif (is_string($callback)) { |
|
58 | 58 | call_user_func($callback, [$body, $oAttachment]); |
59 | 59 | } |
60 | 60 | }); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return string|null |
71 | 71 | */ |
72 | 72 | public function getHTMLBodyWithEmbeddedBase64Images() { |
73 | - return $this->getCustomHTMLBody(function($body, $oAttachment){ |
|
73 | + return $this->getCustomHTMLBody(function($body, $oAttachment) { |
|
74 | 74 | /** @var \Webklex\PHPIMAP\Attachment $oAttachment */ |
75 | 75 | if ($oAttachment->id && $oAttachment->getImgSrc() != null) { |
76 | 76 | $body = str_replace('cid:'.$oAttachment->id, $oAttachment->getImgSrc(), $body); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | public function __construct($parent) { |
40 | 40 | $this->parent = $parent; |
41 | 41 | |
42 | - if(method_exists($this->parent, 'getAttributes')){ |
|
42 | + if (method_exists($this->parent, 'getAttributes')) { |
|
43 | 43 | $this->attributes = array_merge($this->attributes, $this->parent->getAttributes()); |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * Boot method made to be used by any custom mask |
51 | 51 | */ |
52 | - protected function boot(){} |
|
52 | + protected function boot() {} |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Call dynamic attribute setter and getter methods and inherit the parent calls |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | * @throws MethodNotFoundException |
61 | 61 | */ |
62 | 62 | public function __call($method, $arguments) { |
63 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
63 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
64 | 64 | $name = Str::snake(substr($method, 3)); |
65 | 65 | |
66 | - if(isset($this->attributes[$name])) { |
|
66 | + if (isset($this->attributes[$name])) { |
|
67 | 67 | return $this->attributes[$name]; |
68 | 68 | } |
69 | 69 | |
70 | 70 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
71 | 71 | $name = Str::snake(substr($method, 3)); |
72 | 72 | |
73 | - if(isset($this->attributes[$name])) { |
|
73 | + if (isset($this->attributes[$name])) { |
|
74 | 74 | $this->attributes[$name] = array_pop($arguments); |
75 | 75 | |
76 | 76 | return $this->attributes[$name]; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - if(method_exists($this->parent, $method) === true){ |
|
81 | + if (method_exists($this->parent, $method) === true) { |
|
82 | 82 | return call_user_func_array([$this->parent, $method], $arguments); |
83 | 83 | } |
84 | 84 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return mixed|null |
104 | 104 | */ |
105 | 105 | public function __get($name) { |
106 | - if(isset($this->attributes[$name])) { |
|
106 | + if (isset($this->attributes[$name])) { |
|
107 | 107 | return $this->attributes[$name]; |
108 | 108 | } |
109 | 109 | |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * @return mixed |
115 | 115 | */ |
116 | - public function getParent(){ |
|
116 | + public function getParent() { |
|
117 | 117 | return $this->parent; |
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function getAttributes(){ |
|
123 | + public function getAttributes() { |
|
124 | 124 | return $this->attributes; |
125 | 125 | } |
126 | 126 |
@@ -69,7 +69,7 @@ |
||
69 | 69 | * @return int|null |
70 | 70 | */ |
71 | 71 | public function total($total = null) { |
72 | - if($total === null) { |
|
72 | + if ($total === null) { |
|
73 | 73 | return $this->total; |
74 | 74 | } |
75 | 75 |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | throw new AuthFailedException($message); |
86 | 86 | } |
87 | 87 | |
88 | - if(!$this->stream) { |
|
88 | + if (!$this->stream) { |
|
89 | 89 | $errors = \imap_errors(); |
90 | 90 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
91 | 91 | throw new AuthFailedException($message); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if (!$this->cert_validation) { |
117 | 117 | $address .= '/novalidate-cert'; |
118 | 118 | } |
119 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
119 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
120 | 120 | $address .= '/'.$this->encryption; |
121 | 121 | } elseif ($this->encryption === "starttls") { |
122 | 122 | $address .= '/tls'; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return bool |
146 | 146 | */ |
147 | - public function connected(){ |
|
147 | + public function connected() { |
|
148 | 148 | return !$this->stream; |
149 | 149 | } |
150 | 150 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @return array |
212 | 212 | */ |
213 | - public function headers($uids, $rfc = "RFC822"){ |
|
213 | + public function headers($uids, $rfc = "RFC822") { |
|
214 | 214 | $headers = \imap_fetchheader($this->stream, $uids[0], IMAP::FT_UID); |
215 | 215 | return [$uids[0] => $headers]; |
216 | 216 | } |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - public function flags($uids){ |
|
224 | + public function flags($uids) { |
|
225 | 225 | $flags = \imap_fetch_overview($this->stream, $uids[0], IMAP::FT_UID); |
226 | 226 | $result = []; |
227 | 227 | if (is_array($flags) && isset($flags[0])) { |
228 | 228 | $flags = (array) $flags[0]; |
229 | - foreach($flags as $flag => $value) { |
|
230 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
229 | + foreach ($flags as $flag => $value) { |
|
230 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
231 | 231 | $result[] = "\\".ucfirst($flag); |
232 | 232 | } |
233 | 233 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if ($id === null) { |
246 | 246 | $overview = $this->overview("1:*"); |
247 | 247 | $uids = []; |
248 | - foreach($overview as $set){ |
|
248 | + foreach ($overview as $set) { |
|
249 | 249 | $uids[$set->msgno] = $set->uid; |
250 | 250 | } |
251 | 251 | return $uids; |
@@ -285,12 +285,12 @@ discard block |
||
285 | 285 | $result = []; |
286 | 286 | |
287 | 287 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
288 | - if(is_array($items)){ |
|
288 | + if (is_array($items)) { |
|
289 | 289 | foreach ($items as $item) { |
290 | 290 | $name = $this->decodeFolderName($item->name); |
291 | 291 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
292 | 292 | } |
293 | - }else{ |
|
293 | + }else { |
|
294 | 294 | throw new RuntimeException(\imap_last_error()); |
295 | 295 | } |
296 | 296 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true) { |
312 | 312 | $flag = "\\".trim(is_array($flags) ? implode(" \\", $flags) : $flags); |
313 | 313 | |
314 | - if ($mode == "+"){ |
|
314 | + if ($mode == "+") { |
|
315 | 315 | $status = \imap_setflag_full($this->stream, $from, $flag, IMAP::SE_UID); |
316 | - }else{ |
|
316 | + }else { |
|
317 | 317 | $status = \imap_clearflag_full($this->stream, $from, $flag, IMAP::SE_UID); |
318 | 318 | } |
319 | 319 | |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
337 | 337 | if ($date != null) { |
338 | - if ($date instanceof \Carbon\Carbon){ |
|
338 | + if ($date instanceof \Carbon\Carbon) { |
|
339 | 339 | $date = $date->format('d-M-Y H:i:s O'); |
340 | 340 | } |
341 | 341 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -457,14 +457,14 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Enable the debug mode |
459 | 459 | */ |
460 | - public function enableDebug(){ |
|
460 | + public function enableDebug() { |
|
461 | 461 | $this->debug = true; |
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
465 | 465 | * Disable the debug mode |
466 | 466 | */ |
467 | - public function disableDebug(){ |
|
467 | + public function disableDebug() { |
|
468 | 468 | $this->debug = false; |
469 | 469 | } |
470 | 470 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @throws ConnectionFailedException |
83 | 83 | * @throws RuntimeException |
84 | 84 | */ |
85 | - protected function enableTls(){ |
|
85 | + protected function enableTls() { |
|
86 | 86 | $response = $this->requestAndResponse('STARTTLS'); |
87 | 87 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
88 | 88 | if (!$result) { |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $stack = []; |
145 | 145 | |
146 | 146 | // replace any trailing <NL> including spaces with a single space |
147 | - $line = rtrim($line) . ' '; |
|
147 | + $line = rtrim($line).' '; |
|
148 | 148 | while (($pos = strpos($line, ' ')) !== false) { |
149 | 149 | $token = substr($line, 0, $pos); |
150 | 150 | if (!strlen($token)) { |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | if (strlen($token) > $chars) { |
175 | 175 | $line = substr($token, $chars); |
176 | 176 | $token = substr($token, 0, $chars); |
177 | - } else { |
|
177 | + }else { |
|
178 | 178 | $line .= $this->nextLine(); |
179 | 179 | } |
180 | 180 | $tokens[] = $token; |
181 | - $line = trim($line) . ' '; |
|
181 | + $line = trim($line).' '; |
|
182 | 182 | continue; |
183 | 183 | } |
184 | 184 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $line = $this->nextTaggedLine($tag); // get next tag |
229 | 229 | if (!$dontParse) { |
230 | 230 | $tokens = $this->decodeLine($line); |
231 | - } else { |
|
231 | + }else { |
|
232 | 232 | $tokens = $line; |
233 | 233 | } |
234 | 234 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | // last to chars are still needed for response code |
256 | 256 | $tokens = [substr($tokens, 0, 2)]; |
257 | 257 | } |
258 | - if (is_array($lines)){ |
|
258 | + if (is_array($lines)) { |
|
259 | 259 | if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
260 | - }else{ |
|
260 | + }else { |
|
261 | 261 | if ($this->debug) echo "<< ".$lines."\n"; |
262 | 262 | } |
263 | 263 | // last line has response code |
@@ -280,27 +280,27 @@ discard block |
||
280 | 280 | public function sendRequest($command, $tokens = [], &$tag = null) { |
281 | 281 | if (!$tag) { |
282 | 282 | $this->noun++; |
283 | - $tag = 'TAG' . $this->noun; |
|
283 | + $tag = 'TAG'.$this->noun; |
|
284 | 284 | } |
285 | 285 | |
286 | - $line = $tag . ' ' . $command; |
|
286 | + $line = $tag.' '.$command; |
|
287 | 287 | |
288 | 288 | foreach ($tokens as $token) { |
289 | 289 | if (is_array($token)) { |
290 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
290 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
291 | 291 | throw new RuntimeException('failed to write - connection closed?'); |
292 | 292 | } |
293 | 293 | if (!$this->assumedNextLine('+ ')) { |
294 | 294 | throw new RuntimeException('failed to send literal string'); |
295 | 295 | } |
296 | 296 | $line = $token[1]; |
297 | - } else { |
|
298 | - $line .= ' ' . $token; |
|
297 | + }else { |
|
298 | + $line .= ' '.$token; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | if ($this->debug) echo ">> ".$line."\n"; |
302 | 302 | |
303 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
303 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
304 | 304 | throw new RuntimeException('failed to write - connection closed?'); |
305 | 305 | } |
306 | 306 | } |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | public function escapeString($string) { |
331 | 331 | if (func_num_args() < 2) { |
332 | 332 | if (strpos($string, "\n") !== false) { |
333 | - return ['{' . strlen($string) . '}', $string]; |
|
334 | - } else { |
|
335 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
333 | + return ['{'.strlen($string).'}', $string]; |
|
334 | + }else { |
|
335 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | $result = []; |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | } |
358 | 358 | $result[] = $this->escapeList($v); |
359 | 359 | } |
360 | - return '(' . implode(' ', $result) . ')'; |
|
360 | + return '('.implode(' ', $result).')'; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | error_log("got an extra server challenge: $response"); |
398 | 398 | // respond with an empty response. |
399 | 399 | $this->sendRequest(''); |
400 | - } else { |
|
400 | + }else { |
|
401 | 401 | if (preg_match('/^NO /i', $response) || |
402 | 402 | preg_match('/^BAD /i', $response)) { |
403 | 403 | error_log("got failure response: $response"); |
404 | 404 | return false; |
405 | - } else if (preg_match("/^OK /i", $response)) { |
|
405 | + }else if (preg_match("/^OK /i", $response)) { |
|
406 | 406 | return true; |
407 | 407 | } |
408 | 408 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * |
436 | 436 | * @return bool |
437 | 437 | */ |
438 | - public function connected(){ |
|
438 | + public function connected() { |
|
439 | 439 | return (boolean) $this->stream; |
440 | 440 | } |
441 | 441 | |
@@ -482,10 +482,10 @@ discard block |
||
482 | 482 | $result[strtolower($tokens[1])] = $tokens[0]; |
483 | 483 | break; |
484 | 484 | case '[UIDVALIDITY': |
485 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
485 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
486 | 486 | break; |
487 | 487 | case '[UIDNEXT': |
488 | - $result['uidnext'] = (int)$tokens[2]; |
|
488 | + $result['uidnext'] = (int) $tokens[2]; |
|
489 | 489 | break; |
490 | 490 | default: |
491 | 491 | // ignore |
@@ -539,17 +539,17 @@ discard block |
||
539 | 539 | if (is_array($from)) { |
540 | 540 | $set = implode(',', $from); |
541 | 541 | } elseif ($to === null) { |
542 | - $set = (int)$from; |
|
542 | + $set = (int) $from; |
|
543 | 543 | } elseif ($to === INF) { |
544 | - $set = (int)$from . ':*'; |
|
545 | - } else { |
|
546 | - $set = (int)$from . ':' . (int)$to; |
|
544 | + $set = (int) $from.':*'; |
|
545 | + }else { |
|
546 | + $set = (int) $from.':'.(int) $to; |
|
547 | 547 | } |
548 | 548 | |
549 | - $items = (array)$items; |
|
549 | + $items = (array) $items; |
|
550 | 550 | $itemList = $this->escapeList($items); |
551 | 551 | |
552 | - $this->sendRequest(($uid ? 'UID ' : '') . 'FETCH', [$set, $itemList], $tag); |
|
552 | + $this->sendRequest(($uid ? 'UID ' : '').'FETCH', [$set, $itemList], $tag); |
|
553 | 553 | |
554 | 554 | $result = []; |
555 | 555 | $tokens = null; // define $tokens variable before first use |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $count = count($tokens[2]); |
565 | 565 | if ($tokens[2][$count - 2] == 'UID') { |
566 | 566 | $uidKey = $count - 1; |
567 | - } else { |
|
567 | + }else { |
|
568 | 568 | $uidKey = array_search('UID', $tokens[2]) + 1; |
569 | 569 | } |
570 | 570 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $data = $tokens[2][1]; |
581 | 581 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
582 | 582 | $data = $tokens[2][3]; |
583 | - } else { |
|
583 | + }else { |
|
584 | 584 | // maybe the server send an other field we didn't wanted |
585 | 585 | $count = count($tokens[2]); |
586 | 586 | // we start with 2, because 0 was already checked |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | break; |
593 | 593 | } |
594 | 594 | } |
595 | - } else { |
|
595 | + }else { |
|
596 | 596 | $data = []; |
597 | 597 | while (key($tokens[2]) !== null) { |
598 | 598 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | * @return array |
638 | 638 | * @throws RuntimeException |
639 | 639 | */ |
640 | - public function headers($uids, $rfc = "RFC822"){ |
|
640 | + public function headers($uids, $rfc = "RFC822") { |
|
641 | 641 | return $this->fetch(["$rfc.HEADER"], $uids); |
642 | 642 | } |
643 | 643 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * @return array |
649 | 649 | * @throws RuntimeException |
650 | 650 | */ |
651 | - public function flags($uids){ |
|
651 | + public function flags($uids) { |
|
652 | 652 | return $this->fetch(["FLAGS"], $uids); |
653 | 653 | } |
654 | 654 | |
@@ -732,22 +732,22 @@ discard block |
||
732 | 732 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true) { |
733 | 733 | $item = 'FLAGS'; |
734 | 734 | if ($mode == '+' || $mode == '-') { |
735 | - $item = $mode . $item; |
|
735 | + $item = $mode.$item; |
|
736 | 736 | } |
737 | 737 | if ($silent) { |
738 | 738 | $item .= '.SILENT'; |
739 | 739 | } |
740 | 740 | |
741 | 741 | $flags = $this->escapeList($flags); |
742 | - $set = (int)$from; |
|
742 | + $set = (int) $from; |
|
743 | 743 | if ($to !== null) { |
744 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
744 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | $result = $this->requestAndResponse('STORE', [$set, $item, $flags], $silent); |
748 | 748 | |
749 | 749 | if ($silent) { |
750 | - return (bool)$result; |
|
750 | + return (bool) $result; |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | $tokens = $result; |
@@ -797,9 +797,9 @@ discard block |
||
797 | 797 | * @throws RuntimeException |
798 | 798 | */ |
799 | 799 | public function copyMessage($folder, $from, $to = null) { |
800 | - $set = (int)$from; |
|
800 | + $set = (int) $from; |
|
801 | 801 | if ($to !== null) { |
802 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
802 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | return $this->requestAndResponse('COPY', [$set, $this->escapeString($folder)], true); |
@@ -950,14 +950,14 @@ discard block |
||
950 | 950 | /** |
951 | 951 | * Enable the debug mode |
952 | 952 | */ |
953 | - public function enableDebug(){ |
|
953 | + public function enableDebug() { |
|
954 | 954 | $this->debug = true; |
955 | 955 | } |
956 | 956 | |
957 | 957 | /** |
958 | 958 | * Disable the debug mode |
959 | 959 | */ |
960 | - public function disableDebug(){ |
|
960 | + public function disableDebug() { |
|
961 | 961 | $this->debug = false; |
962 | 962 | } |
963 | 963 | } |
964 | 964 | \ No newline at end of file |