@@ -76,18 +76,18 @@ discard block |
||
76 | 76 | |
77 | 77 | $name = Str::camel($name); |
78 | 78 | |
79 | - if(strtolower(substr($name, 0, 3)) === 'not') { |
|
79 | + if (strtolower(substr($name, 0, 3)) === 'not') { |
|
80 | 80 | $that = $that->whereNot(); |
81 | 81 | $name = substr($name, 3); |
82 | 82 | } |
83 | 83 | |
84 | - if (strpos(strtolower($name), "where") === false){ |
|
84 | + if (strpos(strtolower($name), "where") === false) { |
|
85 | 85 | $method = 'where'.ucfirst($name); |
86 | - }else{ |
|
86 | + }else { |
|
87 | 87 | $method = lcfirst($name); |
88 | 88 | } |
89 | 89 | |
90 | - if(method_exists($this, $method) === true){ |
|
90 | + if (method_exists($this, $method) === true) { |
|
91 | 91 | return call_user_func_array([$that, $method], $arguments); |
92 | 92 | } |
93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | if (substr($criteria, 0, 7) === "CUSTOM ") { |
107 | 107 | return substr($criteria, 7); |
108 | 108 | } |
109 | - if(in_array($criteria, $this->available_criteria) === false) { |
|
109 | + if (in_array($criteria, $this->available_criteria) === false) { |
|
110 | 110 | throw new InvalidWhereQueryCriteriaException(); |
111 | 111 | } |
112 | 112 | |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | * @throws InvalidWhereQueryCriteriaException |
122 | 122 | */ |
123 | 123 | public function where($criteria, $value = null) { |
124 | - if(is_array($criteria)){ |
|
125 | - foreach($criteria as $key => $value){ |
|
126 | - if(is_numeric($key)){ |
|
124 | + if (is_array($criteria)) { |
|
125 | + foreach ($criteria as $key => $value) { |
|
126 | + if (is_numeric($key)) { |
|
127 | 127 | return $this->where($value); |
128 | 128 | } |
129 | 129 | return $this->where($key, $value); |
130 | 130 | } |
131 | - }else{ |
|
131 | + }else { |
|
132 | 132 | $criteria = $this->validate_criteria($criteria); |
133 | 133 | $value = $this->parse_value($value); |
134 | 134 | |
135 | - if($value === null || $value === ''){ |
|
135 | + if ($value === null || $value === '') { |
|
136 | 136 | $this->query->push([$criteria]); |
137 | - }else{ |
|
137 | + }else { |
|
138 | 138 | $this->query->push([$criteria, $value]); |
139 | 139 | } |
140 | 140 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function orWhere(\Closure $closure = null) { |
151 | 151 | $this->query->push(['OR']); |
152 | - if($closure !== null) $closure($this); |
|
152 | + if ($closure !== null) $closure($this); |
|
153 | 153 | |
154 | 154 | return $this; |
155 | 155 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function andWhere(\Closure $closure = null) { |
163 | 163 | $this->query->push(['AND']); |
164 | - if($closure !== null) $closure($this); |
|
164 | + if ($closure !== null) $closure($this); |
|
165 | 165 | |
166 | 166 | return $this; |
167 | 167 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | * @return WhereQuery |
402 | 402 | * @throws InvalidWhereQueryCriteriaException |
403 | 403 | */ |
404 | - public function whereNoXSpam(){ |
|
404 | + public function whereNoXSpam() { |
|
405 | 405 | return $this->where("CUSTOM X-Spam-Flag NO"); |
406 | 406 | } |
407 | 407 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * @return WhereQuery |
410 | 410 | * @throws InvalidWhereQueryCriteriaException |
411 | 411 | */ |
412 | - public function whereIsXSpam(){ |
|
412 | + public function whereIsXSpam() { |
|
413 | 413 | return $this->where("CUSTOM X-Spam-Flag YES"); |
414 | 414 | } |
415 | 415 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * @return WhereQuery |
422 | 422 | * @throws InvalidWhereQueryCriteriaException |
423 | 423 | */ |
424 | - public function whereHeader($header, $value){ |
|
424 | + public function whereHeader($header, $value) { |
|
425 | 425 | return $this->where("CUSTOM HEADER $header $value"); |
426 | 426 | } |
427 | 427 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return WhereQuery |
433 | 433 | * @throws InvalidWhereQueryCriteriaException |
434 | 434 | */ |
435 | - public function whereMessageId($messageId){ |
|
435 | + public function whereMessageId($messageId) { |
|
436 | 436 | return $this->whereHeader("Message-ID", $messageId); |
437 | 437 | } |
438 | 438 | |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @return WhereQuery |
444 | 444 | * @throws InvalidWhereQueryCriteriaException |
445 | 445 | */ |
446 | - public function whereInReplyTo($messageId){ |
|
446 | + public function whereInReplyTo($messageId) { |
|
447 | 447 | return $this->whereHeader("In-Reply-To", $messageId); |
448 | 448 | } |
449 | 449 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return WhereQuery |
454 | 454 | * @throws InvalidWhereQueryCriteriaException |
455 | 455 | */ |
456 | - public function whereLanguage($country_code){ |
|
456 | + public function whereLanguage($country_code) { |
|
457 | 457 | return $this->where("Content-Language $country_code"); |
458 | 458 | } |
459 | 459 | } |
460 | 460 | \ No newline at end of file |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | throw new AuthFailedException($message); |
88 | 88 | } |
89 | 89 | |
90 | - if(!$this->stream) { |
|
90 | + if (!$this->stream) { |
|
91 | 91 | $errors = \imap_errors(); |
92 | 92 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
93 | 93 | throw new AuthFailedException($message); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | if (!$this->cert_validation) { |
119 | 119 | $address .= '/novalidate-cert'; |
120 | 120 | } |
121 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
121 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
122 | 122 | $address .= '/'.$this->encryption; |
123 | 123 | } elseif ($this->encryption === "starttls") { |
124 | 124 | $address .= '/tls'; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - public function connected(){ |
|
149 | + public function connected() { |
|
150 | 150 | return !$this->stream; |
151 | 151 | } |
152 | 152 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
221 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
222 | 222 | $result = []; |
223 | 223 | $uids = is_array($uids) ? $uids : [$uids]; |
224 | 224 | foreach ($uids as $uid) { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return array |
236 | 236 | */ |
237 | - public function flags($uids, $uid = false){ |
|
237 | + public function flags($uids, $uid = false) { |
|
238 | 238 | $result = []; |
239 | 239 | $uids = is_array($uids) ? $uids : [$uids]; |
240 | 240 | foreach ($uids as $uid) { |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | $flags = []; |
243 | 243 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
244 | 244 | $raw_flags = (array) $raw_flags[0]; |
245 | - foreach($raw_flags as $flag => $value) { |
|
246 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
245 | + foreach ($raw_flags as $flag => $value) { |
|
246 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
247 | 247 | $flags[] = "\\".ucfirst($flag); |
248 | 248 | } |
249 | 249 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | if ($id === null) { |
265 | 265 | $overview = $this->overview("1:*"); |
266 | 266 | $uids = []; |
267 | - foreach($overview as $set){ |
|
267 | + foreach ($overview as $set) { |
|
268 | 268 | $uids[$set->msgno] = $set->uid; |
269 | 269 | } |
270 | 270 | return $uids; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return array |
291 | 291 | */ |
292 | 292 | public function overview($sequence, $uid = false) { |
293 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::FT_UID : IMAP::NIL); |
|
293 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::FT_UID : IMAP::NIL); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | $result = []; |
306 | 306 | |
307 | 307 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
308 | - if(is_array($items)){ |
|
308 | + if (is_array($items)) { |
|
309 | 309 | foreach ($items as $item) { |
310 | 310 | $name = $this->decodeFolderName($item->name); |
311 | 311 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
312 | 312 | } |
313 | - }else{ |
|
313 | + }else { |
|
314 | 314 | throw new RuntimeException(\imap_last_error()); |
315 | 315 | } |
316 | 316 | |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
333 | 333 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
334 | 334 | |
335 | - if ($mode == "+"){ |
|
335 | + if ($mode == "+") { |
|
336 | 336 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
337 | - }else{ |
|
337 | + }else { |
|
338 | 338 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::FT_UID : IMAP::NIL); |
339 | 339 | } |
340 | 340 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
358 | 358 | if ($date != null) { |
359 | - if ($date instanceof \Carbon\Carbon){ |
|
359 | + if ($date instanceof \Carbon\Carbon) { |
|
360 | 360 | $date = $date->format('d-M-Y H:i:s O'); |
361 | 361 | } |
362 | 362 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -493,14 +493,14 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * Enable the debug mode |
495 | 495 | */ |
496 | - public function enableDebug(){ |
|
496 | + public function enableDebug() { |
|
497 | 497 | $this->debug = true; |
498 | 498 | } |
499 | 499 | |
500 | 500 | /** |
501 | 501 | * Disable the debug mode |
502 | 502 | */ |
503 | - public function disableDebug(){ |
|
503 | + public function disableDebug() { |
|
504 | 504 | $this->debug = false; |
505 | 505 | } |
506 | 506 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @return string |
62 | 62 | */ |
63 | - public function toString(){ |
|
63 | + public function toString() { |
|
64 | 64 | return $this->__toString(); |
65 | 65 | } |
66 | 66 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return array |
71 | 71 | */ |
72 | - public function __serialize(){ |
|
72 | + public function __serialize() { |
|
73 | 73 | return $this->values; |
74 | 74 | } |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @return array |
80 | 80 | */ |
81 | - public function toArray(){ |
|
81 | + public function toArray() { |
|
82 | 82 | return $this->__serialize(); |
83 | 83 | } |
84 | 84 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | if ($this->contains($value) === false) { |
142 | 142 | $this->values[] = $value; |
143 | 143 | } |
144 | - }else{ |
|
144 | + }else { |
|
145 | 145 | $this->values[] = $value; |
146 | 146 | } |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return Attribute |
154 | 154 | */ |
155 | - public function setName($name){ |
|
155 | + public function setName($name) { |
|
156 | 156 | $this->name = $name; |
157 | 157 | |
158 | 158 | return $this; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function getName(){ |
|
166 | + public function getName() { |
|
167 | 167 | return $this->name; |
168 | 168 | } |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return array |
174 | 174 | */ |
175 | - public function get(){ |
|
175 | + public function get() { |
|
176 | 176 | return $this->values; |
177 | 177 | } |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return array |
183 | 183 | */ |
184 | - public function all(){ |
|
184 | + public function all() { |
|
185 | 185 | return $this->get(); |
186 | 186 | } |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return mixed|null |
192 | 192 | */ |
193 | - public function first(){ |
|
193 | + public function first() { |
|
194 | 194 | if (count($this->values) > 0) { |
195 | 195 | return $this->values[0]; |
196 | 196 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return mixed|null |
204 | 204 | */ |
205 | - public function last(){ |
|
205 | + public function last() { |
|
206 | 206 | $cnt = count($this->values); |
207 | 207 | if ($cnt > 0) { |
208 | 208 | return $this->values[$cnt - 1]; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param object $object |
45 | 45 | */ |
46 | 46 | public function __construct($object) { |
47 | - if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
|
48 | - if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
|
49 | - if (property_exists($object, "host")){ $this->host = $object->host; } |
|
50 | - if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
|
51 | - if (property_exists($object, "full")){ $this->full = $object->full; } |
|
47 | + if (property_exists($object, "personal")) { $this->personal = $object->personal; } |
|
48 | + if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; } |
|
49 | + if (property_exists($object, "host")) { $this->host = $object->host; } |
|
50 | + if (property_exists($object, "mail")) { $this->mail = $object->mail; } |
|
51 | + if (property_exists($object, "full")) { $this->full = $object->full; } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -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 [ |
71 | 71 | "personal" => $this->personal, |
72 | 72 | "mailbox" => $this->mailbox, |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function toArray(){ |
|
84 | + public function toArray() { |
|
85 | 85 | return $this->__serialize(); |
86 | 86 | } |
87 | 87 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function toString(){ |
|
93 | + public function toString() { |
|
94 | 94 | return $this->__toString(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | \ No newline at end of file |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws ConnectionFailedException |
85 | 85 | * @throws RuntimeException |
86 | 86 | */ |
87 | - protected function enableTls(){ |
|
87 | + protected function enableTls() { |
|
88 | 88 | $response = $this->requestAndResponse('STARTTLS'); |
89 | 89 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
90 | 90 | if (!$result) { |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $stack = []; |
147 | 147 | |
148 | 148 | // replace any trailing <NL> including spaces with a single space |
149 | - $line = rtrim($line) . ' '; |
|
149 | + $line = rtrim($line).' '; |
|
150 | 150 | while (($pos = strpos($line, ' ')) !== false) { |
151 | 151 | $token = substr($line, 0, $pos); |
152 | 152 | if (!strlen($token)) { |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | if (strlen($token) > $chars) { |
177 | 177 | $line = substr($token, $chars); |
178 | 178 | $token = substr($token, 0, $chars); |
179 | - } else { |
|
179 | + }else { |
|
180 | 180 | $line .= $this->nextLine(); |
181 | 181 | } |
182 | 182 | $tokens[] = $token; |
183 | - $line = trim($line) . ' '; |
|
183 | + $line = trim($line).' '; |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $line = $this->nextTaggedLine($tag); // get next tag |
231 | 231 | if (!$dontParse) { |
232 | 232 | $tokens = $this->decodeLine($line); |
233 | - } else { |
|
233 | + }else { |
|
234 | 234 | $tokens = $line; |
235 | 235 | } |
236 | 236 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -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,9 +564,9 @@ discard block |
||
564 | 564 | $count = count($tokens[2]); |
565 | 565 | if ($tokens[2][$count - 2] == 'UID') { |
566 | 566 | $uidKey = $count - 1; |
567 | - } else if ($tokens[2][0] == 'UID') { |
|
567 | + }else if ($tokens[2][0] == 'UID') { |
|
568 | 568 | $uidKey = 1; |
569 | - } else { |
|
569 | + }else { |
|
570 | 570 | $uidKey = array_search('UID', $tokens[2]) + 1; |
571 | 571 | } |
572 | 572 | } |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | $data = $tokens[2][1]; |
583 | 583 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
584 | 584 | $data = $tokens[2][3]; |
585 | - } else { |
|
585 | + }else { |
|
586 | 586 | // maybe the server send an other field we didn't wanted |
587 | 587 | $count = count($tokens[2]); |
588 | 588 | // we start with 2, because 0 was already checked |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | break; |
595 | 595 | } |
596 | 596 | } |
597 | - } else { |
|
597 | + }else { |
|
598 | 598 | $data = []; |
599 | 599 | while (key($tokens[2]) !== null) { |
600 | 600 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | } |
612 | 612 | if ($uid) { |
613 | 613 | $result[$tokens[2][$uidKey]] = $data; |
614 | - }else{ |
|
614 | + }else { |
|
615 | 615 | $result[$tokens[0]] = $data; |
616 | 616 | } |
617 | 617 | } |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | * @return array |
646 | 646 | * @throws RuntimeException |
647 | 647 | */ |
648 | - public function headers($uids, $rfc = "RFC822", $uid = false){ |
|
648 | + public function headers($uids, $rfc = "RFC822", $uid = false) { |
|
649 | 649 | return $this->fetch(["$rfc.HEADER"], $uids, null, $uid); |
650 | 650 | } |
651 | 651 | |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * @return array |
658 | 658 | * @throws RuntimeException |
659 | 659 | */ |
660 | - public function flags($uids, $uid = false){ |
|
660 | + public function flags($uids, $uid = false) { |
|
661 | 661 | return $this->fetch(["FLAGS"], $uids, null, $uid); |
662 | 662 | } |
663 | 663 | |
@@ -742,23 +742,23 @@ discard block |
||
742 | 742 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = false) { |
743 | 743 | $item = 'FLAGS'; |
744 | 744 | if ($mode == '+' || $mode == '-') { |
745 | - $item = $mode . $item; |
|
745 | + $item = $mode.$item; |
|
746 | 746 | } |
747 | 747 | if ($silent) { |
748 | 748 | $item .= '.SILENT'; |
749 | 749 | } |
750 | 750 | |
751 | 751 | $flags = $this->escapeList($flags); |
752 | - $set = (int)$from; |
|
752 | + $set = (int) $from; |
|
753 | 753 | if ($to !== null) { |
754 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
754 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | $command = ($uid ? "UID " : "")."STORE"; |
758 | 758 | $result = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
759 | 759 | |
760 | 760 | if ($silent) { |
761 | - return (bool)$result; |
|
761 | + return (bool) $result; |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | $tokens = $result; |
@@ -809,9 +809,9 @@ discard block |
||
809 | 809 | * @throws RuntimeException |
810 | 810 | */ |
811 | 811 | public function copyMessage($folder, $from, $to = null, $uid = false) { |
812 | - $set = (int)$from; |
|
812 | + $set = (int) $from; |
|
813 | 813 | if ($to !== null) { |
814 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
814 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
815 | 815 | } |
816 | 816 | $command = ($uid ? "UID " : "")."COPY"; |
817 | 817 | |
@@ -830,9 +830,9 @@ discard block |
||
830 | 830 | * @throws RuntimeException |
831 | 831 | */ |
832 | 832 | public function moveMessage($folder, $from, $to = null, $uid = false) { |
833 | - $set = (int)$from; |
|
833 | + $set = (int) $from; |
|
834 | 834 | if ($to !== null) { |
835 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
835 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
836 | 836 | } |
837 | 837 | $command = ($uid ? "UID " : "")."MOVE"; |
838 | 838 | |
@@ -1002,7 +1002,7 @@ discard block |
||
1002 | 1002 | $ids = []; |
1003 | 1003 | foreach ($uids as $msgn => $v) { |
1004 | 1004 | $id = $uid ? $v : $msgn; |
1005 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1005 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1006 | 1006 | $ids[] = $id; |
1007 | 1007 | } |
1008 | 1008 | } |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | /** |
1017 | 1017 | * Enable the debug mode |
1018 | 1018 | */ |
1019 | - public function enableDebug(){ |
|
1019 | + public function enableDebug() { |
|
1020 | 1020 | $this->debug = true; |
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
1024 | 1024 | * Disable the debug mode |
1025 | 1025 | */ |
1026 | - public function disableDebug(){ |
|
1026 | + public function disableDebug() { |
|
1027 | 1027 | $this->debug = false; |
1028 | 1028 | } |
1029 | 1029 | } |
1030 | 1030 | \ No newline at end of file |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | $this->setClient($client); |
81 | 81 | |
82 | 82 | $this->sequence = ClientManager::get('options.sequence', IMAP::ST_MSGN); |
83 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
83 | + if (ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
84 | 84 | |
85 | 85 | if (ClientManager::get('options.fetch_order') === 'desc') { |
86 | 86 | $this->fetch_order = 'desc'; |
87 | - } else { |
|
87 | + }else { |
|
88 | 88 | $this->fetch_order = 'asc'; |
89 | 89 | } |
90 | 90 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Instance boot method for additional functionality |
100 | 100 | */ |
101 | - protected function boot(){} |
|
101 | + protected function boot() {} |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * Parse a given value |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - protected function parse_value($value){ |
|
110 | - switch(true){ |
|
109 | + protected function parse_value($value) { |
|
110 | + switch (true) { |
|
111 | 111 | case $value instanceof \Carbon\Carbon: |
112 | 112 | $value = $value->format($this->date_format); |
113 | 113 | break; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @throws MessageSearchValidationException |
125 | 125 | */ |
126 | 126 | protected function parse_date($date) { |
127 | - if($date instanceof \Carbon\Carbon) return $date; |
|
127 | + if ($date instanceof \Carbon\Carbon) return $date; |
|
128 | 128 | |
129 | 129 | try { |
130 | 130 | $date = Carbon::parse($date); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @return Collection |
176 | 176 | * @throws GetMessagesFailedException |
177 | 177 | */ |
178 | - protected function search(){ |
|
178 | + protected function search() { |
|
179 | 179 | $this->generate_query(); |
180 | 180 | |
181 | 181 | try { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $raw_flag = isset($raw_flags[$uid]) ? $raw_flags[$uid] : []; |
241 | 241 | |
242 | 242 | $message = Message::make($uid, $msglist, $this->getClient(), $raw_header, $raw_content, $raw_flag, $this->getFetchOptions(), $this->sequence); |
243 | - switch ($message_key){ |
|
243 | + switch ($message_key) { |
|
244 | 244 | case 'number': |
245 | 245 | $key = $message->getMessageNo(); |
246 | 246 | break; |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | |
263 | 263 | return $messages; |
264 | 264 | } catch (\Exception $e) { |
265 | - throw new GetMessagesFailedException($e->getMessage(),0, $e); |
|
265 | + throw new GetMessagesFailedException($e->getMessage(), 0, $e); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
282 | 282 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
283 | 283 | */ |
284 | - public function getMessage($uid, $msglist = null, $sequence = null){ |
|
284 | + public function getMessage($uid, $msglist = null, $sequence = null) { |
|
285 | 285 | return new Message($uid, $msglist, $this->getClient(), $this->getFetchOptions(), $this->getFetchBody(), $this->getFetchFlags(), $sequence ? $sequence : $this->sequence); |
286 | 286 | } |
287 | 287 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
300 | 300 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
301 | 301 | */ |
302 | - public function getMessageByMsgn($msgn, $msglist = null){ |
|
302 | + public function getMessageByMsgn($msgn, $msglist = null) { |
|
303 | 303 | return $this->getMessage($msgn, $msglist, IMAP::ST_MSGN); |
304 | 304 | } |
305 | 305 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @throws \Webklex\PHPIMAP\Exceptions\EventNotFoundException |
317 | 317 | * @throws \Webklex\PHPIMAP\Exceptions\MessageFlagException |
318 | 318 | */ |
319 | - public function getMessageByUid($uid){ |
|
319 | + public function getMessageByUid($uid) { |
|
320 | 320 | return $this->getMessage($uid, null, IMAP::ST_UID); |
321 | 321 | } |
322 | 322 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @return LengthAwarePaginator |
330 | 330 | * @throws GetMessagesFailedException |
331 | 331 | */ |
332 | - public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){ |
|
332 | + public function paginate($per_page = 5, $page = null, $page_name = 'imap_page') { |
|
333 | 333 | if ( |
334 | 334 | $page === null |
335 | 335 | && isset($_GET[$page_name]) |
@@ -355,10 +355,10 @@ discard block |
||
355 | 355 | $this->query->each(function($statement) use(&$query) { |
356 | 356 | if (count($statement) == 1) { |
357 | 357 | $query .= $statement[0]; |
358 | - } else { |
|
359 | - if($statement[1] === null){ |
|
358 | + }else { |
|
359 | + if ($statement[1] === null) { |
|
360 | 360 | $query .= $statement[0]; |
361 | - }else{ |
|
361 | + }else { |
|
362 | 362 | $query .= $statement[0].' "'.$statement[1].'"'; |
363 | 363 | } |
364 | 364 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return $this |
389 | 389 | */ |
390 | 390 | public function limit($limit, $page = 1) { |
391 | - if($page >= 1) $this->page = $page; |
|
391 | + if ($page >= 1) $this->page = $page; |
|
392 | 392 | $this->limit = $limit; |
393 | 393 | |
394 | 394 | return $this; |
@@ -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); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @throws Exceptions\ConnectionFailedException |
140 | 140 | * @throws Exceptions\RuntimeException |
141 | 141 | */ |
142 | - public function query($charset = 'UTF-8'){ |
|
142 | + public function query($charset = 'UTF-8') { |
|
143 | 143 | $this->getClient()->checkConnection(); |
144 | 144 | $this->getClient()->openFolder($this->path); |
145 | 145 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @throws Exceptions\ConnectionFailedException |
152 | 152 | * @throws Exceptions\RuntimeException |
153 | 153 | */ |
154 | - public function search($charset = 'UTF-8'){ |
|
154 | + public function search($charset = 'UTF-8') { |
|
155 | 155 | return $this->query($charset); |
156 | 156 | } |
157 | 157 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @throws Exceptions\ConnectionFailedException |
161 | 161 | * @throws Exceptions\RuntimeException |
162 | 162 | */ |
163 | - public function messages($charset = 'UTF-8'){ |
|
163 | + public function messages($charset = 'UTF-8') { |
|
164 | 164 | return $this->query($charset); |
165 | 165 | } |
166 | 166 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | public function move($new_name, $expunge = true) { |
236 | 236 | $this->client->checkConnection(); |
237 | 237 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
238 | - if($expunge) $this->client->expunge(); |
|
238 | + if ($expunge) $this->client->expunge(); |
|
239 | 239 | |
240 | 240 | $folder = $this->client->getFolder($new_name); |
241 | 241 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @throws ConnectionFailedException |
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); |
@@ -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) { |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | * Set the delimiter |
431 | 431 | * @param $delimiter |
432 | 432 | */ |
433 | - public function setDelimiter($delimiter){ |
|
434 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
433 | + public function setDelimiter($delimiter) { |
|
434 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
435 | 435 | $delimiter = ClientManager::get('options.delimiter', '/'); |
436 | 436 | } |
437 | 437 |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * @param array $config |
202 | 202 | * @param array $default_config |
203 | 203 | */ |
204 | - private function setAccountConfig($key, $config, $default_config){ |
|
204 | + private function setAccountConfig($key, $config, $default_config) { |
|
205 | 205 | $value = $this->default_account_config[$key]; |
206 | - if(isset($config[$key])) { |
|
206 | + if (isset($config[$key])) { |
|
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + }elseif (isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -217,9 +217,9 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function setEventsFromConfig($config) { |
219 | 219 | $this->events = ClientManager::get("events"); |
220 | - if(isset($config['events'])){ |
|
221 | - if(isset($config['events'])) { |
|
222 | - foreach($config['events'] as $section => $events) { |
|
220 | + if (isset($config['events'])) { |
|
221 | + if (isset($config['events'])) { |
|
222 | + foreach ($config['events'] as $section => $events) { |
|
223 | 223 | $this->events[$section] = array_merge($this->events[$section], $events); |
224 | 224 | } |
225 | 225 | } |
@@ -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_message_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_message_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_message_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 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
459 | 459 | $items = $this->connection->folders('', $pattern); |
460 | 460 | |
461 | - if(is_array($items)){ |
|
461 | + if (is_array($items)) { |
|
462 | 462 | foreach ($items as $folder_name => $item) { |
463 | 463 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
464 | 464 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | return $folders; |
476 | - }else{ |
|
476 | + }else { |
|
477 | 477 | throw new FolderFetchingException("failed to fetch any folders"); |
478 | 478 | } |
479 | 479 | } |
@@ -511,10 +511,10 @@ discard block |
||
511 | 511 | $this->checkConnection(); |
512 | 512 | $status = $this->connection->createFolder($folder); |
513 | 513 | |
514 | - if($expunge) $this->expunge(); |
|
514 | + if ($expunge) $this->expunge(); |
|
515 | 515 | |
516 | 516 | $folder = $this->getFolder($folder); |
517 | - if($status && $folder) { |
|
517 | + if ($status && $folder) { |
|
518 | 518 | $event = $this->getEvent("folder", "new"); |
519 | 519 | $event::dispatch($folder); |
520 | 520 | } |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return Folder |
542 | 542 | */ |
543 | - public function getFolderPath(){ |
|
543 | + public function getFolderPath() { |
|
544 | 544 | return $this->active_folder; |
545 | 545 | } |
546 | 546 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @return int |
598 | 598 | */ |
599 | - public function getTimeout($type){ |
|
599 | + public function getTimeout($type) { |
|
600 | 600 | return $this->connection->getConnectionTimeout(); |
601 | 601 | } |
602 | 602 | |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | * |
606 | 606 | * @return string |
607 | 607 | */ |
608 | - public function getDefaultMessageMask(){ |
|
608 | + public function getDefaultMessageMask() { |
|
609 | 609 | return $this->default_message_mask; |
610 | 610 | } |
611 | 611 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return array |
617 | 617 | */ |
618 | - public function getDefaultEvents($section){ |
|
618 | + public function getDefaultEvents($section) { |
|
619 | 619 | return $this->events[$section]; |
620 | 620 | } |
621 | 621 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @throws MaskNotFoundException |
628 | 628 | */ |
629 | 629 | public function setDefaultMessageMask($mask) { |
630 | - if(class_exists($mask)) { |
|
630 | + if (class_exists($mask)) { |
|
631 | 631 | $this->default_message_mask = $mask; |
632 | 632 | |
633 | 633 | return $this; |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | * |
642 | 642 | * @return string |
643 | 643 | */ |
644 | - public function getDefaultAttachmentMask(){ |
|
644 | + public function getDefaultAttachmentMask() { |
|
645 | 645 | return $this->default_attachment_mask; |
646 | 646 | } |
647 | 647 | |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * @throws MaskNotFoundException |
654 | 654 | */ |
655 | 655 | public function setDefaultAttachmentMask($mask) { |
656 | - if(class_exists($mask)) { |
|
656 | + if (class_exists($mask)) { |
|
657 | 657 | $this->default_attachment_mask = $mask; |
658 | 658 | |
659 | 659 | return $this; |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | public function __construct($uid, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false, $sequence = null) { |
203 | 203 | |
204 | 204 | $default_mask = $client->getDefaultMessageMask(); |
205 | - if($default_mask != null) { |
|
205 | + if ($default_mask != null) { |
|
206 | 206 | $this->mask = $default_mask; |
207 | 207 | } |
208 | 208 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @throws MessageFlagException |
262 | 262 | * @throws Exceptions\RuntimeException |
263 | 263 | */ |
264 | - public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null){ |
|
264 | + public static function make($uid, $msglist, Client $client, $raw_header, $raw_body, $raw_flags, $fetch_options = null, $sequence = null) { |
|
265 | 265 | $reflection = new \ReflectionClass(self::class); |
266 | 266 | /** @var self $instance */ |
267 | 267 | $instance = $reflection->newInstanceWithoutConstructor(); |
268 | 268 | |
269 | 269 | $default_mask = $client->getDefaultMessageMask(); |
270 | - if($default_mask != null) { |
|
270 | + if ($default_mask != null) { |
|
271 | 271 | $instance->setMask($default_mask); |
272 | 272 | } |
273 | 273 | $instance->setEvents([ |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | * @throws MethodNotFoundException |
303 | 303 | */ |
304 | 304 | public function __call($method, $arguments) { |
305 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
305 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
306 | 306 | $name = Str::snake(substr($method, 3)); |
307 | 307 | return $this->get($name); |
308 | 308 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
309 | 309 | $name = Str::snake(substr($method, 3)); |
310 | 310 | |
311 | - if(in_array($name, array_keys($this->attributes))) { |
|
311 | + if (in_array($name, array_keys($this->attributes))) { |
|
312 | 312 | return $this->__set($name, array_pop($arguments)); |
313 | 313 | } |
314 | 314 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @return mixed|null |
348 | 348 | */ |
349 | 349 | public function get($name) { |
350 | - if(isset($this->attributes[$name])) { |
|
350 | + if (isset($this->attributes[$name])) { |
|
351 | 351 | return $this->attributes[$name]; |
352 | 352 | } |
353 | 353 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @throws InvalidMessageDateException |
423 | 423 | */ |
424 | - public function parseRawHeader($raw_header){ |
|
424 | + public function parseRawHeader($raw_header) { |
|
425 | 425 | $this->header = new Header($raw_header); |
426 | 426 | } |
427 | 427 | |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | public function parseRawFlags($raw_flags) { |
433 | 433 | $this->flags = FlagCollection::make([]); |
434 | 434 | |
435 | - foreach($raw_flags as $flag) { |
|
436 | - if (strpos($flag, "\\") === 0){ |
|
435 | + foreach ($raw_flags as $flag) { |
|
436 | + if (strpos($flag, "\\") === 0) { |
|
437 | 437 | $flag = substr($flag, 1); |
438 | 438 | } |
439 | 439 | $flag_key = strtolower($flag); |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | * @throws MessageFlagException |
507 | 507 | * @throws Exceptions\RuntimeException |
508 | 508 | */ |
509 | - public function peek(){ |
|
509 | + public function peek() { |
|
510 | 510 | if ($this->fetch_options == IMAP::FT_PEEK) { |
511 | 511 | if ($this->getFlags()->get("seen") == null) { |
512 | 512 | $this->unsetFlag("Seen"); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | private function fetchPart(Part $part) { |
556 | 556 | if ($part->isAttachment()) { |
557 | 557 | $this->fetchAttachment($part); |
558 | - }else{ |
|
558 | + }else { |
|
559 | 559 | $encoding = $this->getEncoding($part); |
560 | 560 | |
561 | 561 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | |
581 | 581 | if (isset($this->bodies[$subtype])) { |
582 | 582 | $this->bodies[$subtype] .= "\n".$content; |
583 | - }else{ |
|
583 | + }else { |
|
584 | 584 | $this->bodies[$subtype] = $content; |
585 | 585 | } |
586 | 586 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | if ($oAttachment->getName() !== null && $oAttachment->getSize() > 0) { |
597 | 597 | if ($oAttachment->getId() !== null) { |
598 | 598 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
599 | - } else { |
|
599 | + }else { |
|
600 | 600 | $this->attachments->push($oAttachment); |
601 | 601 | } |
602 | 602 | } |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
732 | 732 | return @iconv($from, $to.'//IGNORE', $str); |
733 | - } else { |
|
733 | + }else { |
|
734 | 734 | if (!$from) { |
735 | 735 | return mb_convert_encoding($str, $to); |
736 | 736 | } |
@@ -751,9 +751,9 @@ discard block |
||
751 | 751 | return EncodingAliases::get($parameter->value); |
752 | 752 | } |
753 | 753 | } |
754 | - }elseif (property_exists($structure, 'charset')){ |
|
754 | + }elseif (property_exists($structure, 'charset')) { |
|
755 | 755 | return EncodingAliases::get($structure->charset); |
756 | - }elseif (is_string($structure) === true){ |
|
756 | + }elseif (is_string($structure) === true) { |
|
757 | 757 | return mb_detect_encoding($structure); |
758 | 758 | } |
759 | 759 | |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @throws Exceptions\FolderFetchingException |
769 | 769 | * @throws Exceptions\RuntimeException |
770 | 770 | */ |
771 | - public function getFolder(){ |
|
771 | + public function getFolder() { |
|
772 | 772 | return $this->client->getFolder($this->folder_path); |
773 | 773 | } |
774 | 774 | |
@@ -784,13 +784,13 @@ discard block |
||
784 | 784 | * @throws Exceptions\GetMessagesFailedException |
785 | 785 | * @throws Exceptions\RuntimeException |
786 | 786 | */ |
787 | - public function thread($sent_folder = null, &$thread = null, $folder = null){ |
|
787 | + public function thread($sent_folder = null, &$thread = null, $folder = null) { |
|
788 | 788 | $thread = $thread ? $thread : MessageCollection::make([]); |
789 | - $folder = $folder ? $folder : $this->getFolder(); |
|
789 | + $folder = $folder ? $folder : $this->getFolder(); |
|
790 | 790 | $sent_folder = $sent_folder ? $sent_folder : $this->client->getFolder(ClientManager::get("options.common_folders.sent", "INBOX/Sent")); |
791 | 791 | |
792 | 792 | /** @var Message $message */ |
793 | - foreach($thread as $message) { |
|
793 | + foreach ($thread as $message) { |
|
794 | 794 | if ($message->message_id == $this->message_id) { |
795 | 795 | return $thread; |
796 | 796 | } |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | $this->fetchThreadByInReplyTo($thread, $this->message_id, $sent_folder, $folder, $sent_folder); |
802 | 802 | |
803 | 803 | if (is_array($this->in_reply_to)) { |
804 | - foreach($this->in_reply_to as $in_reply_to) { |
|
804 | + foreach ($this->in_reply_to as $in_reply_to) { |
|
805 | 805 | $this->fetchThreadByMessageId($thread, $in_reply_to, $folder, $folder, $sent_folder); |
806 | 806 | $this->fetchThreadByMessageId($thread, $in_reply_to, $sent_folder, $folder, $sent_folder); |
807 | 807 | } |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | * @throws Exceptions\GetMessagesFailedException |
823 | 823 | * @throws Exceptions\RuntimeException |
824 | 824 | */ |
825 | - protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder){ |
|
825 | + protected function fetchThreadByInReplyTo(&$thread, $in_reply_to, $primary_folder, $secondary_folder, $sent_folder) { |
|
826 | 826 | $primary_folder->query()->inReplyTo($in_reply_to) |
827 | 827 | ->setFetchBody($this->getFetchBodyOption()) |
828 | 828 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @throws Exceptions\GetMessagesFailedException |
844 | 844 | * @throws Exceptions\RuntimeException |
845 | 845 | */ |
846 | - protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder){ |
|
846 | + protected function fetchThreadByMessageId(&$thread, $message_id, $primary_folder, $secondary_folder, $sent_folder) { |
|
847 | 847 | $primary_folder->query()->messageId($message_id) |
848 | 848 | ->setFetchBody($this->getFetchBodyOption()) |
849 | 849 | ->leaveUnread()->get()->each(function($message) use(&$thread, $secondary_folder, $sent_folder){ |
@@ -936,14 +936,14 @@ discard block |
||
936 | 936 | * @throws MessageFlagException |
937 | 937 | * @throws MessageHeaderFetchingException |
938 | 938 | */ |
939 | - protected function fetchNewMail($folder, $next_uid, $event, $expunge){ |
|
940 | - if($expunge) $this->client->expunge(); |
|
939 | + protected function fetchNewMail($folder, $next_uid, $event, $expunge) { |
|
940 | + if ($expunge) $this->client->expunge(); |
|
941 | 941 | |
942 | 942 | $this->client->openFolder($folder->path); |
943 | 943 | |
944 | 944 | if ($this->sequence === IMAP::ST_UID) { |
945 | 945 | $sequence_id = $next_uid; |
946 | - }else{ |
|
946 | + }else { |
|
947 | 947 | $sequence_id = $this->client->getConnection()->getMessageNumber($next_uid); |
948 | 948 | } |
949 | 949 | |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | */ |
967 | 967 | public function delete($expunge = true) { |
968 | 968 | $status = $this->setFlag("Deleted"); |
969 | - if($expunge) $this->client->expunge(); |
|
969 | + if ($expunge) $this->client->expunge(); |
|
970 | 970 | |
971 | 971 | $event = $this->getEvent("message", "deleted"); |
972 | 972 | $event::dispatch($this); |
@@ -986,7 +986,7 @@ discard block |
||
986 | 986 | */ |
987 | 987 | public function restore($expunge = true) { |
988 | 988 | $status = $this->unsetFlag("Deleted"); |
989 | - if($expunge) $this->client->expunge(); |
|
989 | + if ($expunge) $this->client->expunge(); |
|
990 | 990 | |
991 | 991 | $event = $this->getEvent("message", "restored"); |
992 | 992 | $event::dispatch($this); |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | * |
1092 | 1092 | * @return AttachmentCollection |
1093 | 1093 | */ |
1094 | - public function attachments(){ |
|
1094 | + public function attachments() { |
|
1095 | 1095 | return $this->getAttachments(); |
1096 | 1096 | } |
1097 | 1097 | |
@@ -1189,7 +1189,7 @@ discard block |
||
1189 | 1189 | * |
1190 | 1190 | * @return FlagCollection |
1191 | 1191 | */ |
1192 | - public function flags(){ |
|
1192 | + public function flags() { |
|
1193 | 1193 | return $this->getFlags(); |
1194 | 1194 | } |
1195 | 1195 | |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | * |
1199 | 1199 | * @return Structure|null |
1200 | 1200 | */ |
1201 | - public function getStructure(){ |
|
1201 | + public function getStructure() { |
|
1202 | 1202 | return $this->structure; |
1203 | 1203 | } |
1204 | 1204 | |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | * |
1225 | 1225 | * @return array |
1226 | 1226 | */ |
1227 | - public function getAttributes(){ |
|
1227 | + public function getAttributes() { |
|
1228 | 1228 | return array_merge($this->attributes, $this->header->getAttributes()); |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1234,8 +1234,8 @@ discard block |
||
1234 | 1234 | * |
1235 | 1235 | * @return $this |
1236 | 1236 | */ |
1237 | - public function setMask($mask){ |
|
1238 | - if(class_exists($mask)){ |
|
1237 | + public function setMask($mask) { |
|
1238 | + if (class_exists($mask)) { |
|
1239 | 1239 | $this->mask = $mask; |
1240 | 1240 | } |
1241 | 1241 | |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | * |
1248 | 1248 | * @return string |
1249 | 1249 | */ |
1250 | - public function getMask(){ |
|
1250 | + public function getMask() { |
|
1251 | 1251 | return $this->mask; |
1252 | 1252 | } |
1253 | 1253 | |
@@ -1258,9 +1258,9 @@ discard block |
||
1258 | 1258 | * @return mixed |
1259 | 1259 | * @throws MaskNotFoundException |
1260 | 1260 | */ |
1261 | - public function mask($mask = null){ |
|
1261 | + public function mask($mask = null) { |
|
1262 | 1262 | $mask = $mask !== null ? $mask : $this->mask; |
1263 | - if(class_exists($mask)){ |
|
1263 | + if (class_exists($mask)) { |
|
1264 | 1264 | return new $mask($this); |
1265 | 1265 | } |
1266 | 1266 | |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | * |
1274 | 1274 | * @return $this |
1275 | 1275 | */ |
1276 | - public function setFolderPath($folder_path){ |
|
1276 | + public function setFolderPath($folder_path) { |
|
1277 | 1277 | $this->folder_path = $folder_path; |
1278 | 1278 | |
1279 | 1279 | return $this; |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | * |
1286 | 1286 | * @return $this |
1287 | 1287 | */ |
1288 | - public function setConfig($config){ |
|
1288 | + public function setConfig($config) { |
|
1289 | 1289 | $this->config = $config; |
1290 | 1290 | |
1291 | 1291 | return $this; |
@@ -1297,7 +1297,7 @@ discard block |
||
1297 | 1297 | * |
1298 | 1298 | * @return $this |
1299 | 1299 | */ |
1300 | - public function setAvailableFlags($available_flags){ |
|
1300 | + public function setAvailableFlags($available_flags) { |
|
1301 | 1301 | $this->available_flags = $available_flags; |
1302 | 1302 | |
1303 | 1303 | return $this; |
@@ -1309,7 +1309,7 @@ discard block |
||
1309 | 1309 | * |
1310 | 1310 | * @return $this |
1311 | 1311 | */ |
1312 | - public function setAttachments($attachments){ |
|
1312 | + public function setAttachments($attachments) { |
|
1313 | 1313 | $this->attachments = $attachments; |
1314 | 1314 | |
1315 | 1315 | return $this; |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | * |
1322 | 1322 | * @return $this |
1323 | 1323 | */ |
1324 | - public function setFlags($flags){ |
|
1324 | + public function setFlags($flags) { |
|
1325 | 1325 | $this->flags = $flags; |
1326 | 1326 | |
1327 | 1327 | return $this; |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | * @throws Exceptions\RuntimeException |
1336 | 1336 | * @throws Exceptions\ConnectionFailedException |
1337 | 1337 | */ |
1338 | - public function setClient($client){ |
|
1338 | + public function setClient($client) { |
|
1339 | 1339 | $this->client = $client; |
1340 | 1340 | $this->client->openFolder($this->folder_path); |
1341 | 1341 | |
@@ -1350,7 +1350,7 @@ discard block |
||
1350 | 1350 | * @throws Exceptions\RuntimeException |
1351 | 1351 | * @return $this |
1352 | 1352 | */ |
1353 | - public function setUid($uid){ |
|
1353 | + public function setUid($uid) { |
|
1354 | 1354 | $this->uid = $uid; |
1355 | 1355 | $this->msgn = $this->client->getConnection()->getMessageNumber($this->uid); |
1356 | 1356 | $this->msglist = null; |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | * @throws Exceptions\RuntimeException |
1368 | 1368 | * @return $this |
1369 | 1369 | */ |
1370 | - public function setMsgn($msgn, $msglist = null){ |
|
1370 | + public function setMsgn($msgn, $msglist = null) { |
|
1371 | 1371 | $this->msgn = $msgn; |
1372 | 1372 | $this->msglist = $msglist; |
1373 | 1373 | $this->uid = $this->client->getConnection()->getUid($this->msgn); |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | * |
1381 | 1381 | * @return int |
1382 | 1382 | */ |
1383 | - public function getSequence(){ |
|
1383 | + public function getSequence() { |
|
1384 | 1384 | return $this->sequence; |
1385 | 1385 | } |
1386 | 1386 | |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | * |
1390 | 1390 | * @return int |
1391 | 1391 | */ |
1392 | - public function getSequenceId(){ |
|
1392 | + public function getSequenceId() { |
|
1393 | 1393 | return $this->sequence === IMAP::ST_UID ? $this->uid : $this->msgn; |
1394 | 1394 | } |
1395 | 1395 | |
@@ -1401,11 +1401,11 @@ discard block |
||
1401 | 1401 | * @throws Exceptions\ConnectionFailedException |
1402 | 1402 | * @throws Exceptions\RuntimeException |
1403 | 1403 | */ |
1404 | - public function setSequenceId($uid, $msglist = null){ |
|
1404 | + public function setSequenceId($uid, $msglist = null) { |
|
1405 | 1405 | if ($this->getSequence() === IMAP::ST_UID) { |
1406 | 1406 | $this->setUid($uid); |
1407 | 1407 | $this->setMsglist($msglist); |
1408 | - }else{ |
|
1408 | + }else { |
|
1409 | 1409 | $this->setMsgn($uid, $msglist); |
1410 | 1410 | } |
1411 | 1411 | } |