@@ -256,9 +256,13 @@ discard block |
||
| 256 | 256 | $tokens = [substr($tokens, 0, 2)]; |
| 257 | 257 | } |
| 258 | 258 | if (is_array($lines)){ |
| 259 | - if ($this->debug) echo "<< ".json_encode($lines)."\n"; |
|
| 260 | - }else{ |
|
| 261 | - if ($this->debug) echo "<< ".$lines."\n"; |
|
| 259 | + if ($this->debug) { |
|
| 260 | + echo "<< ".json_encode($lines)."\n"; |
|
| 261 | + } |
|
| 262 | + } else{ |
|
| 263 | + if ($this->debug) { |
|
| 264 | + echo "<< ".$lines."\n"; |
|
| 265 | + } |
|
| 262 | 266 | } |
| 263 | 267 | |
| 264 | 268 | // last line has response code |
@@ -300,7 +304,9 @@ discard block |
||
| 300 | 304 | $line .= ' ' . $token; |
| 301 | 305 | } |
| 302 | 306 | } |
| 303 | - if ($this->debug) echo ">> ".$line."\n"; |
|
| 307 | + if ($this->debug) { |
|
| 308 | + echo ">> ".$line."\n"; |
|
| 309 | + } |
|
| 304 | 310 | |
| 305 | 311 | if (fwrite($this->stream, $line . "\r\n") === false) { |
| 306 | 312 | throw new RuntimeException('failed to write - connection closed?'); |
@@ -450,7 +456,9 @@ discard block |
||
| 450 | 456 | public function getCapabilities() { |
| 451 | 457 | $response = $this->requestAndResponse('CAPABILITY'); |
| 452 | 458 | |
| 453 | - if (!$response) return []; |
|
| 459 | + if (!$response) { |
|
| 460 | + return []; |
|
| 461 | + } |
|
| 454 | 462 | |
| 455 | 463 | $capabilities = []; |
| 456 | 464 | foreach ($response as $line) { |
@@ -605,9 +613,10 @@ discard block |
||
| 605 | 613 | // if we want only one message we can ignore everything else and just return |
| 606 | 614 | if ($to === null && !is_array($from) && ($uid ? $tokens[2][$uidKey] == $from : $tokens[0] == $from)) { |
| 607 | 615 | // we still need to read all lines |
| 608 | - while (!$this->readLine($tokens, $tag)) |
|
| 609 | - |
|
| 616 | + while (!$this->readLine($tokens, $tag)) { |
|
| 617 | + |
|
| 610 | 618 | return $data; |
| 619 | + } |
|
| 611 | 620 | } |
| 612 | 621 | $result[$tokens[0]] = $data; |
| 613 | 622 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | if ($prev_header !== null) { |
| 189 | 189 | $headers[$prev_header][] = $line; |
| 190 | 190 | } |
| 191 | - }elseif (substr($line, 0, 1) === " ") { |
|
| 191 | + } elseif (substr($line, 0, 1) === " ") { |
|
| 192 | 192 | $line = substr($line, 1); |
| 193 | 193 | $line = trim(rtrim($line)); |
| 194 | 194 | if ($prev_header !== null) { |
@@ -197,11 +197,11 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | if (is_array($headers[$prev_header])) { |
| 199 | 199 | $headers[$prev_header][] = $line; |
| 200 | - }else{ |
|
| 200 | + } else{ |
|
| 201 | 201 | $headers[$prev_header] .= $line; |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | - }else{ |
|
| 204 | + } else{ |
|
| 205 | 205 | if (($pos = strpos($line, ":")) > 0) { |
| 206 | 206 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
| 207 | 207 | $value = trim(rtrim(substr($line, $pos + 1))); |
@@ -212,7 +212,9 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | foreach($headers as $key => $values) { |
| 215 | - if (isset($imap_headers[$key])) continue; |
|
| 215 | + if (isset($imap_headers[$key])) { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 216 | 218 | $value = null; |
| 217 | 219 | switch($key){ |
| 218 | 220 | case 'from': |
@@ -349,9 +351,9 @@ discard block |
||
| 349 | 351 | return EncodingAliases::get($parameter->value, $this->fallback_encoding); |
| 350 | 352 | } |
| 351 | 353 | } |
| 352 | - }elseif (property_exists($structure, 'charset')) { |
|
| 354 | + } elseif (property_exists($structure, 'charset')) { |
|
| 353 | 355 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 354 | - }elseif (is_string($structure) === true){ |
|
| 356 | + } elseif (is_string($structure) === true){ |
|
| 355 | 357 | return mb_detect_encoding($structure); |
| 356 | 358 | } |
| 357 | 359 | |
@@ -382,9 +384,9 @@ discard block |
||
| 382 | 384 | } |
| 383 | 385 | } |
| 384 | 386 | } |
| 385 | - }elseif($decoder === 'iconv') { |
|
| 387 | + } elseif($decoder === 'iconv') { |
|
| 386 | 388 | $value = iconv_mime_decode($value); |
| 387 | - }else{ |
|
| 389 | + } else{ |
|
| 388 | 390 | $value = mb_decode_mimeheader($value); |
| 389 | 391 | } |
| 390 | 392 | |
@@ -404,7 +406,9 @@ discard block |
||
| 404 | 406 | * Try to extract the priority from a given raw header string |
| 405 | 407 | */ |
| 406 | 408 | private function findPriority() { |
| 407 | - if(($priority = $this->get("x-priority")) === null) return; |
|
| 409 | + if(($priority = $this->get("x-priority")) === null) { |
|
| 410 | + return; |
|
| 411 | + } |
|
| 408 | 412 | switch($priority){ |
| 409 | 413 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 410 | 414 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if(strtolower(substr($method, 0, 3)) === 'get') { |
| 245 | 245 | $name = Str::snake(substr($method, 3)); |
| 246 | 246 | return $this->get($name); |
| 247 | - }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 247 | + } elseif (strtolower(substr($method, 0, 3)) === 'set') { |
|
| 248 | 248 | $name = Str::snake(substr($method, 3)); |
| 249 | 249 | |
| 250 | 250 | if(in_array($name, array_keys($this->attributes))) { |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | if ($part->isAttachment()) { |
| 442 | 442 | $this->fetchAttachment($part); |
| 443 | - }else{ |
|
| 443 | + } else{ |
|
| 444 | 444 | $encoding = $this->getEncoding($part); |
| 445 | 445 | |
| 446 | 446 | $content = $this->decodeString($part->content, $part->encoding); |
@@ -616,9 +616,9 @@ discard block |
||
| 616 | 616 | return EncodingAliases::get($parameter->value); |
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | - }elseif (property_exists($structure, 'charset')){ |
|
| 619 | + } elseif (property_exists($structure, 'charset')){ |
|
| 620 | 620 | return EncodingAliases::get($structure->charset); |
| 621 | - }elseif (is_string($structure) === true){ |
|
| 621 | + } elseif (is_string($structure) === true){ |
|
| 622 | 622 | return mb_detect_encoding($structure); |
| 623 | 623 | } |
| 624 | 624 | |
@@ -719,7 +719,9 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | $this->client->openFolder($this->folder_path); |
| 721 | 721 | if ($this->client->getConnection()->copyMessage($folder->path, $this->msgn) == true) { |
| 722 | - if($expunge) $this->client->expunge(); |
|
| 722 | + if($expunge) { |
|
| 723 | + $this->client->expunge(); |
|
| 724 | + } |
|
| 723 | 725 | |
| 724 | 726 | $this->client->openFolder($folder->path); |
| 725 | 727 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -761,7 +763,9 @@ discard block |
||
| 761 | 763 | |
| 762 | 764 | $this->client->openFolder($this->folder_path); |
| 763 | 765 | if ($this->client->getConnection()->moveMessage($folder->path, $this->msgn) == true) { |
| 764 | - if($expunge) $this->client->expunge(); |
|
| 766 | + if($expunge) { |
|
| 767 | + $this->client->expunge(); |
|
| 768 | + } |
|
| 765 | 769 | |
| 766 | 770 | $this->client->openFolder($folder->path); |
| 767 | 771 | $message_num = $this->client->getConnection()->getMessageNumber($next_uid); |
@@ -788,7 +792,9 @@ discard block |
||
| 788 | 792 | */ |
| 789 | 793 | public function delete($expunge = true) { |
| 790 | 794 | $status = $this->setFlag("Deleted"); |
| 791 | - if($expunge) $this->client->expunge(); |
|
| 795 | + if($expunge) { |
|
| 796 | + $this->client->expunge(); |
|
| 797 | + } |
|
| 792 | 798 | |
| 793 | 799 | $event = $this->getEvent("message", "deleted"); |
| 794 | 800 | $event::dispatch($this); |
@@ -807,7 +813,9 @@ discard block |
||
| 807 | 813 | */ |
| 808 | 814 | public function restore($expunge = true) { |
| 809 | 815 | $status = $this->unsetFlag("Deleted"); |
| 810 | - if($expunge) $this->client->expunge(); |
|
| 816 | + if($expunge) { |
|
| 817 | + $this->client->expunge(); |
|
| 818 | + } |
|
| 811 | 819 | |
| 812 | 820 | $event = $this->getEvent("message", "restored"); |
| 813 | 821 | $event::dispatch($this); |
@@ -76,7 +76,9 @@ discard block |
||
| 76 | 76 | public function __construct(Client $client, $charset = 'UTF-8') { |
| 77 | 77 | $this->setClient($client); |
| 78 | 78 | |
| 79 | - if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) $this->leaveUnread(); |
|
| 79 | + if(ClientManager::get('options.fetch') === IMAP::FT_PEEK) { |
|
| 80 | + $this->leaveUnread(); |
|
| 81 | + } |
|
| 80 | 82 | |
| 81 | 83 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 82 | 84 | $this->fetch_order = 'desc'; |
@@ -120,7 +122,9 @@ discard block |
||
| 120 | 122 | * @throws MessageSearchValidationException |
| 121 | 123 | */ |
| 122 | 124 | protected function parse_date($date) { |
| 123 | - if($date instanceof \Carbon\Carbon) return $date; |
|
| 125 | + if($date instanceof \Carbon\Carbon) { |
|
| 126 | + return $date; |
|
| 127 | + } |
|
| 124 | 128 | |
| 125 | 129 | try { |
| 126 | 130 | $date = Carbon::parse($date); |
@@ -287,7 +291,7 @@ discard block |
||
| 287 | 291 | } else { |
| 288 | 292 | if($statement[1] === null){ |
| 289 | 293 | $query .= $statement[0]; |
| 290 | - }else{ |
|
| 294 | + } else{ |
|
| 291 | 295 | $query .= $statement[0].' "'.$statement[1].'"'; |
| 292 | 296 | } |
| 293 | 297 | } |
@@ -317,7 +321,9 @@ discard block |
||
| 317 | 321 | * @return $this |
| 318 | 322 | */ |
| 319 | 323 | public function limit($limit, $page = 1) { |
| 320 | - if($page >= 1) $this->page = $page; |
|
| 324 | + if($page >= 1) { |
|
| 325 | + $this->page = $page; |
|
| 326 | + } |
|
| 321 | 327 | $this->limit = $limit; |
| 322 | 328 | |
| 323 | 329 | return $this; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | $name = $this->decodeFolderName($item->name); |
| 305 | 305 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 306 | 306 | } |
| 307 | - }else{ |
|
| 307 | + } else{ |
|
| 308 | 308 | throw new RuntimeException(\imap_last_error()); |
| 309 | 309 | } |
| 310 | 310 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | if ($mode == "+"){ |
| 329 | 329 | $status = \imap_setflag_full($this->stream, $from, $flag, IMAP::NIL); |
| 330 | - }else{ |
|
| 330 | + } else{ |
|
| 331 | 331 | $status = \imap_clearflag_full($this->stream, $from, $flag, IMAP::NIL); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -232,7 +232,9 @@ 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) { |
|
| 236 | + $this->client->expunge(); |
|
| 237 | + } |
|
| 236 | 238 | |
| 237 | 239 | $folder = $this->client->getFolder($new_name); |
| 238 | 240 | $event = $this->getEvent("folder", "moved"); |
@@ -306,7 +308,9 @@ discard block |
||
| 306 | 308 | */ |
| 307 | 309 | public function delete($expunge = true) { |
| 308 | 310 | $status = $this->client->getConnection()->deleteFolder($this->path); |
| 309 | - if($expunge) $this->client->expunge(); |
|
| 311 | + if($expunge) { |
|
| 312 | + $this->client->expunge(); |
|
| 313 | + } |
|
| 310 | 314 | |
| 311 | 315 | $event = $this->getEvent("folder", "deleted"); |
| 312 | 316 | $event::dispatch($this); |
@@ -374,7 +378,7 @@ discard block |
||
| 374 | 378 | |
| 375 | 379 | $connection->idle(); |
| 376 | 380 | } |
| 377 | - }catch (Exceptions\RuntimeException $e) { |
|
| 381 | + } catch (Exceptions\RuntimeException $e) { |
|
| 378 | 382 | if(strpos($e->getMessage(), "connection closed") === false) { |
| 379 | 383 | throw $e; |
| 380 | 384 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $value = $this->default_account_config[$key]; |
| 199 | 199 | if(isset($config[$key])) { |
| 200 | 200 | $value = $config[$key]; |
| 201 | - }elseif(isset($default_config[$key])) { |
|
| 201 | + } elseif(isset($default_config[$key])) { |
|
| 202 | 202 | $value = $default_config[$key]; |
| 203 | 203 | } |
| 204 | 204 | $this->$key = $value; |
@@ -232,39 +232,39 @@ discard block |
||
| 232 | 232 | if(isset($config['masks']['message'])) { |
| 233 | 233 | if(class_exists($config['masks']['message'])) { |
| 234 | 234 | $this->default_message_mask = $config['masks']['message']; |
| 235 | - }else{ |
|
| 235 | + } else{ |
|
| 236 | 236 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 237 | 237 | } |
| 238 | - }else{ |
|
| 238 | + } else{ |
|
| 239 | 239 | if(class_exists($default_config['message'])) { |
| 240 | 240 | $this->default_message_mask = $default_config['message']; |
| 241 | - }else{ |
|
| 241 | + } else{ |
|
| 242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | if(isset($config['masks']['attachment'])) { |
| 246 | 246 | if(class_exists($config['masks']['attachment'])) { |
| 247 | 247 | $this->default_message_mask = $config['masks']['attachment']; |
| 248 | - }else{ |
|
| 248 | + } else{ |
|
| 249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 250 | 250 | } |
| 251 | - }else{ |
|
| 251 | + } else{ |
|
| 252 | 252 | if(class_exists($default_config['attachment'])) { |
| 253 | 253 | $this->default_message_mask = $default_config['attachment']; |
| 254 | - }else{ |
|
| 254 | + } else{ |
|
| 255 | 255 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | - }else{ |
|
| 258 | + } else{ |
|
| 259 | 259 | if(class_exists($default_config['message'])) { |
| 260 | 260 | $this->default_message_mask = $default_config['message']; |
| 261 | - }else{ |
|
| 261 | + } else{ |
|
| 262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if(class_exists($default_config['attachment'])) { |
| 266 | 266 | $this->default_message_mask = $default_config['attachment']; |
| 267 | - }else{ |
|
| 267 | + } else{ |
|
| 268 | 268 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 269 | 269 | } |
| 270 | 270 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
| 330 | 330 | $this->connection->setConnectionTimeout($timeout); |
| 331 | 331 | $this->connection->setProxy($this->proxy); |
| 332 | - }else{ |
|
| 332 | + } else{ |
|
| 333 | 333 | if (extension_loaded('imap') === false) { |
| 334 | 334 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 335 | 335 | } |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | return $folders; |
| 460 | - }else{ |
|
| 460 | + } else{ |
|
| 461 | 461 | throw new FolderFetchingException("failed to fetch any folders"); |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -493,7 +493,9 @@ discard block |
||
| 493 | 493 | $this->checkConnection(); |
| 494 | 494 | $status = $this->connection->createFolder($folder); |
| 495 | 495 | |
| 496 | - if($expunge) $this->expunge(); |
|
| 496 | + if($expunge) { |
|
| 497 | + $this->expunge(); |
|
| 498 | + } |
|
| 497 | 499 | |
| 498 | 500 | $folder = $this->getFolder($folder); |
| 499 | 501 | if($status && $folder) { |