@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @throws InvalidMessageDateException |
| 161 | 161 | */ |
| 162 | - protected function parse(){ |
|
| 162 | + protected function parse() { |
|
| 163 | 163 | if ($this->header === null) { |
| 164 | 164 | $body = $this->findHeaders(); |
| 165 | - }else{ |
|
| 165 | + }else { |
|
| 166 | 166 | $body = $this->raw; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | $this->name = $this->header->get("name"); |
| 175 | 175 | $this->filename = $this->header->get("filename"); |
| 176 | 176 | |
| 177 | - if(!empty($this->header->get("id"))) { |
|
| 177 | + if (!empty($this->header->get("id"))) { |
|
| 178 | 178 | $this->id = $this->header->get("id"); |
| 179 | - } else if(!empty($this->header->get("x_attachment_id"))){ |
|
| 179 | + }else if (!empty($this->header->get("x_attachment_id"))) { |
|
| 180 | 180 | $this->id = $this->header->get("x_attachment_id"); |
| 181 | - } else if(!empty($this->header->get("content_id"))){ |
|
| 181 | + }else if (!empty($this->header->get("content_id"))) { |
|
| 182 | 182 | $this->id = strtr($this->header->get("content_id"), [ |
| 183 | 183 | '<' => '', |
| 184 | 184 | '>' => '' |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $content_types = $this->header->get("content_type"); |
| 189 | - if(!empty($content_types)){ |
|
| 189 | + if (!empty($content_types)) { |
|
| 190 | 190 | $this->subtype = $this->parseSubtype($content_types); |
| 191 | 191 | $content_type = $content_types; |
| 192 | 192 | if (is_array($content_types)) { |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * @return string |
| 208 | 208 | * @throws InvalidMessageDateException |
| 209 | 209 | */ |
| 210 | - private function findHeaders(){ |
|
| 210 | + private function findHeaders() { |
|
| 211 | 211 | $body = $this->raw; |
| 212 | 212 | while (($pos = strpos($body, "\r\n")) > 0) { |
| 213 | 213 | $body = substr($body, $pos + 2); |
@@ -226,16 +226,16 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @return string |
| 228 | 228 | */ |
| 229 | - private function parseSubtype($content_type){ |
|
| 229 | + private function parseSubtype($content_type) { |
|
| 230 | 230 | if (is_array($content_type)) { |
| 231 | - foreach ($content_type as $part){ |
|
| 232 | - if ((strpos($part, "/")) !== false){ |
|
| 231 | + foreach ($content_type as $part) { |
|
| 232 | + if ((strpos($part, "/")) !== false) { |
|
| 233 | 233 | return $this->parseSubtype($part); |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | return null; |
| 237 | 237 | } |
| 238 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
| 238 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
| 239 | 239 | return substr($content_type, $pos + 1); |
| 240 | 240 | } |
| 241 | 241 | return null; |
@@ -244,9 +244,9 @@ discard block |
||
| 244 | 244 | /** |
| 245 | 245 | * Try to parse the disposition if any is present |
| 246 | 246 | */ |
| 247 | - private function parseDisposition(){ |
|
| 247 | + private function parseDisposition() { |
|
| 248 | 248 | $content_disposition = $this->header->get("content_disposition"); |
| 249 | - if($content_disposition !== null) { |
|
| 249 | + if ($content_disposition !== null) { |
|
| 250 | 250 | $this->ifdisposition = true; |
| 251 | 251 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
| 252 | 252 | } |
@@ -255,9 +255,9 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * Try to parse the description if any is present |
| 257 | 257 | */ |
| 258 | - private function parseDescription(){ |
|
| 258 | + private function parseDescription() { |
|
| 259 | 259 | $content_description = $this->header->get("content_description"); |
| 260 | - if($content_description !== null) { |
|
| 260 | + if ($content_description !== null) { |
|
| 261 | 261 | $this->ifdescription = true; |
| 262 | 262 | $this->description = $content_description; |
| 263 | 263 | } |
@@ -266,9 +266,9 @@ discard block |
||
| 266 | 266 | /** |
| 267 | 267 | * Try to parse the encoding if any is present |
| 268 | 268 | */ |
| 269 | - private function parseEncoding(){ |
|
| 269 | + private function parseEncoding() { |
|
| 270 | 270 | $encoding = $this->header->get("content_transfer_encoding"); |
| 271 | - if($encoding !== null) { |
|
| 271 | + if ($encoding !== null) { |
|
| 272 | 272 | switch (strtolower($encoding)) { |
| 273 | 273 | case "quoted-printable": |
| 274 | 274 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @return bool |
| 300 | 300 | */ |
| 301 | - public function isAttachment(){ |
|
| 301 | + public function isAttachment() { |
|
| 302 | 302 | $valid_disposition = in_array(strtolower($this->disposition), ClientManager::get('options.dispositions')); |
| 303 | 303 | |
| 304 | 304 | if ($this->type == IMAP::MESSAGE_TYPE_TEXT && ($this->ifdisposition == 0 || (empty($this->disposition))) && !$valid_disposition) { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @throws MessageContentFetchingException |
| 78 | 78 | * @throws InvalidMessageDateException |
| 79 | 79 | */ |
| 80 | - protected function parse(){ |
|
| 80 | + protected function parse() { |
|
| 81 | 81 | $this->findContentType(); |
| 82 | 82 | $this->parts = $this->find_parts(); |
| 83 | 83 | } |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * Determine the message content type |
| 87 | 87 | */ |
| 88 | - public function findContentType(){ |
|
| 88 | + public function findContentType() { |
|
| 89 | 89 | $content_type = $this->header->get("content_type"); |
| 90 | 90 | $content_type = (is_array($content_type)) ? implode(' ', $content_type) : $content_type; |
| 91 | - if(stripos($content_type, 'multipart') === 0) { |
|
| 91 | + if (stripos($content_type, 'multipart') === 0) { |
|
| 92 | 92 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
| 93 | - }else{ |
|
| 93 | + }else { |
|
| 94 | 94 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @return Part[] |
| 104 | 104 | * @throws InvalidMessageDateException |
| 105 | 105 | */ |
| 106 | - private function parsePart($context, $part_number = 0){ |
|
| 106 | + private function parsePart($context, $part_number = 0) { |
|
| 107 | 107 | $body = $context; |
| 108 | 108 | while (($pos = strpos($body, "\r\n")) > 0) { |
| 109 | 109 | $body = substr($body, $pos + 2); |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | * @return array |
| 127 | 127 | * @throws InvalidMessageDateException |
| 128 | 128 | */ |
| 129 | - private function detectParts($boundary, $context, $part_number = 0){ |
|
| 130 | - $base_parts = explode( $boundary, $context); |
|
| 129 | + private function detectParts($boundary, $context, $part_number = 0) { |
|
| 130 | + $base_parts = explode($boundary, $context); |
|
| 131 | 131 | $final_parts = []; |
| 132 | - foreach($base_parts as $ctx) { |
|
| 132 | + foreach ($base_parts as $ctx) { |
|
| 133 | 133 | $ctx = substr($ctx, 2); |
| 134 | 134 | if ($ctx !== "--" && $ctx != "") { |
| 135 | 135 | $parts = $this->parsePart($ctx, $part_number); |
@@ -150,9 +150,9 @@ discard block |
||
| 150 | 150 | * @throws MessageContentFetchingException |
| 151 | 151 | * @throws InvalidMessageDateException |
| 152 | 152 | */ |
| 153 | - public function find_parts(){ |
|
| 154 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 155 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
| 153 | + public function find_parts() { |
|
| 154 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
| 155 | + if (($boundary = $this->header->getBoundary()) === null) { |
|
| 156 | 156 | throw new MessageContentFetchingException("no content found", 0); |
| 157 | 157 | } |
| 158 | 158 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @return string|null |
| 169 | 169 | * @Depricated since version 2.4.4 |
| 170 | 170 | */ |
| 171 | - public function getBoundary(){ |
|
| 171 | + public function getBoundary() { |
|
| 172 | 172 | return $this->header->getBoundary(); |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return null |
| 32 | 32 | */ |
| 33 | - public function getHtmlBody(){ |
|
| 33 | + public function getHtmlBody() { |
|
| 34 | 34 | $bodies = $this->parent->getBodies(); |
| 35 | 35 | if (!isset($bodies['html'])) { |
| 36 | 36 | return null; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if(is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
| 39 | + if (is_object($bodies['html']) && property_exists($bodies['html'], 'content')) { |
|
| 40 | 40 | return $bodies['html']->content; |
| 41 | 41 | } |
| 42 | 42 | return $bodies['html']; |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function getCustomHTMLBody($callback = false) { |
| 52 | 52 | $body = $this->getHtmlBody(); |
| 53 | - if($body === null) return null; |
|
| 53 | + if ($body === null) return null; |
|
| 54 | 54 | |
| 55 | 55 | if ($callback !== false) { |
| 56 | 56 | $aAttachment = $this->parent->getAttachments(); |
| 57 | 57 | $aAttachment->each(function($oAttachment) use(&$body, $callback) { |
| 58 | 58 | /** @var Attachment $oAttachment */ |
| 59 | - if(is_callable($callback)) { |
|
| 59 | + if (is_callable($callback)) { |
|
| 60 | 60 | $body = $callback($body, $oAttachment); |
| 61 | - }elseif(is_string($callback)) { |
|
| 61 | + }elseif (is_string($callback)) { |
|
| 62 | 62 | call_user_func($callback, [$body, $oAttachment]); |
| 63 | 63 | } |
| 64 | 64 | }); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @return string|null |
| 75 | 75 | */ |
| 76 | 76 | public function getHTMLBodyWithEmbeddedBase64Images() { |
| 77 | - return $this->getCustomHTMLBody(function($body, $oAttachment){ |
|
| 77 | + return $this->getCustomHTMLBody(function($body, $oAttachment) { |
|
| 78 | 78 | /** @var Attachment $oAttachment */ |
| 79 | 79 | if ($oAttachment->id) { |
| 80 | 80 | $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body); |
@@ -203,11 +203,11 @@ discard block |
||
| 203 | 203 | * @param array $config |
| 204 | 204 | * @param array $default_config |
| 205 | 205 | */ |
| 206 | - private function setAccountConfig($key, $config, $default_config){ |
|
| 206 | + private function setAccountConfig($key, $config, $default_config) { |
|
| 207 | 207 | $value = $this->default_account_config[$key]; |
| 208 | - if(isset($config[$key])) { |
|
| 208 | + if (isset($config[$key])) { |
|
| 209 | 209 | $value = $config[$key]; |
| 210 | - }elseif(isset($default_config[$key])) { |
|
| 210 | + }elseif (isset($default_config[$key])) { |
|
| 211 | 211 | $value = $default_config[$key]; |
| 212 | 212 | } |
| 213 | 213 | $this->$key = $value; |
@@ -219,8 +219,8 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | protected function setEventsFromConfig($config) { |
| 221 | 221 | $this->events = ClientManager::get("events"); |
| 222 | - if(isset($config['events'])){ |
|
| 223 | - foreach($config['events'] as $section => $events) { |
|
| 222 | + if (isset($config['events'])) { |
|
| 223 | + foreach ($config['events'] as $section => $events) { |
|
| 224 | 224 | $this->events[$section] = array_merge($this->events[$section], $events); |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -233,45 +233,45 @@ discard block |
||
| 233 | 233 | * @throws MaskNotFoundException |
| 234 | 234 | */ |
| 235 | 235 | protected function setMaskFromConfig($config) { |
| 236 | - $default_config = ClientManager::get("masks"); |
|
| 236 | + $default_config = ClientManager::get("masks"); |
|
| 237 | 237 | |
| 238 | - if(isset($config['masks'])){ |
|
| 239 | - if(isset($config['masks']['message'])) { |
|
| 240 | - if(class_exists($config['masks']['message'])) { |
|
| 238 | + if (isset($config['masks'])) { |
|
| 239 | + if (isset($config['masks']['message'])) { |
|
| 240 | + if (class_exists($config['masks']['message'])) { |
|
| 241 | 241 | $this->default_message_mask = $config['masks']['message']; |
| 242 | - }else{ |
|
| 242 | + }else { |
|
| 243 | 243 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
| 244 | 244 | } |
| 245 | - }else{ |
|
| 246 | - if(class_exists($default_config['message'])) { |
|
| 245 | + }else { |
|
| 246 | + if (class_exists($default_config['message'])) { |
|
| 247 | 247 | $this->default_message_mask = $default_config['message']; |
| 248 | - }else{ |
|
| 248 | + }else { |
|
| 249 | 249 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | - if(isset($config['masks']['attachment'])) { |
|
| 253 | - if(class_exists($config['masks']['attachment'])) { |
|
| 252 | + if (isset($config['masks']['attachment'])) { |
|
| 253 | + if (class_exists($config['masks']['attachment'])) { |
|
| 254 | 254 | $this->default_attachment_mask = $config['masks']['attachment']; |
| 255 | - }else{ |
|
| 255 | + }else { |
|
| 256 | 256 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
| 257 | 257 | } |
| 258 | - }else{ |
|
| 259 | - if(class_exists($default_config['attachment'])) { |
|
| 258 | + }else { |
|
| 259 | + if (class_exists($default_config['attachment'])) { |
|
| 260 | 260 | $this->default_attachment_mask = $default_config['attachment']; |
| 261 | - }else{ |
|
| 261 | + }else { |
|
| 262 | 262 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | - }else{ |
|
| 266 | - if(class_exists($default_config['message'])) { |
|
| 265 | + }else { |
|
| 266 | + if (class_exists($default_config['message'])) { |
|
| 267 | 267 | $this->default_message_mask = $default_config['message']; |
| 268 | - }else{ |
|
| 268 | + }else { |
|
| 269 | 269 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if(class_exists($default_config['attachment'])) { |
|
| 272 | + if (class_exists($default_config['attachment'])) { |
|
| 273 | 273 | $this->default_attachment_mask = $default_config['attachment']; |
| 274 | - }else{ |
|
| 274 | + }else { |
|
| 275 | 275 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
| 336 | 336 | $this->connection->setConnectionTimeout($this->timeout); |
| 337 | 337 | $this->connection->setProxy($this->proxy); |
| 338 | - }else{ |
|
| 338 | + }else { |
|
| 339 | 339 | if (extension_loaded('imap') === false) { |
| 340 | 340 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
| 341 | 341 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names) |
| 410 | 410 | $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter; |
| 411 | - if (strpos($folder_name, (string)$delimiter) !== false) { |
|
| 411 | + if (strpos($folder_name, (string) $delimiter) !== false) { |
|
| 412 | 412 | return $this->getFolderByPath($folder_name); |
| 413 | 413 | } |
| 414 | 414 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
| 461 | 461 | $items = $this->connection->folders('', $pattern); |
| 462 | 462 | |
| 463 | - if(is_array($items)){ |
|
| 463 | + if (is_array($items)) { |
|
| 464 | 464 | foreach ($items as $folder_name => $item) { |
| 465 | 465 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
| 466 | 466 | |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | return $folders; |
| 478 | - }else{ |
|
| 478 | + }else { |
|
| 479 | 479 | throw new FolderFetchingException("failed to fetch any folders"); |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | $this->checkConnection(); |
| 514 | 514 | $status = $this->connection->createFolder($folder); |
| 515 | 515 | |
| 516 | - if($expunge) $this->expunge(); |
|
| 516 | + if ($expunge) $this->expunge(); |
|
| 517 | 517 | |
| 518 | 518 | $folder = $this->getFolder($folder); |
| 519 | - if($status && $folder) { |
|
| 519 | + if ($status && $folder) { |
|
| 520 | 520 | $event = $this->getEvent("folder", "new"); |
| 521 | 521 | $event::dispatch($folder); |
| 522 | 522 | } |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | * |
| 543 | 543 | * @return string |
| 544 | 544 | */ |
| 545 | - public function getFolderPath(){ |
|
| 545 | + public function getFolderPath() { |
|
| 546 | 546 | return $this->active_folder; |
| 547 | 547 | } |
| 548 | 548 | |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @return int |
| 601 | 601 | * @throws ConnectionFailedException |
| 602 | 602 | */ |
| 603 | - public function getTimeout(){ |
|
| 603 | + public function getTimeout() { |
|
| 604 | 604 | $this->checkConnection(); |
| 605 | 605 | return $this->connection->getConnectionTimeout(); |
| 606 | 606 | } |
@@ -610,7 +610,7 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @return string |
| 612 | 612 | */ |
| 613 | - public function getDefaultMessageMask(){ |
|
| 613 | + public function getDefaultMessageMask() { |
|
| 614 | 614 | return $this->default_message_mask; |
| 615 | 615 | } |
| 616 | 616 | |
@@ -620,7 +620,7 @@ discard block |
||
| 620 | 620 | * |
| 621 | 621 | * @return array |
| 622 | 622 | */ |
| 623 | - public function getDefaultEvents($section){ |
|
| 623 | + public function getDefaultEvents($section) { |
|
| 624 | 624 | return $this->events[$section]; |
| 625 | 625 | } |
| 626 | 626 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * @throws MaskNotFoundException |
| 633 | 633 | */ |
| 634 | 634 | public function setDefaultMessageMask($mask) { |
| 635 | - if(class_exists($mask)) { |
|
| 635 | + if (class_exists($mask)) { |
|
| 636 | 636 | $this->default_message_mask = $mask; |
| 637 | 637 | |
| 638 | 638 | return $this; |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * |
| 647 | 647 | * @return string |
| 648 | 648 | */ |
| 649 | - public function getDefaultAttachmentMask(){ |
|
| 649 | + public function getDefaultAttachmentMask() { |
|
| 650 | 650 | return $this->default_attachment_mask; |
| 651 | 651 | } |
| 652 | 652 | |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | * @throws MaskNotFoundException |
| 659 | 659 | */ |
| 660 | 660 | public function setDefaultAttachmentMask($mask) { |
| 661 | - if(class_exists($mask)) { |
|
| 661 | + if (class_exists($mask)) { |
|
| 662 | 662 | $this->default_attachment_mask = $mask; |
| 663 | 663 | |
| 664 | 664 | return $this; |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | * @throws MethodNotFoundException |
| 83 | 83 | */ |
| 84 | 84 | public function __call($method, $arguments) { |
| 85 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 85 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 86 | 86 | $name = preg_replace('/(.)(?=[A-Z])/u', '$1_', substr(strtolower($method), 3)); |
| 87 | 87 | |
| 88 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 88 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 89 | 89 | return $this->attributes[$name]; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return Attribute|mixed |
| 112 | 112 | */ |
| 113 | 113 | public function get($name) { |
| 114 | - if(isset($this->attributes[$name])) { |
|
| 114 | + if (isset($this->attributes[$name])) { |
|
| 115 | 115 | return $this->attributes[$name]; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -127,23 +127,23 @@ discard block |
||
| 127 | 127 | * @return Attribute |
| 128 | 128 | */ |
| 129 | 129 | public function set($name, $value, $strict = false) { |
| 130 | - if(isset($this->attributes[$name]) && $strict === false) { |
|
| 130 | + if (isset($this->attributes[$name]) && $strict === false) { |
|
| 131 | 131 | if ($this->attributize) { |
| 132 | 132 | $this->attributes[$name]->add($value, true); |
| 133 | - }else{ |
|
| 134 | - if(isset($this->attributes[$name])) { |
|
| 133 | + }else { |
|
| 134 | + if (isset($this->attributes[$name])) { |
|
| 135 | 135 | if (is_array($this->attributes[$name]) == false) { |
| 136 | 136 | $this->attributes[$name] = [$this->attributes[$name], $value]; |
| 137 | - }else{ |
|
| 137 | + }else { |
|
| 138 | 138 | $this->attributes[$name][] = $value; |
| 139 | 139 | } |
| 140 | - }else{ |
|
| 140 | + }else { |
|
| 141 | 141 | $this->attributes[$name] = $value; |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | - }elseif($this->attributize == false){ |
|
| 144 | + }elseif ($this->attributize == false) { |
|
| 145 | 145 | $this->attributes[$name] = $value; |
| 146 | - }else{ |
|
| 146 | + }else { |
|
| 147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | public function find($pattern) { |
| 160 | 160 | if (preg_match_all($pattern, $this->raw, $matches)) { |
| 161 | 161 | if (isset($matches[1])) { |
| 162 | - if(count($matches[1]) > 0) { |
|
| 162 | + if (count($matches[1]) > 0) { |
|
| 163 | 163 | return $matches[1][0]; |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string|null |
| 174 | 174 | */ |
| 175 | - public function getBoundary(){ |
|
| 175 | + public function getBoundary() { |
|
| 176 | 176 | $regex = isset($this->config["boundary"]) ? $this->config["boundary"] : "/boundary=(.*?(?=;)|(.*))/i"; |
| 177 | 177 | $boundary = $this->find($regex); |
| 178 | 178 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @throws InvalidMessageDateException |
| 200 | 200 | */ |
| 201 | - protected function parse(){ |
|
| 201 | + protected function parse() { |
|
| 202 | 202 | $header = $this->rfc822_parse_headers($this->raw); |
| 203 | 203 | |
| 204 | 204 | $this->extractAddresses($header); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $this->parseDate($header); |
| 217 | 217 | foreach ($header as $key => $value) { |
| 218 | 218 | $key = trim(rtrim(strtolower($key))); |
| 219 | - if(!isset($this->attributes[$key])){ |
|
| 219 | + if (!isset($this->attributes[$key])) { |
|
| 220 | 220 | $this->set($key, $value); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -232,19 +232,19 @@ discard block |
||
| 232 | 232 | * |
| 233 | 233 | * @return object |
| 234 | 234 | */ |
| 235 | - public function rfc822_parse_headers($raw_headers){ |
|
| 235 | + public function rfc822_parse_headers($raw_headers) { |
|
| 236 | 236 | $headers = []; |
| 237 | 237 | $imap_headers = []; |
| 238 | 238 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
| 239 | 239 | $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
| 240 | - foreach($raw_imap_headers as $key => $values) { |
|
| 240 | + foreach ($raw_imap_headers as $key => $values) { |
|
| 241 | 241 | $key = str_replace("-", "_", $key); |
| 242 | 242 | $imap_headers[$key] = $values; |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | $lines = explode("\r\n", str_replace("\r\n\t", ' ', $raw_headers)); |
| 246 | 246 | $prev_header = null; |
| 247 | - foreach($lines as $line) { |
|
| 247 | + foreach ($lines as $line) { |
|
| 248 | 248 | if (substr($line, 0, 1) === "\n") { |
| 249 | 249 | $line = substr($line, 1); |
| 250 | 250 | } |
@@ -264,19 +264,19 @@ discard block |
||
| 264 | 264 | } |
| 265 | 265 | if (is_array($headers[$prev_header])) { |
| 266 | 266 | $headers[$prev_header][] = $line; |
| 267 | - }else{ |
|
| 267 | + }else { |
|
| 268 | 268 | $headers[$prev_header] .= $line; |
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | - }else{ |
|
| 271 | + }else { |
|
| 272 | 272 | if (($pos = strpos($line, ":")) > 0) { |
| 273 | 273 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
| 274 | 274 | $key = str_replace("-", "_", $key); |
| 275 | 275 | |
| 276 | 276 | $value = trim(rtrim(substr($line, $pos + 1))); |
| 277 | 277 | if (isset($headers[$key])) { |
| 278 | - $headers[$key][] = $value; |
|
| 279 | - }else{ |
|
| 278 | + $headers[$key][] = $value; |
|
| 279 | + }else { |
|
| 280 | 280 | $headers[$key] = [$value]; |
| 281 | 281 | } |
| 282 | 282 | $prev_header = $key; |
@@ -284,10 +284,10 @@ discard block |
||
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - foreach($headers as $key => $values) { |
|
| 287 | + foreach ($headers as $key => $values) { |
|
| 288 | 288 | if (isset($imap_headers[$key])) continue; |
| 289 | 289 | $value = null; |
| 290 | - switch($key){ |
|
| 290 | + switch ($key) { |
|
| 291 | 291 | case 'from': |
| 292 | 292 | case 'to': |
| 293 | 293 | case 'cc': |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | break; |
| 303 | 303 | default: |
| 304 | 304 | if (is_array($values)) { |
| 305 | - foreach($values as $k => $v) { |
|
| 305 | + foreach ($values as $k => $v) { |
|
| 306 | 306 | if ($v == "") { |
| 307 | 307 | unset($values[$k]); |
| 308 | 308 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $value = implode(" ", $values); |
| 315 | 315 | } elseif ($available_values > 2) { |
| 316 | 316 | $value = array_values($values); |
| 317 | - } else { |
|
| 317 | + }else { |
|
| 318 | 318 | $value = ""; |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -334,12 +334,12 @@ discard block |
||
| 334 | 334 | * @return array The decoded elements are returned in an array of objects, where each |
| 335 | 335 | * object has two properties, charset and text. |
| 336 | 336 | */ |
| 337 | - public function mime_header_decode($text){ |
|
| 337 | + public function mime_header_decode($text) { |
|
| 338 | 338 | if (extension_loaded('imap')) { |
| 339 | 339 | return \imap_mime_header_decode($text); |
| 340 | 340 | } |
| 341 | 341 | $charset = $this->getEncoding($text); |
| 342 | - return [(object)[ |
|
| 342 | + return [(object) [ |
|
| 343 | 343 | "charset" => $charset, |
| 344 | 344 | "text" => $this->convertEncoding($text, $charset) |
| 345 | 345 | ]]; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | try { |
| 394 | 394 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 395 | 395 | return iconv($from, $to, $str); |
| 396 | - } else { |
|
| 396 | + }else { |
|
| 397 | 397 | if (!$from) { |
| 398 | 398 | return mb_convert_encoding($str, $to); |
| 399 | 399 | } |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | if (strstr($from, '-')) { |
| 404 | 404 | $from = str_replace('-', '', $from); |
| 405 | 405 | return $this->convertEncoding($str, $from, $to); |
| 406 | - } else { |
|
| 406 | + }else { |
|
| 407 | 407 | return $str; |
| 408 | 408 | } |
| 409 | 409 | } |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | } |
| 425 | 425 | }elseif (property_exists($structure, 'charset')) { |
| 426 | 426 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 427 | - }elseif (is_string($structure) === true){ |
|
| 427 | + }elseif (is_string($structure) === true) { |
|
| 428 | 428 | return mb_detect_encoding($structure); |
| 429 | 429 | } |
| 430 | 430 | |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | if ($value !== null) { |
| 458 | 458 | $is_utf8_base = $this->is_uft8($value); |
| 459 | 459 | |
| 460 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 460 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 461 | 461 | $value = \imap_utf8($value); |
| 462 | 462 | $is_utf8_base = $this->is_uft8($value); |
| 463 | 463 | if ($is_utf8_base) { |
@@ -466,14 +466,14 @@ discard block |
||
| 466 | 466 | if ($this->notDecoded($original_value, $value)) { |
| 467 | 467 | $decoded_value = $this->mime_header_decode($value); |
| 468 | 468 | if (count($decoded_value) > 0) { |
| 469 | - if(property_exists($decoded_value[0], "text")) { |
|
| 469 | + if (property_exists($decoded_value[0], "text")) { |
|
| 470 | 470 | $value = $decoded_value[0]->text; |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
| 474 | + }elseif ($decoder === 'iconv' && $is_utf8_base) { |
|
| 475 | 475 | $value = iconv_mime_decode($value); |
| 476 | - }elseif($is_utf8_base){ |
|
| 476 | + }elseif ($is_utf8_base) { |
|
| 477 | 477 | $value = mb_decode_mimeheader($value); |
| 478 | 478 | } |
| 479 | 479 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | * @return array |
| 497 | 497 | */ |
| 498 | 498 | private function decodeArray($values) { |
| 499 | - foreach($values as $key => $value) { |
|
| 499 | + foreach ($values as $key => $value) { |
|
| 500 | 500 | $values[$key] = $this->decode($value); |
| 501 | 501 | } |
| 502 | 502 | return $values; |
@@ -506,8 +506,8 @@ discard block |
||
| 506 | 506 | * Try to extract the priority from a given raw header string |
| 507 | 507 | */ |
| 508 | 508 | private function findPriority() { |
| 509 | - if(($priority = $this->get("x_priority")) === null) return; |
|
| 510 | - switch((int)"$priority"){ |
|
| 509 | + if (($priority = $this->get("x_priority")) === null) return; |
|
| 510 | + switch ((int) "$priority") { |
|
| 511 | 511 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 512 | 512 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 513 | 513 | break; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | if (isset($parsed_address['address'])) { |
| 547 | 547 | $mail_address = explode('@', $parsed_address['address']); |
| 548 | 548 | if (count($mail_address) == 2) { |
| 549 | - $addresses[] = (object)[ |
|
| 549 | + $addresses[] = (object) [ |
|
| 550 | 550 | "personal" => isset($parsed_address['display']) ? $parsed_address['display'] : '', |
| 551 | 551 | "mailbox" => $mail_address[0], |
| 552 | 552 | "host" => $mail_address[1], |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | return $addresses; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | - foreach($values as $address) { |
|
| 562 | + foreach ($values as $address) { |
|
| 563 | 563 | foreach (preg_split('/, (?=(?:[^"]*"[^"]*")*[^"]*$)/', $address) as $split_address) { |
| 564 | 564 | $split_address = trim(rtrim($split_address)); |
| 565 | 565 | |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | $name = trim(rtrim($matches["name"])); |
| 575 | 575 | $email = trim(rtrim($matches["email"])); |
| 576 | 576 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
| 577 | - $addresses[] = (object)[ |
|
| 577 | + $addresses[] = (object) [ |
|
| 578 | 578 | "personal" => $name, |
| 579 | 579 | "mailbox" => $mailbox, |
| 580 | 580 | "host" => $host, |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @param object $header |
| 592 | 592 | */ |
| 593 | 593 | private function extractAddresses($header) { |
| 594 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
| 594 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
| 595 | 595 | if (property_exists($header, $key)) { |
| 596 | 596 | $this->set($key, $this->parseAddresses($header->$key)); |
| 597 | 597 | } |
@@ -622,10 +622,10 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | if (!property_exists($address, 'personal')) { |
| 624 | 624 | $address->personal = false; |
| 625 | - } else { |
|
| 625 | + }else { |
|
| 626 | 626 | $personalParts = $this->mime_header_decode($address->personal); |
| 627 | 627 | |
| 628 | - if(is_array($personalParts)) { |
|
| 628 | + if (is_array($personalParts)) { |
|
| 629 | 629 | $address->personal = ''; |
| 630 | 630 | foreach ($personalParts as $p) { |
| 631 | 631 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -649,23 +649,23 @@ discard block |
||
| 649 | 649 | /** |
| 650 | 650 | * Search and extract potential header extensions |
| 651 | 651 | */ |
| 652 | - private function extractHeaderExtensions(){ |
|
| 652 | + private function extractHeaderExtensions() { |
|
| 653 | 653 | foreach ($this->attributes as $key => $value) { |
| 654 | 654 | if (is_array($value)) { |
| 655 | 655 | $value = implode(", ", $value); |
| 656 | - }else{ |
|
| 657 | - $value = (string)$value; |
|
| 656 | + }else { |
|
| 657 | + $value = (string) $value; |
|
| 658 | 658 | } |
| 659 | 659 | // Only parse strings and don't parse any attributes like the user-agent |
| 660 | 660 | if (in_array($key, ["user_agent"]) === false) { |
| 661 | - if (($pos = strpos($value, ";")) !== false){ |
|
| 661 | + if (($pos = strpos($value, ";")) !== false) { |
|
| 662 | 662 | $original = substr($value, 0, $pos); |
| 663 | 663 | $this->set($key, trim(rtrim($original)), true); |
| 664 | 664 | |
| 665 | 665 | // Get all potential extensions |
| 666 | 666 | $extensions = explode(";", substr($value, $pos + 1)); |
| 667 | - foreach($extensions as $extension) { |
|
| 668 | - if (($pos = strpos($extension, "=")) !== false){ |
|
| 667 | + foreach ($extensions as $extension) { |
|
| 668 | + if (($pos = strpos($extension, "=")) !== false) { |
|
| 669 | 669 | $key = substr($extension, 0, $pos); |
| 670 | 670 | $key = trim(rtrim(strtolower($key))); |
| 671 | 671 | |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | $parsed_date = null; |
| 709 | 709 | $date = $header->date; |
| 710 | 710 | |
| 711 | - if(preg_match('/\+0580/', $date)) { |
|
| 711 | + if (preg_match('/\+0580/', $date)) { |
|
| 712 | 712 | $date = str_replace('+0580', '+0530', $date); |
| 713 | 713 | } |
| 714 | 714 | |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | $date = trim(array_pop($array)); |
| 732 | 732 | break; |
| 733 | 733 | } |
| 734 | - try{ |
|
| 734 | + try { |
|
| 735 | 735 | $parsed_date = Carbon::parse($date); |
| 736 | 736 | } catch (\Exception $_e) { |
| 737 | 737 | $error_message = "Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date; |
@@ -233,7 +233,7 @@ |
||
| 233 | 233 | return "UID"; |
| 234 | 234 | } |
| 235 | 235 | if (strlen($uid) > 0 && !is_numeric($uid)) { |
| 236 | - return (string)$uid; |
|
| 236 | + return (string) $uid; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return ""; |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | throw new AuthFailedException($message); |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(!$this->stream) { |
|
| 92 | + if (!$this->stream) { |
|
| 93 | 93 | $errors = \imap_errors(); |
| 94 | 94 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
| 95 | 95 | throw new AuthFailedException($message); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $errors = \imap_errors(); |
| 99 | - if(is_array($errors)) { |
|
| 99 | + if (is_array($errors)) { |
|
| 100 | 100 | $status = $this->examineFolder(); |
| 101 | - if($status['exists'] !== 0) { |
|
| 101 | + if ($status['exists'] !== 0) { |
|
| 102 | 102 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
| 103 | 103 | throw new RuntimeException($message); |
| 104 | 104 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | if (!$this->cert_validation) { |
| 130 | 130 | $address .= '/novalidate-cert'; |
| 131 | 131 | } |
| 132 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
| 132 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
| 133 | 133 | $address .= '/'.$this->encryption; |
| 134 | 134 | } elseif ($this->encryption === "starttls") { |
| 135 | 135 | $address .= '/tls'; |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function connected(){ |
|
| 162 | + public function connected() { |
|
| 163 | 163 | return boolval($this->stream); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return array |
| 233 | 233 | */ |
| 234 | - public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID){ |
|
| 234 | + public function headers($uids, $rfc = "RFC822", $uid = IMAP::ST_UID) { |
|
| 235 | 235 | $result = []; |
| 236 | 236 | $uids = is_array($uids) ? $uids : [$uids]; |
| 237 | 237 | foreach ($uids as $id) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return array |
| 249 | 249 | */ |
| 250 | - public function flags($uids, $uid = IMAP::ST_UID){ |
|
| 250 | + public function flags($uids, $uid = IMAP::ST_UID) { |
|
| 251 | 251 | $result = []; |
| 252 | 252 | $uids = is_array($uids) ? $uids : [$uids]; |
| 253 | 253 | foreach ($uids as $id) { |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | $flags = []; |
| 256 | 256 | if (is_array($raw_flags) && isset($raw_flags[0])) { |
| 257 | 257 | $raw_flags = (array) $raw_flags[0]; |
| 258 | - foreach($raw_flags as $flag => $value) { |
|
| 259 | - if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false){ |
|
| 258 | + foreach ($raw_flags as $flag => $value) { |
|
| 259 | + if ($value === 1 && in_array($flag, ["size", "uid", "msgno", "update"]) === false) { |
|
| 260 | 260 | $flags[] = "\\".ucfirst($flag); |
| 261 | 261 | } |
| 262 | 262 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | if ($id === null) { |
| 278 | 278 | $overview = $this->overview("1:*"); |
| 279 | 279 | $uids = []; |
| 280 | - foreach($overview as $set){ |
|
| 280 | + foreach ($overview as $set) { |
|
| 281 | 281 | $uids[$set->msgno] = $set->uid; |
| 282 | 282 | } |
| 283 | 283 | return $uids; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * @return array |
| 304 | 304 | */ |
| 305 | 305 | public function overview($sequence, $uid = IMAP::ST_UID) { |
| 306 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
| 306 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | $result = []; |
| 319 | 319 | |
| 320 | 320 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
| 321 | - if(is_array($items)){ |
|
| 321 | + if (is_array($items)) { |
|
| 322 | 322 | foreach ($items as $item) { |
| 323 | 323 | $name = $this->decodeFolderName($item->name); |
| 324 | 324 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
| 325 | 325 | } |
| 326 | - }else{ |
|
| 326 | + }else { |
|
| 327 | 327 | throw new RuntimeException(\imap_last_error()); |
| 328 | 328 | } |
| 329 | 329 | |
@@ -345,9 +345,9 @@ discard block |
||
| 345 | 345 | public function store(array $flags, $from, $to = null, $mode = null, $silent = true, $uid = IMAP::ST_UID) { |
| 346 | 346 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
| 347 | 347 | |
| 348 | - if ($mode == "+"){ |
|
| 348 | + if ($mode == "+") { |
|
| 349 | 349 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 350 | - }else{ |
|
| 350 | + }else { |
|
| 351 | 351 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
| 352 | 352 | } |
| 353 | 353 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | public function appendMessage($folder, $message, $flags = null, $date = null) { |
| 371 | 371 | if ($date != null) { |
| 372 | - if ($date instanceof \Carbon\Carbon){ |
|
| 372 | + if ($date instanceof \Carbon\Carbon) { |
|
| 373 | 373 | $date = $date->format('d-M-Y H:i:s O'); |
| 374 | 374 | } |
| 375 | 375 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | * @return array|bool Tokens if operation successful, false if an error occurred |
| 402 | 402 | */ |
| 403 | 403 | public function copyManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
| 404 | - foreach($messages as $msg) { |
|
| 404 | + foreach ($messages as $msg) { |
|
| 405 | 405 | if ($this->copyMessage($folder, $msg, null, $uid) == false) { |
| 406 | 406 | return false; |
| 407 | 407 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | * @return array|bool Tokens if operation successful, false if an error occurred |
| 434 | 434 | */ |
| 435 | 435 | public function moveManyMessages($messages, $folder, $uid = IMAP::ST_UID) { |
| 436 | - foreach($messages as $msg) { |
|
| 436 | + foreach ($messages as $msg) { |
|
| 437 | 437 | if ($this->moveMessage($folder, $msg, null, $uid) == false) { |
| 438 | 438 | return false; |
| 439 | 439 | } |
@@ -556,14 +556,14 @@ discard block |
||
| 556 | 556 | /** |
| 557 | 557 | * Enable the debug mode |
| 558 | 558 | */ |
| 559 | - public function enableDebug(){ |
|
| 559 | + public function enableDebug() { |
|
| 560 | 560 | $this->debug = true; |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
| 564 | 564 | * Disable the debug mode |
| 565 | 565 | */ |
| 566 | - public function disableDebug(){ |
|
| 566 | + public function disableDebug() { |
|
| 567 | 567 | $this->debug = false; |
| 568 | 568 | } |
| 569 | 569 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | if (ClientManager::get('options.fetch_order') === 'desc') { |
| 97 | 97 | $this->fetch_order = 'desc'; |
| 98 | - } else { |
|
| 98 | + }else { |
|
| 99 | 99 | $this->fetch_order = 'asc'; |
| 100 | 100 | } |
| 101 | 101 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | break; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return (string)$value; |
|
| 129 | + return (string) $value; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -158,14 +158,14 @@ discard block |
||
| 158 | 158 | $this->query->each(function($statement) use (&$query) { |
| 159 | 159 | if (count($statement) == 1) { |
| 160 | 160 | $query .= $statement[0]; |
| 161 | - } else { |
|
| 161 | + }else { |
|
| 162 | 162 | if ($statement[1] === null) { |
| 163 | 163 | $query .= $statement[0]; |
| 164 | - } else { |
|
| 164 | + }else { |
|
| 165 | 165 | if (is_numeric($statement[1])) { |
| 166 | - $query .= $statement[0] . ' ' . $statement[1]; |
|
| 167 | - } else { |
|
| 168 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
| 166 | + $query .= $statement[0].' '.$statement[1]; |
|
| 167 | + }else { |
|
| 168 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | $key = $message->getMessageId(); |
| 300 | 300 | break; |
| 301 | 301 | } |
| 302 | - return (string)$key; |
|
| 302 | + return (string) $key; |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | $extensions = isset($raw_messages["extensions"][$uid]) ? $raw_messages["extensions"][$uid] : []; |
| 330 | 330 | |
| 331 | 331 | $message = $this->make($uid, $msglist, $header, $content, $flag); |
| 332 | - foreach($extensions as $key => $extension) { |
|
| 332 | + foreach ($extensions as $key => $extension) { |
|
| 333 | 333 | $message->getHeader()->set($key, $extension); |
| 334 | 334 | } |
| 335 | 335 | if ($message !== null) { |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $this->setDelimiter($delimiter); |
| 124 | 124 | $this->path = $folder_name; |
| 125 | - $this->full_name = $this->decodeName($folder_name); |
|
| 125 | + $this->full_name = $this->decodeName($folder_name); |
|
| 126 | 126 | $this->name = $this->getSimpleName($this->delimiter, $this->full_name); |
| 127 | 127 | |
| 128 | 128 | $this->parseAttributes($attributes); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @throws Exceptions\ConnectionFailedException |
| 137 | 137 | * @throws Exceptions\RuntimeException |
| 138 | 138 | */ |
| 139 | - public function query($extensions = []){ |
|
| 139 | + public function query($extensions = []) { |
|
| 140 | 140 | $this->getClient()->checkConnection(); |
| 141 | 141 | $this->getClient()->openFolder($this->path); |
| 142 | 142 | $extensions = count($extensions) > 0 ? $extensions : $this->getClient()->extensions; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @throws Exceptions\ConnectionFailedException |
| 150 | 150 | * @throws Exceptions\RuntimeException |
| 151 | 151 | */ |
| 152 | - public function search($extensions = 'UTF-8'){ |
|
| 152 | + public function search($extensions = 'UTF-8') { |
|
| 153 | 153 | return $this->query($extensions); |
| 154 | 154 | } |
| 155 | 155 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @throws Exceptions\ConnectionFailedException |
| 159 | 159 | * @throws Exceptions\RuntimeException |
| 160 | 160 | */ |
| 161 | - public function messages($extensions = []){ |
|
| 161 | + public function messages($extensions = []) { |
|
| 162 | 162 | return $this->query($extensions); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | public function move($new_name, $expunge = true) { |
| 234 | 234 | $this->client->checkConnection(); |
| 235 | 235 | $status = $this->client->getConnection()->renameFolder($this->full_name, $new_name); |
| 236 | - if($expunge) $this->client->expunge(); |
|
| 236 | + if ($expunge) $this->client->expunge(); |
|
| 237 | 237 | |
| 238 | 238 | $folder = $this->client->getFolder($new_name); |
| 239 | 239 | $event = $this->getEvent("folder", "moved"); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @throws Exceptions\MessageNotFoundException |
| 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); |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | try { |
| 373 | 373 | $line = $connection->nextLine(); |
| 374 | 374 | if (($pos = strpos($line, "EXISTS")) !== false) { |
| 375 | - $msgn = (int) substr($line, 2, $pos -2); |
|
| 375 | + $msgn = (int) substr($line, 2, $pos - 2); |
|
| 376 | 376 | $connection->done(); |
| 377 | 377 | |
| 378 | 378 | $this->client->openFolder($this->path, true); |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | |
| 386 | 386 | $connection->idle(); |
| 387 | 387 | } |
| 388 | - }catch (Exceptions\RuntimeException $e) { |
|
| 389 | - if(strpos($e->getMessage(), "connection closed") === false) { |
|
| 388 | + } catch (Exceptions\RuntimeException $e) { |
|
| 389 | + if (strpos($e->getMessage(), "connection closed") === false) { |
|
| 390 | 390 | throw $e; |
| 391 | 391 | } |
| 392 | 392 | if ($auto_reconnect === true) { |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | * Set the delimiter |
| 436 | 436 | * @param $delimiter |
| 437 | 437 | */ |
| 438 | - public function setDelimiter($delimiter){ |
|
| 439 | - if(in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 438 | + public function setDelimiter($delimiter) { |
|
| 439 | + if (in_array($delimiter, [null, '', ' ', false]) === true) { |
|
| 440 | 440 | $delimiter = ClientManager::get('options.delimiter', '/'); |
| 441 | 441 | } |
| 442 | 442 | |