@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @throws InvalidMessageDateException |
161 | 161 | */ |
162 | - protected function parse(){ |
|
162 | + protected function parse() { |
|
163 | 163 | if ($this->header === null) { |
164 | 164 | $body = $this->findHeaders(); |
165 | - }else{ |
|
165 | + }else { |
|
166 | 166 | $body = $this->raw; |
167 | 167 | } |
168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | $this->name = $this->header->get("name"); |
175 | 175 | $this->filename = $this->header->get("filename"); |
176 | 176 | |
177 | - if(!empty($this->header->get("id"))) { |
|
177 | + if (!empty($this->header->get("id"))) { |
|
178 | 178 | $this->id = $this->header->get("id"); |
179 | - } else if(!empty($this->header->get("x_attachment_id"))){ |
|
179 | + }else if (!empty($this->header->get("x_attachment_id"))) { |
|
180 | 180 | $this->id = $this->header->get("x_attachment_id"); |
181 | - } else if(!empty($this->header->get("content_id"))){ |
|
181 | + }else if (!empty($this->header->get("content_id"))) { |
|
182 | 182 | $this->id = strtr($this->header->get("content_id"), [ |
183 | 183 | '<' => '', |
184 | 184 | '>' => '' |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $content_types = $this->header->get("content_type"); |
189 | - if(!empty($content_types)){ |
|
189 | + if (!empty($content_types)) { |
|
190 | 190 | $this->subtype = $this->parseSubtype($content_types); |
191 | 191 | $content_type = $content_types; |
192 | 192 | if (is_array($content_types)) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @return string |
208 | 208 | * @throws InvalidMessageDateException |
209 | 209 | */ |
210 | - private function findHeaders(){ |
|
210 | + private function findHeaders() { |
|
211 | 211 | $body = $this->raw; |
212 | 212 | while (($pos = strpos($body, "\r\n")) > 0) { |
213 | 213 | $body = substr($body, $pos + 2); |
@@ -226,16 +226,16 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - private function parseSubtype($content_type){ |
|
229 | + private function parseSubtype($content_type) { |
|
230 | 230 | if (is_array($content_type)) { |
231 | - foreach ($content_type as $part){ |
|
232 | - if ((strpos($part, "/")) !== false){ |
|
231 | + foreach ($content_type as $part) { |
|
232 | + if ((strpos($part, "/")) !== false) { |
|
233 | 233 | return $this->parseSubtype($part); |
234 | 234 | } |
235 | 235 | } |
236 | 236 | return null; |
237 | 237 | } |
238 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
238 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
239 | 239 | return substr($content_type, $pos + 1); |
240 | 240 | } |
241 | 241 | return null; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * Try to parse the disposition if any is present |
246 | 246 | */ |
247 | - private function parseDisposition(){ |
|
247 | + private function parseDisposition() { |
|
248 | 248 | $content_disposition = $this->header->get("content_disposition"); |
249 | - if($content_disposition !== null) { |
|
249 | + if ($content_disposition !== null) { |
|
250 | 250 | $this->ifdisposition = true; |
251 | 251 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
252 | 252 | } |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | /** |
256 | 256 | * Try to parse the description if any is present |
257 | 257 | */ |
258 | - private function parseDescription(){ |
|
258 | + private function parseDescription() { |
|
259 | 259 | $content_description = $this->header->get("content_description"); |
260 | - if($content_description !== null) { |
|
260 | + if ($content_description !== null) { |
|
261 | 261 | $this->ifdescription = true; |
262 | 262 | $this->description = $content_description; |
263 | 263 | } |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | /** |
267 | 267 | * Try to parse the encoding if any is present |
268 | 268 | */ |
269 | - private function parseEncoding(){ |
|
269 | + private function parseEncoding() { |
|
270 | 270 | $encoding = $this->header->get("content_transfer_encoding"); |
271 | - if($encoding !== null) { |
|
271 | + if ($encoding !== null) { |
|
272 | 272 | switch (strtolower($encoding)) { |
273 | 273 | case "quoted-printable": |
274 | 274 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function isAttachment(){ |
|
301 | + public function isAttachment() { |
|
302 | 302 | $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')); |
303 | 303 | |
304 | 304 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) { |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws MessageContentFetchingException |
78 | 78 | * @throws InvalidMessageDateException |
79 | 79 | */ |
80 | - protected function parse(){ |
|
80 | + protected function parse() { |
|
81 | 81 | $this->findContentType(); |
82 | 82 | $this->parts = $this->find_parts(); |
83 | 83 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Determine the message content type |
87 | 87 | */ |
88 | - public function findContentType(){ |
|
88 | + public function findContentType() { |
|
89 | 89 | $content_type = $this->header->get("content_type"); |
90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
91 | - if(stripos($content_type, 'multipart') === 0) { |
|
91 | + if (stripos($content_type, 'multipart') === 0) { |
|
92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
93 | - }else{ |
|
93 | + }else { |
|
94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
95 | 95 | } |
96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | * @return Part[] |
104 | 104 | * @throws InvalidMessageDateException |
105 | 105 | */ |
106 | - private function parsePart($context, $part_number = 0){ |
|
106 | + private function parsePart($context, $part_number = 0) { |
|
107 | 107 | $body = $context; |
108 | 108 | while (($pos = strpos($body, "\r\n")) > 0) { |
109 | 109 | $body = substr($body, $pos + 2); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @return array |
127 | 127 | * @throws InvalidMessageDateException |
128 | 128 | */ |
129 | - private function detectParts($boundary, $context, $part_number = 0){ |
|
130 | - $base_parts = explode( $boundary, $context); |
|
129 | + private function detectParts($boundary, $context, $part_number = 0) { |
|
130 | + $base_parts = explode($boundary, $context); |
|
131 | 131 | $final_parts = []; |
132 | - foreach($base_parts as $ctx) { |
|
132 | + foreach ($base_parts as $ctx) { |
|
133 | 133 | $ctx = substr($ctx, 2); |
134 | 134 | if ($ctx !== "--" && $ctx != "") { |
135 | 135 | $parts = $this->parsePart($ctx, $part_number); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @throws MessageContentFetchingException |
151 | 151 | * @throws InvalidMessageDateException |
152 | 152 | */ |
153 | - public function find_parts(){ |
|
154 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
153 | + public function find_parts() { |
|
154 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
155 | + if (($boundary = $this->header->getBoundary()) === null) { |
|
156 | 156 | throw new MessageContentFetchingException("no content found", 0); |
157 | 157 | } |
158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return string|null |
169 | 169 | * @Depricated since version 2.4.4 |
170 | 170 | */ |
171 | - public function getBoundary(){ |
|
171 | + public function getBoundary() { |
|
172 | 172 | return $this->header->getBoundary(); |
173 | 173 | } |
174 | 174 | } |
@@ -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); |
@@ -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($charset = 'UTF-8'){ |
|
139 | + public function query($charset = 'UTF-8') { |
|
140 | 140 | $this->getClient()->checkConnection(); |
141 | 141 | $this->getClient()->openFolder($this->path); |
142 | 142 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @throws Exceptions\ConnectionFailedException |
149 | 149 | * @throws Exceptions\RuntimeException |
150 | 150 | */ |
151 | - public function search($charset = 'UTF-8'){ |
|
151 | + public function search($charset = 'UTF-8') { |
|
152 | 152 | return $this->query($charset); |
153 | 153 | } |
154 | 154 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @throws Exceptions\ConnectionFailedException |
158 | 158 | * @throws Exceptions\RuntimeException |
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 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function move($new_name, $expunge = true) { |
233 | 233 | $this->client->checkConnection(); |
234 | 234 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
235 | - if($expunge) $this->client->expunge(); |
|
235 | + if ($expunge) $this->client->expunge(); |
|
236 | 236 | |
237 | 237 | $folder = $this->client->getFolder($new_name); |
238 | 238 | $event = $this->getEvent("folder", "moved"); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * @throws Exceptions\MessageNotFoundException |
252 | 252 | * @throws Exceptions\RuntimeException |
253 | 253 | */ |
254 | - public function overview($sequence = null){ |
|
254 | + public function overview($sequence = null) { |
|
255 | 255 | $this->client->openFolder($this->path); |
256 | 256 | $sequence = $sequence === null ? "1:*" : $sequence; |
257 | 257 | $uid = ClientManager::get('options.sequence', IMAP::ST_MSGN) == IMAP::ST_UID; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | |
278 | 278 | if ($internal_date != null) { |
279 | - if ($internal_date instanceof Carbon){ |
|
279 | + if ($internal_date instanceof Carbon) { |
|
280 | 280 | $internal_date = $internal_date->format('d-M-Y H:i:s O'); |
281 | 281 | } |
282 | 282 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function delete($expunge = true) { |
312 | 312 | $status = $this->client->getConnection()->deleteFolder($this->path); |
313 | - if($expunge) $this->client->expunge(); |
|
313 | + if ($expunge) $this->client->expunge(); |
|
314 | 314 | |
315 | 315 | $event = $this->getEvent("folder", "deleted"); |
316 | 316 | $event::dispatch($this); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | try { |
372 | 372 | $line = $connection->nextLine(); |
373 | 373 | if (($pos = strpos($line, "EXISTS")) !== false) { |
374 | - $msgn = (int) substr($line, 2, $pos -2); |
|
374 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
375 | 375 | $connection->done(); |
376 | 376 | |
377 | 377 | $this->client->openFolder($this->path, true); |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | |
385 | 385 | $connection->idle(); |
386 | 386 | } |
387 | - }catch (Exceptions\RuntimeException $e) { |
|
388 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
387 | + } catch (Exceptions\RuntimeException $e) { |
|
388 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
389 | 389 | throw $e; |
390 | 390 | } |
391 | 391 | if ($auto_reconnect === true) { |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * Set the delimiter |
435 | 435 | * @param $delimiter |
436 | 436 | */ |
437 | - public function setDelimiter($delimiter){ |
|
438 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
437 | + public function setDelimiter($delimiter) { |
|
438 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
439 | 439 | $delimiter = ClientManager::get('options.delimiter', '/'); |
440 | 440 | } |
441 | 441 |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | if (ClientManager::get('options.fetch_order') === 'desc') { |
97 | 97 | $this->fetch_order = 'desc'; |
98 | - } else { |
|
98 | + }else { |
|
99 | 99 | $this->fetch_order = 'asc'; |
100 | 100 | } |
101 | 101 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | break; |
127 | 127 | } |
128 | 128 | |
129 | - return (string)$value; |
|
129 | + return (string) $value; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | $this->query->each(function($statement) use (&$query) { |
159 | 159 | if (count($statement) == 1) { |
160 | 160 | $query .= $statement[0]; |
161 | - } else { |
|
161 | + }else { |
|
162 | 162 | if ($statement[1] === null) { |
163 | 163 | $query .= $statement[0]; |
164 | - } else { |
|
165 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
164 | + }else { |
|
165 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | $query .= ' '; |
@@ -247,18 +247,18 @@ discard block |
||
247 | 247 | * @throws GetMessagesFailedException |
248 | 248 | * @throws ReflectionException |
249 | 249 | */ |
250 | - protected function make($uid, $msglist, $header, $content, $flags){ |
|
250 | + protected function make($uid, $msglist, $header, $content, $flags) { |
|
251 | 251 | try { |
252 | 252 | return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence); |
253 | - }catch (MessageNotFoundException $e) { |
|
253 | + } catch (MessageNotFoundException $e) { |
|
254 | 254 | $this->setError($uid, $e); |
255 | - }catch (RuntimeException $e) { |
|
255 | + } catch (RuntimeException $e) { |
|
256 | 256 | $this->setError($uid, $e); |
257 | - }catch (MessageFlagException $e) { |
|
257 | + } catch (MessageFlagException $e) { |
|
258 | 258 | $this->setError($uid, $e); |
259 | - }catch (InvalidMessageDateException $e) { |
|
259 | + } catch (InvalidMessageDateException $e) { |
|
260 | 260 | $this->setError($uid, $e); |
261 | - }catch (MessageContentFetchingException $e) { |
|
261 | + } catch (MessageContentFetchingException $e) { |
|
262 | 262 | $this->setError($uid, $e); |
263 | 263 | } |
264 | 264 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - protected function getMessageKey($message_key, $msglist, $message){ |
|
278 | + protected function getMessageKey($message_key, $msglist, $message) { |
|
279 | 279 | switch ($message_key) { |
280 | 280 | case 'number': |
281 | 281 | $key = $message->getMessageNo(); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $key = $message->getMessageId(); |
291 | 291 | break; |
292 | 292 | } |
293 | - return (string)$key; |
|
293 | + return (string) $key; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | * |
783 | 783 | * @return boolean |
784 | 784 | */ |
785 | - public function hasErrors($uid = null){ |
|
785 | + public function hasErrors($uid = null) { |
|
786 | 786 | if ($uid !== null) { |
787 | 787 | return $this->hasError($uid); |
788 | 788 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * |
796 | 796 | * @return boolean |
797 | 797 | */ |
798 | - public function hasError($uid){ |
|
798 | + public function hasError($uid) { |
|
799 | 799 | return isset($this->errors[$uid]); |
800 | 800 | } |
801 | 801 | |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @return array |
806 | 806 | */ |
807 | - public function errors(){ |
|
807 | + public function errors() { |
|
808 | 808 | return $this->getErrors(); |
809 | 809 | } |
810 | 810 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | * |
814 | 814 | * @return array |
815 | 815 | */ |
816 | - public function getErrors(){ |
|
816 | + public function getErrors() { |
|
817 | 817 | return $this->errors; |
818 | 818 | } |
819 | 819 | |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | * |
824 | 824 | * @return Exception|null |
825 | 825 | */ |
826 | - public function error($uid){ |
|
826 | + public function error($uid) { |
|
827 | 827 | return $this->getError($uid); |
828 | 828 | } |
829 | 829 | |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | * |
834 | 834 | * @return Exception|null |
835 | 835 | */ |
836 | - public function getError($uid){ |
|
836 | + public function getError($uid) { |
|
837 | 837 | if ($this->hasError($uid)) { |
838 | 838 | return $this->errors[$uid]; |
839 | 839 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public function toString(){ |
|
60 | + public function toString() { |
|
61 | 61 | return $this->__toString(); |
62 | 62 | } |
63 | 63 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function __serialize(){ |
|
69 | + public function __serialize() { |
|
70 | 70 | return $this->values; |
71 | 71 | } |
72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return array |
77 | 77 | */ |
78 | - public function toArray(){ |
|
78 | + public function toArray() { |
|
79 | 79 | return $this->__serialize(); |
80 | 80 | } |
81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return Carbon|null |
86 | 86 | */ |
87 | - public function toDate(){ |
|
87 | + public function toDate() { |
|
88 | 88 | $date = $this->first(); |
89 | 89 | if ($date instanceof Carbon) return $date; |
90 | 90 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function offsetSet($key, $value) { |
122 | 122 | if (is_null($key)) { |
123 | 123 | $this->values[] = $value; |
124 | - } else { |
|
124 | + }else { |
|
125 | 125 | $this->values[$key] = $value; |
126 | 126 | } |
127 | 127 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | if ($this->contains($value) === false) { |
196 | 196 | $this->values[] = $value; |
197 | 197 | } |
198 | - }else{ |
|
198 | + }else { |
|
199 | 199 | $this->values[] = $value; |
200 | 200 | } |
201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return Attribute |
208 | 208 | */ |
209 | - public function setName($name){ |
|
209 | + public function setName($name) { |
|
210 | 210 | $this->name = $name; |
211 | 211 | |
212 | 212 | return $this; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function getName(){ |
|
220 | + public function getName() { |
|
221 | 221 | return $this->name; |
222 | 222 | } |
223 | 223 | |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - public function get(){ |
|
229 | + public function get() { |
|
230 | 230 | return $this->values; |
231 | 231 | } |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return array |
237 | 237 | */ |
238 | - public function all(){ |
|
238 | + public function all() { |
|
239 | 239 | return $this->get(); |
240 | 240 | } |
241 | 241 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return mixed|null |
246 | 246 | */ |
247 | - public function first(){ |
|
247 | + public function first() { |
|
248 | 248 | if ($this->offsetExists(0)) { |
249 | 249 | return $this->values[0]; |
250 | 250 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return mixed|null |
258 | 258 | */ |
259 | - public function last(){ |
|
259 | + public function last() { |
|
260 | 260 | if (($cnt = $this->count()) > 0) { |
261 | 261 | return $this->values[$cnt - 1]; |
262 | 262 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return int |
270 | 270 | */ |
271 | - public function count(){ |
|
271 | + public function count() { |
|
272 | 272 | return count($this->values); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | \ No newline at end of file |
@@ -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; |
@@ -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 | /** |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | } |
132 | 132 | return $this->where($key, $value); |
133 | 133 | } |
134 | - } else { |
|
134 | + }else { |
|
135 | 135 | $criteria = $this->validate_criteria($criteria); |
136 | 136 | $value = $this->parse_value($value); |
137 | 137 | |
138 | 138 | if ($value === null || $value === '') { |
139 | 139 | $this->query->push([$criteria]); |
140 | - } else { |
|
140 | + }else { |
|
141 | 141 | $this->query->push([$criteria, $value]); |
142 | 142 | } |
143 | 143 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | * @return $this|mixed |
492 | 492 | */ |
493 | 493 | public function unless($value, $callback, $default = null) { |
494 | - if (! $value) { |
|
494 | + if (!$value) { |
|
495 | 495 | return $callback($this, $value) ?: $this; |
496 | 496 | } elseif ($default) { |
497 | 497 | return $default($this, $value) ?: $this; |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | throw new AuthFailedException($message); |
91 | 91 | } |
92 | 92 | |
93 | - if(!$this->stream) { |
|
93 | + if (!$this->stream) { |
|
94 | 94 | $errors = \imap_errors(); |
95 | 95 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
96 | 96 | throw new AuthFailedException($message); |
97 | 97 | } |
98 | 98 | |
99 | 99 | $errors = \imap_errors(); |
100 | - if(is_array($errors)) { |
|
100 | + if (is_array($errors)) { |
|
101 | 101 | $status = $this->examineFolder(); |
102 | - if($status['exists'] !== 0) { |
|
102 | + if ($status['exists'] !== 0) { |
|
103 | 103 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
104 | 104 | throw new RuntimeException($message); |
105 | 105 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | if (!$this->cert_validation) { |
131 | 131 | $address .= '/novalidate-cert'; |
132 | 132 | } |
133 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
133 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
134 | 134 | $address .= '/'.$this->encryption; |
135 | 135 | } elseif ($this->encryption === "starttls") { |
136 | 136 | $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 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return array |
234 | 234 | */ |
235 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
235 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
236 | 236 | $result = []; |
237 | 237 | $uids = is_array($uids) ? $uids : [$uids]; |
238 | 238 | foreach ($uids as $id) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return array |
250 | 250 | */ |
251 | - public function flags($uids, $uid = false){ |
|
251 | + public function flags($uids, $uid = false) { |
|
252 | 252 | $result = []; |
253 | 253 | $uids = is_array($uids) ? $uids : [$uids]; |
254 | 254 | foreach ($uids as $id) { |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | $flags = []; |
257 | 257 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
258 | 258 | $raw_flags = (array) $raw_flags[0]; |
259 | - foreach($raw_flags as $flag => $value) { |
|
260 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
259 | + foreach ($raw_flags as $flag => $value) { |
|
260 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
261 | 261 | $flags[] = "\\".ucfirst($flag); |
262 | 262 | } |
263 | 263 | } |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | if ($id === null) { |
279 | 279 | $overview = $this->overview("1:*"); |
280 | 280 | $uids = []; |
281 | - foreach($overview as $set){ |
|
281 | + foreach ($overview as $set) { |
|
282 | 282 | $uids[$set->msgno] = $set->uid; |
283 | 283 | } |
284 | 284 | return $uids; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return array |
305 | 305 | */ |
306 | 306 | public function overview($sequence, $uid = false) { |
307 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::FT_UID : IMAP::NIL); |
|
307 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::FT_UID : IMAP::NIL); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -319,12 +319,12 @@ discard block |
||
319 | 319 | $result = []; |
320 | 320 | |
321 | 321 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
322 | - if(is_array($items)){ |
|
322 | + if (is_array($items)) { |
|
323 | 323 | foreach ($items as $item) { |
324 | 324 | $name = $this->decodeFolderName($item->name); |
325 | 325 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
326 | 326 | } |
327 | - }else{ |
|
327 | + }else { |
|
328 | 328 | throw new RuntimeException(\imap_last_error()); |
329 | 329 | } |
330 | 330 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
347 | 347 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
348 | 348 | |
349 | - if ($mode == "+"){ |
|
349 | + if ($mode == "+") { |
|
350 | 350 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
351 | - }else{ |
|
351 | + }else { |
|
352 | 352 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
353 | 353 | } |
354 | 354 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
372 | 372 | if ($date != null) { |
373 | - if ($date instanceof \Carbon\Carbon){ |
|
373 | + if ($date instanceof \Carbon\Carbon) { |
|
374 | 374 | $date = $date->format('d-M-Y H:i:s O'); |
375 | 375 | } |
376 | 376 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | /** |
508 | 508 | * Enable the debug mode |
509 | 509 | */ |
510 | - public function enableDebug(){ |
|
510 | + public function enableDebug() { |
|
511 | 511 | $this->debug = true; |
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
515 | 515 | * Disable the debug mode |
516 | 516 | */ |
517 | - public function disableDebug(){ |
|
517 | + public function disableDebug() { |
|
518 | 518 | $this->debug = false; |
519 | 519 | } |
520 | 520 |