@@ -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 \Webklex\PHPIMAP\Attachment $oAttachment */ |
| 79 | 79 | if ($oAttachment->id) { |
| 80 | 80 | $body = str_replace('cid:'.$oAttachment->id, 'data:'.$oAttachment->getContentType().';base64, '.base64_encode($oAttachment->getContent()), $body); |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | public function __construct($msgn, $msglist, Client $client, $fetch_options = null, $fetch_body = false, $fetch_flags = false) { |
| 195 | 195 | |
| 196 | 196 | $default_mask = $client->getDefaultMessageMask(); |
| 197 | - if($default_mask != null) { |
|
| 197 | + if ($default_mask != null) { |
|
| 198 | 198 | $this->mask = $default_mask; |
| 199 | 199 | } |
| 200 | 200 | $this->events["message"] = $client->getDefaultEvents("message"); |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | * @throws MethodNotFoundException |
| 240 | 240 | */ |
| 241 | 241 | public function __call($method, $arguments) { |
| 242 | - if(strtolower(substr($method, 0, 3)) === 'get') { |
|
| 242 | + if (strtolower(substr($method, 0, 3)) === 'get') { |
|
| 243 | 243 | $name = Str::snake(substr($method, 3)); |
| 244 | 244 | return $this->get($name); |
| 245 | 245 | }elseif (strtolower(substr($method, 0, 3)) === 'set') { |
| 246 | 246 | $name = Str::snake(substr($method, 3)); |
| 247 | 247 | |
| 248 | - if(in_array($name, array_keys($this->attributes))) { |
|
| 248 | + if (in_array($name, array_keys($this->attributes))) { |
|
| 249 | 249 | $this->attributes[$name] = array_pop($arguments); |
| 250 | 250 | |
| 251 | 251 | return $this->attributes[$name]; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @return mixed|null |
| 287 | 287 | */ |
| 288 | 288 | public function get($name) { |
| 289 | - if(isset($this->attributes[$name])) { |
|
| 289 | + if (isset($this->attributes[$name])) { |
|
| 290 | 290 | return $this->attributes[$name]; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | $flags = $this->client->getConnection()->flags([$this->msgn]); |
| 369 | 369 | |
| 370 | 370 | if (isset($flags[$this->msgn])) { |
| 371 | - foreach($flags[$this->msgn] as $flag) { |
|
| 372 | - if (strpos($flag, "\\") === 0){ |
|
| 371 | + foreach ($flags[$this->msgn] as $flag) { |
|
| 372 | + if (strpos($flag, "\\") === 0) { |
|
| 373 | 373 | $flag = substr($flag, 1); |
| 374 | 374 | } |
| 375 | 375 | $flag_key = strtolower($flag); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | private function fetchPart(Part $part) { |
| 427 | 427 | |
| 428 | - if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])) ) ) { |
|
| 428 | + if ($part->type == IMAP::MESSAGE_TYPE_TEXT && ($part->ifdisposition == 0 || (empty($part->disposition) || !in_array(strtolower($part->disposition), ['attachment', 'inline'])))) { |
|
| 429 | 429 | |
| 430 | 430 | if (strtolower($part->subtype) == "plain" || strtolower($part->subtype) == "csv") { |
| 431 | 431 | $encoding = $this->getEncoding($part); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } elseif ($part->ifdisposition == 1 && strtolower($part->disposition) == 'attachment') { |
| 464 | 464 | $this->fetchAttachment($part); |
| 465 | 465 | } |
| 466 | - } else { |
|
| 466 | + }else { |
|
| 467 | 467 | $this->fetchAttachment($part); |
| 468 | 468 | } |
| 469 | 469 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | if ($oAttachment->getName() !== null) { |
| 480 | 480 | if ($oAttachment->getId() !== null) { |
| 481 | 481 | $this->attachments->put($oAttachment->getId(), $oAttachment); |
| 482 | - } else { |
|
| 482 | + }else { |
|
| 483 | 483 | $this->attachments->push($oAttachment); |
| 484 | 484 | } |
| 485 | 485 | } |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7') { |
| 598 | 598 | return @iconv($from, $to.'//IGNORE', $str); |
| 599 | - } else { |
|
| 599 | + }else { |
|
| 600 | 600 | if (!$from) { |
| 601 | 601 | return mb_convert_encoding($str, $to); |
| 602 | 602 | } |
@@ -617,9 +617,9 @@ discard block |
||
| 617 | 617 | return EncodingAliases::get($parameter->value); |
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | - }elseif (property_exists($structure, 'charset')){ |
|
| 620 | + }elseif (property_exists($structure, 'charset')) { |
|
| 621 | 621 | return EncodingAliases::get($structure->charset); |
| 622 | - }elseif (is_string($structure) === true){ |
|
| 622 | + }elseif (is_string($structure) === true) { |
|
| 623 | 623 | return mb_detect_encoding($structure); |
| 624 | 624 | } |
| 625 | 625 | |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | * @throws Exceptions\ConnectionFailedException |
| 634 | 634 | * @throws Exceptions\FolderFetchingException |
| 635 | 635 | */ |
| 636 | - public function getFolder(){ |
|
| 636 | + public function getFolder() { |
|
| 637 | 637 | return $this->client->getFolder($this->folder_path); |
| 638 | 638 | } |
| 639 | 639 | |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | public function delete($expunge = true) { |
| 712 | 712 | $status = $this->setFlag("Deleted"); |
| 713 | - if($expunge) $this->client->expunge(); |
|
| 713 | + if ($expunge) $this->client->expunge(); |
|
| 714 | 714 | |
| 715 | 715 | $event = $this->getEvent("message", "deleted"); |
| 716 | 716 | $event::dispatch($this); |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | */ |
| 730 | 730 | public function restore($expunge = true) { |
| 731 | 731 | $status = $this->unsetFlag("Deleted"); |
| 732 | - if($expunge) $this->client->expunge(); |
|
| 732 | + if ($expunge) $this->client->expunge(); |
|
| 733 | 733 | |
| 734 | 734 | $event = $this->getEvent("message", "restored"); |
| 735 | 735 | $event::dispatch($this); |
@@ -882,7 +882,7 @@ discard block |
||
| 882 | 882 | * |
| 883 | 883 | * @return object|null |
| 884 | 884 | */ |
| 885 | - public function getStructure(){ |
|
| 885 | + public function getStructure() { |
|
| 886 | 886 | return $this->structure; |
| 887 | 887 | } |
| 888 | 888 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | * |
| 909 | 909 | * @return array |
| 910 | 910 | */ |
| 911 | - public function getAttributes(){ |
|
| 911 | + public function getAttributes() { |
|
| 912 | 912 | return array_merge($this->attributes, $this->header->getAttributes()); |
| 913 | 913 | } |
| 914 | 914 | |
@@ -918,8 +918,8 @@ discard block |
||
| 918 | 918 | * |
| 919 | 919 | * @return $this |
| 920 | 920 | */ |
| 921 | - public function setMask($mask){ |
|
| 922 | - if(class_exists($mask)){ |
|
| 921 | + public function setMask($mask) { |
|
| 922 | + if (class_exists($mask)) { |
|
| 923 | 923 | $this->mask = $mask; |
| 924 | 924 | } |
| 925 | 925 | |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * |
| 932 | 932 | * @return string |
| 933 | 933 | */ |
| 934 | - public function getMask(){ |
|
| 934 | + public function getMask() { |
|
| 935 | 935 | return $this->mask; |
| 936 | 936 | } |
| 937 | 937 | |
@@ -942,9 +942,9 @@ discard block |
||
| 942 | 942 | * @return mixed |
| 943 | 943 | * @throws MaskNotFoundException |
| 944 | 944 | */ |
| 945 | - public function mask($mask = null){ |
|
| 945 | + public function mask($mask = null) { |
|
| 946 | 946 | $mask = $mask !== null ? $mask : $this->mask; |
| 947 | - if(class_exists($mask)){ |
|
| 947 | + if (class_exists($mask)) { |
|
| 948 | 948 | return new $mask($this); |
| 949 | 949 | } |
| 950 | 950 | |
@@ -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 | |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | $this->name = $this->header->get("name"); |
| 176 | 176 | $this->filename = $this->header->get("filename"); |
| 177 | 177 | |
| 178 | - if(!empty($this->header->get("id"))) { |
|
| 178 | + if (!empty($this->header->get("id"))) { |
|
| 179 | 179 | $this->id = $this->header->get("id"); |
| 180 | - } else if(!empty($this->header->get("x-attachment-id"))){ |
|
| 180 | + }else if (!empty($this->header->get("x-attachment-id"))) { |
|
| 181 | 181 | $this->id = $this->header->get("x-attachment-id"); |
| 182 | - } else if(!empty($this->header->get("content-id"))){ |
|
| 182 | + }else if (!empty($this->header->get("content-id"))) { |
|
| 183 | 183 | $this->id = strtr($this->header->get("content-id"), [ |
| 184 | 184 | '<' => '', |
| 185 | 185 | '>' => '' |
| 186 | 186 | ]); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(!empty($this->header->get("content-type"))){ |
|
| 189 | + if (!empty($this->header->get("content-type"))) { |
|
| 190 | 190 | $rawContentType = $this->header->get("content-type"); |
| 191 | 191 | $contentTypeArray = explode(';', $rawContentType); |
| 192 | 192 | $this->content_type = trim($contentTypeArray[0]); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @return string |
| 204 | 204 | * @throws InvalidMessageDateException |
| 205 | 205 | */ |
| 206 | - private function findHeaders(){ |
|
| 206 | + private function findHeaders() { |
|
| 207 | 207 | $body = $this->raw; |
| 208 | 208 | while (($pos = strpos($body, "\r\n")) > 0) { |
| 209 | 209 | $body = substr($body, $pos + 2); |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | /** |
| 220 | 220 | * Try to parse the subtype if any is present |
| 221 | 221 | */ |
| 222 | - private function parseSubtype(){ |
|
| 222 | + private function parseSubtype() { |
|
| 223 | 223 | $content_type = $this->header->get("content-type"); |
| 224 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
| 224 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
| 225 | 225 | $this->subtype = substr($content_type, $pos + 1); |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -229,9 +229,9 @@ discard block |
||
| 229 | 229 | /** |
| 230 | 230 | * Try to parse the disposition if any is present |
| 231 | 231 | */ |
| 232 | - private function parseDisposition(){ |
|
| 232 | + private function parseDisposition() { |
|
| 233 | 233 | $content_disposition = $this->header->get("content-disposition"); |
| 234 | - if($content_disposition !== null) { |
|
| 234 | + if ($content_disposition !== null) { |
|
| 235 | 235 | $this->ifdisposition = true; |
| 236 | 236 | $this->disposition = $content_disposition; |
| 237 | 237 | } |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | /** |
| 241 | 241 | * Try to parse the description if any is present |
| 242 | 242 | */ |
| 243 | - private function parseDescription(){ |
|
| 243 | + private function parseDescription() { |
|
| 244 | 244 | $content_description = $this->header->get("content-description"); |
| 245 | - if($content_description !== null) { |
|
| 245 | + if ($content_description !== null) { |
|
| 246 | 246 | $this->ifdescription = true; |
| 247 | 247 | $this->description = $content_description; |
| 248 | 248 | } |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | /** |
| 252 | 252 | * Try to parse the encoding if any is present |
| 253 | 253 | */ |
| 254 | - private function parseEncoding(){ |
|
| 254 | + private function parseEncoding() { |
|
| 255 | 255 | $encoding = $this->header->get("content-transfer-encoding"); |
| 256 | - if($encoding !== null) { |
|
| 256 | + if ($encoding !== null) { |
|
| 257 | 257 | switch (strtolower($encoding)) { |
| 258 | 258 | case "quoted-printable": |
| 259 | 259 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |