@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @throws ConnectionFailedException |
90 | 90 | * @throws RuntimeException |
91 | 91 | */ |
92 | - protected function enableStartTls(){ |
|
92 | + protected function enableStartTls() { |
|
93 | 93 | $response = $this->requestAndResponse('STARTTLS'); |
94 | 94 | $result = $response && stream_socket_enable_crypto($this->stream, true, $this->getCryptoMethod()); |
95 | 95 | if (!$result) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | throw new RuntimeException('empty response'); |
113 | 113 | } |
114 | 114 | if ($this->debug) echo "<< ".$line."\n"; |
115 | - return $line . "\n"; |
|
115 | + return $line."\n"; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $stack = []; |
166 | 166 | |
167 | 167 | // replace any trailing <NL> including spaces with a single space |
168 | - $line = rtrim($line) . ' '; |
|
168 | + $line = rtrim($line).' '; |
|
169 | 169 | while (($pos = strpos($line, ' ')) !== false) { |
170 | 170 | $token = substr($line, 0, $pos); |
171 | 171 | if (!strlen($token)) { |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | if (strlen($token) > $chars) { |
196 | 196 | $line = substr($token, $chars); |
197 | 197 | $token = substr($token, 0, $chars); |
198 | - } else { |
|
198 | + }else { |
|
199 | 199 | $line .= $this->nextLine(); |
200 | 200 | } |
201 | 201 | $tokens[] = $token; |
202 | - $line = trim($line) . ' '; |
|
202 | + $line = trim($line).' '; |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $line = $this->nextTaggedLine($tag); // get next tag |
250 | 250 | if (!$dontParse) { |
251 | 251 | $tokens = $this->decodeLine($line); |
252 | - } else { |
|
252 | + }else { |
|
253 | 253 | $tokens = $line; |
254 | 254 | } |
255 | 255 | |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | public function sendRequest(string $command, array $tokens = [], string &$tag = null) { |
300 | 300 | if (!$tag) { |
301 | 301 | $this->noun++; |
302 | - $tag = 'TAG' . $this->noun; |
|
302 | + $tag = 'TAG'.$this->noun; |
|
303 | 303 | } |
304 | 304 | |
305 | - $line = $tag . ' ' . $command; |
|
305 | + $line = $tag.' '.$command; |
|
306 | 306 | |
307 | 307 | foreach ($tokens as $token) { |
308 | 308 | if (is_array($token)) { |
309 | - $this->write($line . ' ' . $token[0]); |
|
309 | + $this->write($line.' '.$token[0]); |
|
310 | 310 | if (!$this->assumedNextLine('+ ')) { |
311 | 311 | throw new RuntimeException('failed to send literal string'); |
312 | 312 | } |
313 | 313 | $line = $token[1]; |
314 | - } else { |
|
315 | - $line .= ' ' . $token; |
|
314 | + }else { |
|
315 | + $line .= ' '.$token; |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | $this->write($line); |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | * @throws RuntimeException |
326 | 326 | */ |
327 | 327 | public function write(string $data) { |
328 | - if ($this->debug) echo ">> ".$data ."\n"; |
|
328 | + if ($this->debug) echo ">> ".$data."\n"; |
|
329 | 329 | |
330 | - if (fwrite($this->stream, $data . "\r\n") === false) { |
|
330 | + if (fwrite($this->stream, $data."\r\n") === false) { |
|
331 | 331 | throw new RuntimeException('failed to write - connection closed?'); |
332 | 332 | } |
333 | 333 | } |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | public function escapeString($string) { |
358 | 358 | if (func_num_args() < 2) { |
359 | 359 | if (strpos($string, "\n") !== false) { |
360 | - return ['{' . strlen($string) . '}', $string]; |
|
361 | - } else { |
|
362 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
360 | + return ['{'.strlen($string).'}', $string]; |
|
361 | + }else { |
|
362 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
363 | 363 | } |
364 | 364 | } |
365 | 365 | $result = []; |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | } |
385 | 385 | $result[] = $this->escapeList($v); |
386 | 386 | } |
387 | - return '(' . implode(' ', $result) . ')'; |
|
387 | + return '('.implode(' ', $result).')'; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | error_log("got an extra server challenge: $response"); |
426 | 426 | // respond with an empty response. |
427 | 427 | $this->sendRequest(''); |
428 | - } else { |
|
428 | + }else { |
|
429 | 429 | if (preg_match('/^NO /i', $response) || |
430 | 430 | preg_match('/^BAD /i', $response)) { |
431 | 431 | error_log("got failure response: $response"); |
432 | 432 | return false; |
433 | - } else if (preg_match("/^OK /i", $response)) { |
|
433 | + }else if (preg_match("/^OK /i", $response)) { |
|
434 | 434 | return true; |
435 | 435 | } |
436 | 436 | } |
@@ -508,16 +508,16 @@ discard block |
||
508 | 508 | switch ($tokens[1]) { |
509 | 509 | case 'EXISTS': |
510 | 510 | case 'RECENT': |
511 | - $result[strtolower($tokens[1])] = (int)$tokens[0]; |
|
511 | + $result[strtolower($tokens[1])] = (int) $tokens[0]; |
|
512 | 512 | break; |
513 | 513 | case '[UIDVALIDITY': |
514 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
514 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
515 | 515 | break; |
516 | 516 | case '[UIDNEXT': |
517 | - $result['uidnext'] = (int)$tokens[2]; |
|
517 | + $result['uidnext'] = (int) $tokens[2]; |
|
518 | 518 | break; |
519 | 519 | case '[UNSEEN': |
520 | - $result['unseen'] = (int)$tokens[2]; |
|
520 | + $result['unseen'] = (int) $tokens[2]; |
|
521 | 521 | break; |
522 | 522 | case '[NONEXISTENT]': |
523 | 523 | throw new RuntimeException("folder doesn't exist"); |
@@ -576,14 +576,14 @@ discard block |
||
576 | 576 | if (is_array($from)) { |
577 | 577 | $set = implode(',', $from); |
578 | 578 | } elseif ($to === null) { |
579 | - $set = (int)$from; |
|
579 | + $set = (int) $from; |
|
580 | 580 | } elseif ($to === INF) { |
581 | - $set = (int)$from . ':*'; |
|
582 | - } else { |
|
583 | - $set = (int)$from . ':' . (int)$to; |
|
581 | + $set = (int) $from.':*'; |
|
582 | + }else { |
|
583 | + $set = (int) $from.':'.(int) $to; |
|
584 | 584 | } |
585 | 585 | |
586 | - $items = (array)$items; |
|
586 | + $items = (array) $items; |
|
587 | 587 | $itemList = $this->escapeList($items); |
588 | 588 | |
589 | 589 | $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag); |
@@ -600,9 +600,9 @@ discard block |
||
600 | 600 | $count = count($tokens[2]); |
601 | 601 | if ($tokens[2][$count - 2] == 'UID') { |
602 | 602 | $uidKey = $count - 1; |
603 | - } else if ($tokens[2][0] == 'UID') { |
|
603 | + }else if ($tokens[2][0] == 'UID') { |
|
604 | 604 | $uidKey = 1; |
605 | - } else { |
|
605 | + }else { |
|
606 | 606 | $found = array_search('UID', $tokens[2]); |
607 | 607 | if ($found === false || $found === -1) { |
608 | 608 | continue; |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | $data = $tokens[2][1]; |
625 | 625 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
626 | 626 | $data = $tokens[2][3]; |
627 | - } else { |
|
627 | + }else { |
|
628 | 628 | // maybe the server send an other field we didn't wanted |
629 | 629 | $count = count($tokens[2]); |
630 | 630 | // we start with 2, because 0 was already checked |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | break; |
637 | 637 | } |
638 | 638 | } |
639 | - } else { |
|
639 | + }else { |
|
640 | 640 | $data = []; |
641 | 641 | while (key($tokens[2]) !== null) { |
642 | 642 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | } |
654 | 654 | if ($uid) { |
655 | 655 | $result[$tokens[2][$uidKey]] = $data; |
656 | - }else{ |
|
656 | + }else { |
|
657 | 657 | $result[$tokens[0]] = $data; |
658 | 658 | } |
659 | 659 | } |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $ids = $this->getUid(); |
755 | 755 | foreach ($ids as $k => $v) { |
756 | 756 | if ($v == $id) { |
757 | - return (int)$k; |
|
757 | + return (int) $k; |
|
758 | 758 | } |
759 | 759 | } |
760 | 760 | |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
812 | 812 | |
813 | 813 | if ($silent) { |
814 | - return (bool)$response; |
|
814 | + return (bool) $response; |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | $result = []; |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | public function copyMessage(string $folder, $from, $to = null, $uid = IMAP::ST_UID): bool { |
865 | 865 | $set = $this->buildSet($from, $to); |
866 | 866 | $command = $this->buildUIDCommand("COPY", $uid); |
867 | - return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
867 | + return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -903,7 +903,7 @@ discard block |
||
903 | 903 | $set = $this->buildSet($from, $to); |
904 | 904 | $command = $this->buildUIDCommand("MOVE", $uid); |
905 | 905 | |
906 | - return (bool)$this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
906 | + return (bool) $this->requestAndResponse($command, [$set, $this->escapeString($folder)], true); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * @throws RuntimeException |
956 | 956 | */ |
957 | 957 | public function createFolder(string $folder): bool { |
958 | - return (bool)$this->requestAndResponse('CREATE', [$this->escapeString($folder)], true); |
|
958 | + return (bool) $this->requestAndResponse('CREATE', [$this->escapeString($folder)], true); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | /** |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | * @throws RuntimeException |
968 | 968 | */ |
969 | 969 | public function renameFolder(string $old, string $new): bool { |
970 | - return (bool)$this->requestAndResponse('RENAME', $this->escapeString($old, $new), true); |
|
970 | + return (bool) $this->requestAndResponse('RENAME', $this->escapeString($old, $new), true); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | /** |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @throws RuntimeException |
979 | 979 | */ |
980 | 980 | public function deleteFolder(string $folder): bool { |
981 | - return (bool)$this->requestAndResponse('DELETE', [$this->escapeString($folder)], true); |
|
981 | + return (bool) $this->requestAndResponse('DELETE', [$this->escapeString($folder)], true); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | * @throws RuntimeException |
990 | 990 | */ |
991 | 991 | public function subscribeFolder(string $folder): bool { |
992 | - return (bool)$this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true); |
|
992 | + return (bool) $this->requestAndResponse('SUBSCRIBE', [$this->escapeString($folder)], true); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | /** |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | * @throws RuntimeException |
1001 | 1001 | */ |
1002 | 1002 | public function unsubscribeFolder(string $folder): bool { |
1003 | - return (bool)$this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true); |
|
1003 | + return (bool) $this->requestAndResponse('UNSUBSCRIBE', [$this->escapeString($folder)], true); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | /** |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | * @throws RuntimeException |
1011 | 1011 | */ |
1012 | 1012 | public function expunge(): bool { |
1013 | - return (bool)$this->requestAndResponse('EXPUNGE'); |
|
1013 | + return (bool) $this->requestAndResponse('EXPUNGE'); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | * @throws RuntimeException |
1021 | 1021 | */ |
1022 | 1022 | public function noop(): bool { |
1023 | - return (bool)$this->requestAndResponse('NOOP'); |
|
1023 | + return (bool) $this->requestAndResponse('NOOP'); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | /** |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | $ids = []; |
1114 | 1114 | foreach ($uids as $msgn => $v) { |
1115 | 1115 | $id = $uid ? $v : $msgn; |
1116 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1116 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1117 | 1117 | $ids[] = $id; |
1118 | 1118 | } |
1119 | 1119 | } |
@@ -1127,14 +1127,14 @@ discard block |
||
1127 | 1127 | /** |
1128 | 1128 | * Enable the debug mode |
1129 | 1129 | */ |
1130 | - public function enableDebug(){ |
|
1130 | + public function enableDebug() { |
|
1131 | 1131 | $this->debug = true; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | /** |
1135 | 1135 | * Disable the debug mode |
1136 | 1136 | */ |
1137 | - public function disableDebug(){ |
|
1137 | + public function disableDebug() { |
|
1138 | 1138 | $this->debug = false; |
1139 | 1139 | } |
1140 | 1140 | |
@@ -1146,9 +1146,9 @@ discard block |
||
1146 | 1146 | * @return int|string |
1147 | 1147 | */ |
1148 | 1148 | public function buildSet($from, $to = null) { |
1149 | - $set = (int)$from; |
|
1149 | + $set = (int) $from; |
|
1150 | 1150 | if ($to !== null) { |
1151 | - $set .= ':' . ($to == INF ? '*' : (int)$to); |
|
1151 | + $set .= ':'.($to == INF ? '*' : (int) $to); |
|
1152 | 1152 | } |
1153 | 1153 | return $set; |
1154 | 1154 | } |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @param array $config |
211 | 211 | * @param array $default_config |
212 | 212 | */ |
213 | - private function setAccountConfig(string $key, array $config, array $default_config){ |
|
213 | + private function setAccountConfig(string $key, array $config, array $default_config) { |
|
214 | 214 | $value = $this->default_account_config[$key]; |
215 | - if(isset($config[$key])) { |
|
215 | + if (isset($config[$key])) { |
|
216 | 216 | $value = $config[$key]; |
217 | - }elseif(isset($default_config[$key])) { |
|
217 | + }elseif (isset($default_config[$key])) { |
|
218 | 218 | $value = $default_config[$key]; |
219 | 219 | } |
220 | 220 | $this->$key = $value; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | protected function setEventsFromConfig($config) { |
228 | 228 | $this->events = ClientManager::get("events"); |
229 | - if(isset($config['events'])){ |
|
230 | - foreach($config['events'] as $section => $events) { |
|
229 | + if (isset($config['events'])) { |
|
230 | + foreach ($config['events'] as $section => $events) { |
|
231 | 231 | $this->events[$section] = array_merge($this->events[$section], $events); |
232 | 232 | } |
233 | 233 | } |
@@ -240,45 +240,45 @@ discard block |
||
240 | 240 | * @throws MaskNotFoundException |
241 | 241 | */ |
242 | 242 | protected function setMaskFromConfig($config) { |
243 | - $default_config = ClientManager::get("masks"); |
|
243 | + $default_config = ClientManager::get("masks"); |
|
244 | 244 | |
245 | - if(isset($config['masks'])){ |
|
246 | - if(isset($config['masks']['message'])) { |
|
247 | - if(class_exists($config['masks']['message'])) { |
|
245 | + if (isset($config['masks'])) { |
|
246 | + if (isset($config['masks']['message'])) { |
|
247 | + if (class_exists($config['masks']['message'])) { |
|
248 | 248 | $this->default_message_mask = $config['masks']['message']; |
249 | - }else{ |
|
249 | + }else { |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
251 | 251 | } |
252 | - }else{ |
|
253 | - if(class_exists($default_config['message'])) { |
|
252 | + }else { |
|
253 | + if (class_exists($default_config['message'])) { |
|
254 | 254 | $this->default_message_mask = $default_config['message']; |
255 | - }else{ |
|
255 | + }else { |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
257 | 257 | } |
258 | 258 | } |
259 | - if(isset($config['masks']['attachment'])) { |
|
260 | - if(class_exists($config['masks']['attachment'])) { |
|
259 | + if (isset($config['masks']['attachment'])) { |
|
260 | + if (class_exists($config['masks']['attachment'])) { |
|
261 | 261 | $this->default_attachment_mask = $config['masks']['attachment']; |
262 | - }else{ |
|
262 | + }else { |
|
263 | 263 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
264 | 264 | } |
265 | - }else{ |
|
266 | - if(class_exists($default_config['attachment'])) { |
|
265 | + }else { |
|
266 | + if (class_exists($default_config['attachment'])) { |
|
267 | 267 | $this->default_attachment_mask = $default_config['attachment']; |
268 | - }else{ |
|
268 | + }else { |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
270 | 270 | } |
271 | 271 | } |
272 | - }else{ |
|
273 | - if(class_exists($default_config['message'])) { |
|
272 | + }else { |
|
273 | + if (class_exists($default_config['message'])) { |
|
274 | 274 | $this->default_message_mask = $default_config['message']; |
275 | - }else{ |
|
275 | + }else { |
|
276 | 276 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
277 | 277 | } |
278 | 278 | |
279 | - if(class_exists($default_config['attachment'])) { |
|
279 | + if (class_exists($default_config['attachment'])) { |
|
280 | 280 | $this->default_attachment_mask = $default_config['attachment']; |
281 | - }else{ |
|
281 | + }else { |
|
282 | 282 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
283 | 283 | } |
284 | 284 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
343 | 343 | $this->connection->setConnectionTimeout($this->timeout); |
344 | 344 | $this->connection->setProxy($this->proxy); |
345 | - }else{ |
|
345 | + }else { |
|
346 | 346 | if (extension_loaded('imap') === false) { |
347 | 347 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
348 | 348 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | |
424 | 424 | // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names) |
425 | 425 | $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter; |
426 | - if (strpos($folder_name, (string)$delimiter) !== false) { |
|
426 | + if (strpos($folder_name, (string) $delimiter) !== false) { |
|
427 | 427 | return $this->getFolderByPath($folder_name); |
428 | 428 | } |
429 | 429 | |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
476 | 476 | $items = $this->connection->folders('', $pattern); |
477 | 477 | |
478 | - if(is_array($items)){ |
|
478 | + if (is_array($items)) { |
|
479 | 479 | foreach ($items as $folder_name => $item) { |
480 | 480 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
481 | 481 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | return $folders; |
493 | - }else{ |
|
493 | + }else { |
|
494 | 494 | throw new FolderFetchingException("failed to fetch any folders"); |
495 | 495 | } |
496 | 496 | } |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
515 | 515 | $items = $this->connection->folders('', $pattern); |
516 | 516 | |
517 | - if(is_array($items)){ |
|
517 | + if (is_array($items)) { |
|
518 | 518 | foreach ($items as $folder_name => $item) { |
519 | 519 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
520 | 520 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | return $folders; |
533 | - }else{ |
|
533 | + }else { |
|
534 | 534 | throw new FolderFetchingException("failed to fetch any folders"); |
535 | 535 | } |
536 | 536 | } |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | $this->checkConnection(); |
569 | 569 | $status = $this->connection->createFolder($folder); |
570 | 570 | |
571 | - if($expunge) $this->expunge(); |
|
571 | + if ($expunge) $this->expunge(); |
|
572 | 572 | |
573 | 573 | $folder = $this->getFolder($folder); |
574 | - if($status && $folder) { |
|
574 | + if ($status && $folder) { |
|
575 | 575 | $event = $this->getEvent("folder", "new"); |
576 | 576 | $event::dispatch($folder); |
577 | 577 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * |
598 | 598 | * @return string |
599 | 599 | */ |
600 | - public function getFolderPath(){ |
|
600 | + public function getFolderPath() { |
|
601 | 601 | return $this->active_folder; |
602 | 602 | } |
603 | 603 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @throws MaskNotFoundException |
710 | 710 | */ |
711 | 711 | public function setDefaultMessageMask(string $mask): Client { |
712 | - if(class_exists($mask)) { |
|
712 | + if (class_exists($mask)) { |
|
713 | 713 | $this->default_message_mask = $mask; |
714 | 714 | |
715 | 715 | return $this; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @throws MaskNotFoundException |
736 | 736 | */ |
737 | 737 | public function setDefaultAttachmentMask(string $mask): Client { |
738 | - if(class_exists($mask)) { |
|
738 | + if (class_exists($mask)) { |
|
739 | 739 | $this->default_attachment_mask = $mask; |
740 | 740 | |
741 | 741 | return $this; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $value = $this->default_account_config[$key]; |
215 | 215 | if(isset($config[$key])) { |
216 | 216 | $value = $config[$key]; |
217 | - }elseif(isset($default_config[$key])) { |
|
217 | + } elseif(isset($default_config[$key])) { |
|
218 | 218 | $value = $default_config[$key]; |
219 | 219 | } |
220 | 220 | $this->$key = $value; |
@@ -246,39 +246,39 @@ discard block |
||
246 | 246 | if(isset($config['masks']['message'])) { |
247 | 247 | if(class_exists($config['masks']['message'])) { |
248 | 248 | $this->default_message_mask = $config['masks']['message']; |
249 | - }else{ |
|
249 | + } else{ |
|
250 | 250 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
251 | 251 | } |
252 | - }else{ |
|
252 | + } else{ |
|
253 | 253 | if(class_exists($default_config['message'])) { |
254 | 254 | $this->default_message_mask = $default_config['message']; |
255 | - }else{ |
|
255 | + } else{ |
|
256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | if(isset($config['masks']['attachment'])) { |
260 | 260 | if(class_exists($config['masks']['attachment'])) { |
261 | 261 | $this->default_attachment_mask = $config['masks']['attachment']; |
262 | - }else{ |
|
262 | + } else{ |
|
263 | 263 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | if(class_exists($default_config['attachment'])) { |
267 | 267 | $this->default_attachment_mask = $default_config['attachment']; |
268 | - }else{ |
|
268 | + } else{ |
|
269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
270 | 270 | } |
271 | 271 | } |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | if(class_exists($default_config['message'])) { |
274 | 274 | $this->default_message_mask = $default_config['message']; |
275 | - }else{ |
|
275 | + } else{ |
|
276 | 276 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
277 | 277 | } |
278 | 278 | |
279 | 279 | if(class_exists($default_config['attachment'])) { |
280 | 280 | $this->default_attachment_mask = $default_config['attachment']; |
281 | - }else{ |
|
281 | + } else{ |
|
282 | 282 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
283 | 283 | } |
284 | 284 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
343 | 343 | $this->connection->setConnectionTimeout($this->timeout); |
344 | 344 | $this->connection->setProxy($this->proxy); |
345 | - }else{ |
|
345 | + } else{ |
|
346 | 346 | if (extension_loaded('imap') === false) { |
347 | 347 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
348 | 348 | } |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | return $folders; |
493 | - }else{ |
|
493 | + } else{ |
|
494 | 494 | throw new FolderFetchingException("failed to fetch any folders"); |
495 | 495 | } |
496 | 496 | } |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | return $folders; |
533 | - }else{ |
|
533 | + } else{ |
|
534 | 534 | throw new FolderFetchingException("failed to fetch any folders"); |
535 | 535 | } |
536 | 536 | } |
@@ -568,7 +568,9 @@ discard block |
||
568 | 568 | $this->checkConnection(); |
569 | 569 | $status = $this->connection->createFolder($folder); |
570 | 570 | |
571 | - if($expunge) $this->expunge(); |
|
571 | + if($expunge) { |
|
572 | + $this->expunge(); |
|
573 | + } |
|
572 | 574 | |
573 | 575 | $folder = $this->getFolder($folder); |
574 | 576 | if($status && $folder) { |