@@ -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); |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | * @return int|null |
| 74 | 74 | */ |
| 75 | 75 | public function total($total = null) { |
| 76 | - if($total === null) { |
|
| 76 | + if ($total === null) { |
|
| 77 | 77 | return $this->total; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | * @param object $object |
| 39 | 39 | */ |
| 40 | 40 | public function __construct($object) { |
| 41 | - if (property_exists($object, "personal")){ $this->personal = $object->personal; } |
|
| 42 | - if (property_exists($object, "mailbox")){ $this->mailbox = $object->mailbox; } |
|
| 43 | - if (property_exists($object, "host")){ $this->host = $object->host; } |
|
| 44 | - if (property_exists($object, "mail")){ $this->mail = $object->mail; } |
|
| 45 | - if (property_exists($object, "full")){ $this->full = $object->full; } |
|
| 41 | + if (property_exists($object, "personal")) { $this->personal = $object->personal; } |
|
| 42 | + if (property_exists($object, "mailbox")) { $this->mailbox = $object->mailbox; } |
|
| 43 | + if (property_exists($object, "host")) { $this->host = $object->host; } |
|
| 44 | + if (property_exists($object, "mail")) { $this->mail = $object->mail; } |
|
| 45 | + if (property_exists($object, "full")) { $this->full = $object->full; } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function __serialize(){ |
|
| 63 | + public function __serialize() { |
|
| 64 | 64 | return [ |
| 65 | 65 | "personal" => $this->personal, |
| 66 | 66 | "mailbox" => $this->mailbox, |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return array |
| 77 | 77 | */ |
| 78 | - public function toArray(){ |
|
| 78 | + public function toArray() { |
|
| 79 | 79 | return $this->__serialize(); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - public function toString(){ |
|
| 87 | + public function toString() { |
|
| 88 | 88 | return $this->__toString(); |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | \ No newline at end of file |
@@ -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 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | if ($statement[1] === null) { |
| 163 | 163 | $query .= $statement[0]; |
| 164 | 164 | } else { |
| 165 | - $query .= $statement[0] . ' "' . $statement[1] . '"'; |
|
| 165 | + $query .= $statement[0].' "'.$statement[1].'"'; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | $query .= ' '; |
@@ -247,18 +247,18 @@ discard block |
||
| 247 | 247 | * @throws GetMessagesFailedException |
| 248 | 248 | * @throws ReflectionException |
| 249 | 249 | */ |
| 250 | - protected function make($uid, $msglist, $header, $content, $flags){ |
|
| 250 | + protected function make($uid, $msglist, $header, $content, $flags) { |
|
| 251 | 251 | try { |
| 252 | 252 | return Message::make($uid, $msglist, $this->getClient(), $header, $content, $flags, $this->getFetchOptions(), $this->sequence); |
| 253 | - }catch (MessageNotFoundException $e) { |
|
| 253 | + } catch (MessageNotFoundException $e) { |
|
| 254 | 254 | $this->setError($uid, $e); |
| 255 | - }catch (RuntimeException $e) { |
|
| 255 | + } catch (RuntimeException $e) { |
|
| 256 | 256 | $this->setError($uid, $e); |
| 257 | - }catch (MessageFlagException $e) { |
|
| 257 | + } catch (MessageFlagException $e) { |
|
| 258 | 258 | $this->setError($uid, $e); |
| 259 | - }catch (InvalidMessageDateException $e) { |
|
| 259 | + } catch (InvalidMessageDateException $e) { |
|
| 260 | 260 | $this->setError($uid, $e); |
| 261 | - }catch (MessageContentFetchingException $e) { |
|
| 261 | + } catch (MessageContentFetchingException $e) { |
|
| 262 | 262 | $this->setError($uid, $e); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return string |
| 277 | 277 | */ |
| 278 | - protected function getMessageKey($message_key, $msglist, $message){ |
|
| 278 | + protected function getMessageKey($message_key, $msglist, $message) { |
|
| 279 | 279 | switch ($message_key) { |
| 280 | 280 | case 'number': |
| 281 | 281 | $key = $message->getMessageNo(); |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $key = $message->getMessageId(); |
| 291 | 291 | break; |
| 292 | 292 | } |
| 293 | - return (string)$key; |
|
| 293 | + return (string) $key; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | * |
| 783 | 783 | * @return boolean |
| 784 | 784 | */ |
| 785 | - public function hasErrors($uid = null){ |
|
| 785 | + public function hasErrors($uid = null) { |
|
| 786 | 786 | if ($uid !== null) { |
| 787 | 787 | return $this->hasError($uid); |
| 788 | 788 | } |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | * |
| 796 | 796 | * @return boolean |
| 797 | 797 | */ |
| 798 | - public function hasError($uid){ |
|
| 798 | + public function hasError($uid) { |
|
| 799 | 799 | return isset($this->errors[$uid]); |
| 800 | 800 | } |
| 801 | 801 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | * |
| 805 | 805 | * @return array |
| 806 | 806 | */ |
| 807 | - public function errors(){ |
|
| 807 | + public function errors() { |
|
| 808 | 808 | return $this->getErrors(); |
| 809 | 809 | } |
| 810 | 810 | |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | * |
| 814 | 814 | * @return array |
| 815 | 815 | */ |
| 816 | - public function getErrors(){ |
|
| 816 | + public function getErrors() { |
|
| 817 | 817 | return $this->errors; |
| 818 | 818 | } |
| 819 | 819 | |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | * |
| 824 | 824 | * @return Exception|null |
| 825 | 825 | */ |
| 826 | - public function error($uid){ |
|
| 826 | + public function error($uid) { |
|
| 827 | 827 | return $this->getError($uid); |
| 828 | 828 | } |
| 829 | 829 | |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | * |
| 834 | 834 | * @return Exception|null |
| 835 | 835 | */ |
| 836 | - public function getError($uid){ |
|
| 836 | + public function getError($uid) { |
|
| 837 | 837 | if ($this->hasError($uid)) { |
| 838 | 838 | return $this->errors[$uid]; |
| 839 | 839 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | if (strpos(strtolower($name), "where") === false) { |
| 88 | - $method = 'where' . ucfirst($name); |
|
| 88 | + $method = 'where'.ucfirst($name); |
|
| 89 | 89 | } else { |
| 90 | 90 | $method = lcfirst($name); |
| 91 | 91 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return call_user_func_array([$that, $method], $arguments); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
| 97 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | foreach ($criteria as $key => $value) { |
| 139 | 139 | if (is_numeric($key)) { |
| 140 | 140 | $this->where($value); |
| 141 | - }else{ |
|
| 141 | + } else { |
|
| 142 | 142 | $this->where($key, $value); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @throws InvalidWhereQueryCriteriaException |
| 158 | 158 | */ |
| 159 | - protected function push_search_criteria(string $criteria, $value){ |
|
| 159 | + protected function push_search_criteria(string $criteria, $value) { |
|
| 160 | 160 | $criteria = $this->validate_criteria($criteria); |
| 161 | 161 | $value = $this->parse_value($value); |
| 162 | 162 | |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @return $this|mixed |
| 541 | 541 | */ |
| 542 | 542 | public function unless($value, $callback, $default = null) { |
| 543 | - if (! $value) { |
|
| 543 | + if (!$value) { |
|
| 544 | 544 | return $callback($this, $value) ?: $this; |
| 545 | 545 | } elseif ($default) { |
| 546 | 546 | return $default($this, $value) ?: $this; |
@@ -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 | } |
@@ -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) { |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | public static function get($key, $default = null) { |
| 77 | 77 | $parts = explode('.', $key); |
| 78 | 78 | $value = null; |
| 79 | - foreach($parts as $part) { |
|
| 80 | - if($value === null) { |
|
| 81 | - if(isset(self::$config[$part])) { |
|
| 79 | + foreach ($parts as $part) { |
|
| 80 | + if ($value === null) { |
|
| 81 | + if (isset(self::$config[$part])) { |
|
| 82 | 82 | $value = self::$config[$part]; |
| 83 | - }else{ |
|
| 83 | + } else { |
|
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | - }else{ |
|
| 87 | - if(isset($value[$part])) { |
|
| 86 | + } else { |
|
| 87 | + if (isset($value[$part])) { |
|
| 88 | 88 | $value = $value[$part]; |
| 89 | - }else{ |
|
| 89 | + } else { |
|
| 90 | 90 | break; |
| 91 | 91 | } |
| 92 | 92 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public function setConfig($config) { |
| 178 | 178 | |
| 179 | - if(is_array($config) === false) { |
|
| 179 | + if (is_array($config) === false) { |
|
| 180 | 180 | $config = require $config; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -186,17 +186,17 @@ discard block |
||
| 186 | 186 | $vendor_config = require $path; |
| 187 | 187 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
| 188 | 188 | |
| 189 | - if(is_array($config)){ |
|
| 190 | - if(isset($config['default'])){ |
|
| 191 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
| 189 | + if (is_array($config)) { |
|
| 190 | + if (isset($config['default'])) { |
|
| 191 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
| 192 | 192 | |
| 193 | 193 | $default_config = $vendor_config['accounts']['default']; |
| 194 | - if(isset($config['accounts'][$config['default']])){ |
|
| 194 | + if (isset($config['accounts'][$config['default']])) { |
|
| 195 | 195 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - if(is_array($config['accounts'])){ |
|
| 199 | - foreach($config['accounts'] as $account_key => $account){ |
|
| 198 | + if (is_array($config['accounts'])) { |
|
| 199 | + foreach ($config['accounts'] as $account_key => $account) { |
|
| 200 | 200 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -232,23 +232,23 @@ discard block |
||
| 232 | 232 | $arrays = func_get_args(); |
| 233 | 233 | $base = array_shift($arrays); |
| 234 | 234 | |
| 235 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 235 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 236 | 236 | |
| 237 | - foreach($arrays as $append) { |
|
| 237 | + foreach ($arrays as $append) { |
|
| 238 | 238 | |
| 239 | - if(!is_array($append)) $append = array($append); |
|
| 239 | + if (!is_array($append)) $append = array($append); |
|
| 240 | 240 | |
| 241 | - foreach($append as $key => $value) { |
|
| 241 | + foreach ($append as $key => $value) { |
|
| 242 | 242 | |
| 243 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
| 243 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
| 244 | 244 | $base[$key] = $append[$key]; |
| 245 | 245 | continue; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - if(is_array($value) or is_array($base[$key])) { |
|
| 248 | + if (is_array($value) or is_array($base[$key])) { |
|
| 249 | 249 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 250 | - } else if(is_numeric($key)) { |
|
| 251 | - if(!in_array($value, $base)) $base[] = $value; |
|
| 250 | + } else if (is_numeric($key)) { |
|
| 251 | + if (!in_array($value, $base)) $base[] = $value; |
|
| 252 | 252 | } else { |
| 253 | 253 | $base[$key] = $value; |
| 254 | 254 | } |
@@ -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 | $boundary = $this->find("/boundary\=(.*)/i"); |
| 177 | 177 | |
| 178 | 178 | if ($boundary === null) { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * |
| 198 | 198 | * @throws InvalidMessageDateException |
| 199 | 199 | */ |
| 200 | - protected function parse(){ |
|
| 200 | + protected function parse() { |
|
| 201 | 201 | $header = $this->rfc822_parse_headers($this->raw); |
| 202 | 202 | |
| 203 | 203 | $this->extractAddresses($header); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | $this->parseDate($header); |
| 216 | 216 | foreach ($header as $key => $value) { |
| 217 | 217 | $key = trim(rtrim(strtolower($key))); |
| 218 | - if(!isset($this->attributes[$key])){ |
|
| 218 | + if (!isset($this->attributes[$key])) { |
|
| 219 | 219 | $this->set($key, $value); |
| 220 | 220 | } |
| 221 | 221 | } |
@@ -231,19 +231,19 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return object |
| 233 | 233 | */ |
| 234 | - public function rfc822_parse_headers($raw_headers){ |
|
| 234 | + public function rfc822_parse_headers($raw_headers) { |
|
| 235 | 235 | $headers = []; |
| 236 | 236 | $imap_headers = []; |
| 237 | 237 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
| 238 | 238 | $raw_imap_headers = (array) \imap_rfc822_parse_headers($this->raw); |
| 239 | - foreach($raw_imap_headers as $key => $values) { |
|
| 239 | + foreach ($raw_imap_headers as $key => $values) { |
|
| 240 | 240 | $key = str_replace("-", "_", $key); |
| 241 | 241 | $imap_headers[$key] = $values; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | $lines = explode("\r\n", str_replace("\r\n\t", ' ', $raw_headers)); |
| 245 | 245 | $prev_header = null; |
| 246 | - foreach($lines as $line) { |
|
| 246 | + foreach ($lines as $line) { |
|
| 247 | 247 | if (substr($line, 0, 1) === "\n") { |
| 248 | 248 | $line = substr($line, 1); |
| 249 | 249 | } |
@@ -263,19 +263,19 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | if (is_array($headers[$prev_header])) { |
| 265 | 265 | $headers[$prev_header][] = $line; |
| 266 | - }else{ |
|
| 266 | + } else { |
|
| 267 | 267 | $headers[$prev_header] .= $line; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | - }else{ |
|
| 270 | + } else { |
|
| 271 | 271 | if (($pos = strpos($line, ":")) > 0) { |
| 272 | 272 | $key = trim(rtrim(strtolower(substr($line, 0, $pos)))); |
| 273 | 273 | $key = str_replace("-", "_", $key); |
| 274 | 274 | |
| 275 | 275 | $value = trim(rtrim(substr($line, $pos + 1))); |
| 276 | 276 | if (isset($headers[$key])) { |
| 277 | - $headers[$key][] = $value; |
|
| 278 | - }else{ |
|
| 277 | + $headers[$key][] = $value; |
|
| 278 | + } else { |
|
| 279 | 279 | $headers[$key] = [$value]; |
| 280 | 280 | } |
| 281 | 281 | $prev_header = $key; |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - foreach($headers as $key => $values) { |
|
| 286 | + foreach ($headers as $key => $values) { |
|
| 287 | 287 | if (isset($imap_headers[$key])) continue; |
| 288 | 288 | $value = null; |
| 289 | - switch($key){ |
|
| 289 | + switch ($key) { |
|
| 290 | 290 | case 'from': |
| 291 | 291 | case 'to': |
| 292 | 292 | case 'cc': |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | break; |
| 302 | 302 | default: |
| 303 | 303 | if (is_array($values)) { |
| 304 | - foreach($values as $k => $v) { |
|
| 304 | + foreach ($values as $k => $v) { |
|
| 305 | 305 | if ($v == "") { |
| 306 | 306 | unset($values[$k]); |
| 307 | 307 | } |
@@ -333,12 +333,12 @@ discard block |
||
| 333 | 333 | * @return array The decoded elements are returned in an array of objects, where each |
| 334 | 334 | * object has two properties, charset and text. |
| 335 | 335 | */ |
| 336 | - public function mime_header_decode($text){ |
|
| 336 | + public function mime_header_decode($text) { |
|
| 337 | 337 | if (extension_loaded('imap')) { |
| 338 | 338 | return \imap_mime_header_decode($text); |
| 339 | 339 | } |
| 340 | 340 | $charset = $this->getEncoding($text); |
| 341 | - return [(object)[ |
|
| 341 | + return [(object) [ |
|
| 342 | 342 | "charset" => $charset, |
| 343 | 343 | "text" => $this->convertEncoding($text, $charset) |
| 344 | 344 | ]]; |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | }elseif (property_exists($structure, 'charset')) { |
| 425 | 425 | return EncodingAliases::get($structure->charset, $this->fallback_encoding); |
| 426 | - }elseif (is_string($structure) === true){ |
|
| 426 | + }elseif (is_string($structure) === true) { |
|
| 427 | 427 | return mb_detect_encoding($structure); |
| 428 | 428 | } |
| 429 | 429 | |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | if ($value !== null) { |
| 457 | 457 | $is_utf8_base = $this->is_uft8($value); |
| 458 | 458 | |
| 459 | - if($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 459 | + if ($decoder === 'utf-8' && extension_loaded('imap')) { |
|
| 460 | 460 | $value = \imap_utf8($value); |
| 461 | 461 | $is_utf8_base = $this->is_uft8($value); |
| 462 | 462 | if ($is_utf8_base) { |
@@ -465,14 +465,14 @@ discard block |
||
| 465 | 465 | if ($this->notDecoded($original_value, $value)) { |
| 466 | 466 | $decoded_value = $this->mime_header_decode($value); |
| 467 | 467 | if (count($decoded_value) > 0) { |
| 468 | - if(property_exists($decoded_value[0], "text")) { |
|
| 468 | + if (property_exists($decoded_value[0], "text")) { |
|
| 469 | 469 | $value = $decoded_value[0]->text; |
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | } |
| 473 | - }elseif($decoder === 'iconv' && $is_utf8_base) { |
|
| 473 | + }elseif ($decoder === 'iconv' && $is_utf8_base) { |
|
| 474 | 474 | $value = iconv_mime_decode($value); |
| 475 | - }elseif($is_utf8_base){ |
|
| 475 | + }elseif ($is_utf8_base) { |
|
| 476 | 476 | $value = mb_decode_mimeheader($value); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | * @return array |
| 496 | 496 | */ |
| 497 | 497 | private function decodeArray($values) { |
| 498 | - foreach($values as $key => $value) { |
|
| 498 | + foreach ($values as $key => $value) { |
|
| 499 | 499 | $values[$key] = $this->decode($value); |
| 500 | 500 | } |
| 501 | 501 | return $values; |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | * Try to extract the priority from a given raw header string |
| 506 | 506 | */ |
| 507 | 507 | private function findPriority() { |
| 508 | - if(($priority = $this->get("x_priority")) === null) return; |
|
| 509 | - switch((int)"$priority"){ |
|
| 508 | + if (($priority = $this->get("x_priority")) === null) return; |
|
| 509 | + switch ((int) "$priority") { |
|
| 510 | 510 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 511 | 511 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
| 512 | 512 | break; |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | if (isset($parsed_address['address'])) { |
| 546 | 546 | $mail_address = explode('@', $parsed_address['address']); |
| 547 | 547 | if (count($mail_address) == 2) { |
| 548 | - $addresses[] = (object)[ |
|
| 548 | + $addresses[] = (object) [ |
|
| 549 | 549 | "personal" => isset($parsed_address['display']) ? $parsed_address['display'] : '', |
| 550 | 550 | "mailbox" => $mail_address[0], |
| 551 | 551 | "host" => $mail_address[1], |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | return $addresses; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | - foreach($values as $address) { |
|
| 561 | + foreach ($values as $address) { |
|
| 562 | 562 | foreach (preg_split('/, (?=(?:[^"]*"[^"]*")*[^"]*$)/', $address) as $split_address) { |
| 563 | 563 | $split_address = trim(rtrim($split_address)); |
| 564 | 564 | |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | $name = trim(rtrim($matches["name"])); |
| 574 | 574 | $email = trim(rtrim($matches["email"])); |
| 575 | 575 | list($mailbox, $host) = array_pad(explode("@", $email), 2, null); |
| 576 | - $addresses[] = (object)[ |
|
| 576 | + $addresses[] = (object) [ |
|
| 577 | 577 | "personal" => $name, |
| 578 | 578 | "mailbox" => $mailbox, |
| 579 | 579 | "host" => $host, |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * @param object $header |
| 591 | 591 | */ |
| 592 | 592 | private function extractAddresses($header) { |
| 593 | - foreach(['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key){ |
|
| 593 | + foreach (['from', 'to', 'cc', 'bcc', 'reply_to', 'sender'] as $key) { |
|
| 594 | 594 | if (property_exists($header, $key)) { |
| 595 | 595 | $this->set($key, $this->parseAddresses($header->$key)); |
| 596 | 596 | } |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | } else { |
| 625 | 625 | $personalParts = $this->mime_header_decode($address->personal); |
| 626 | 626 | |
| 627 | - if(is_array($personalParts)) { |
|
| 627 | + if (is_array($personalParts)) { |
|
| 628 | 628 | $address->personal = ''; |
| 629 | 629 | foreach ($personalParts as $p) { |
| 630 | 630 | $address->personal .= $this->convertEncoding($p->text, $this->getEncoding($p)); |
@@ -648,23 +648,23 @@ discard block |
||
| 648 | 648 | /** |
| 649 | 649 | * Search and extract potential header extensions |
| 650 | 650 | */ |
| 651 | - private function extractHeaderExtensions(){ |
|
| 651 | + private function extractHeaderExtensions() { |
|
| 652 | 652 | foreach ($this->attributes as $key => $value) { |
| 653 | 653 | if (is_array($value)) { |
| 654 | 654 | $value = implode(", ", $value); |
| 655 | - }else{ |
|
| 656 | - $value = (string)$value; |
|
| 655 | + } else { |
|
| 656 | + $value = (string) $value; |
|
| 657 | 657 | } |
| 658 | 658 | // Only parse strings and don't parse any attributes like the user-agent |
| 659 | 659 | if (in_array($key, ["user_agent"]) === false) { |
| 660 | - if (($pos = strpos($value, ";")) !== false){ |
|
| 660 | + if (($pos = strpos($value, ";")) !== false) { |
|
| 661 | 661 | $original = substr($value, 0, $pos); |
| 662 | 662 | $this->set($key, trim(rtrim($original)), true); |
| 663 | 663 | |
| 664 | 664 | // Get all potential extensions |
| 665 | 665 | $extensions = explode(";", substr($value, $pos + 1)); |
| 666 | - foreach($extensions as $extension) { |
|
| 667 | - if (($pos = strpos($extension, "=")) !== false){ |
|
| 666 | + foreach ($extensions as $extension) { |
|
| 667 | + if (($pos = strpos($extension, "=")) !== false) { |
|
| 668 | 668 | $key = substr($extension, 0, $pos); |
| 669 | 669 | $key = trim(rtrim(strtolower($key))); |
| 670 | 670 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | $parsed_date = null; |
| 708 | 708 | $date = $header->date; |
| 709 | 709 | |
| 710 | - if(preg_match('/\+0580/', $date)) { |
|
| 710 | + if (preg_match('/\+0580/', $date)) { |
|
| 711 | 711 | $date = str_replace('+0580', '+0530', $date); |
| 712 | 712 | } |
| 713 | 713 | |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | $date = trim(array_pop($array)); |
| 731 | 731 | break; |
| 732 | 732 | } |
| 733 | - try{ |
|
| 733 | + try { |
|
| 734 | 734 | $parsed_date = Carbon::parse($date); |
| 735 | 735 | } catch (\Exception $_e) { |
| 736 | 736 | throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id"), 1100, $e); |