@@ -5,8 +5,8 @@ |
||
5 | 5 | use Rector\Config\RectorConfig; |
6 | 6 | use Rector\Set\ValueObject\SetList; |
7 | 7 | |
8 | -return static function (RectorConfig $containerConfigurator): void { |
|
9 | - $containerConfigurator->paths([__DIR__ . '/src', __DIR__ . '/tests']); |
|
8 | +return static function(RectorConfig $containerConfigurator): void { |
|
9 | + $containerConfigurator->paths([__DIR__.'/src', __DIR__.'/tests']); |
|
10 | 10 | |
11 | 11 | $containerConfigurator->import(SetList::PHP_54); |
12 | 12 | $containerConfigurator->import(SetList::PHP_55); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | } |
97 | 97 | |
98 | - throw new MethodNotFoundException("Method " . self::class . '::' . $method . '() is not supported'); |
|
98 | + throw new MethodNotFoundException("Method ".self::class.'::'.$method.'() is not supported'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | if (isset($this->attributes[$name]) && $strict === false) { |
131 | 131 | if ($this->attributize) { |
132 | 132 | $this->attributes[$name]->add($value, true); |
133 | - } else { |
|
133 | + }else { |
|
134 | 134 | if (isset($this->attributes[$name])) { |
135 | 135 | if (!is_array($this->attributes[$name])) { |
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 | 144 | } elseif (!$this->attributize) { |
145 | 145 | $this->attributes[$name] = $value; |
146 | - } else { |
|
146 | + }else { |
|
147 | 147 | $this->attributes[$name] = new Attribute($name, $value); |
148 | 148 | } |
149 | 149 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $headers = []; |
236 | 236 | $imap_headers = []; |
237 | 237 | if (extension_loaded('imap') && $this->config["rfc822"]) { |
238 | - $raw_imap_headers = (array)imap_rfc822_parse_headers($this->raw); |
|
238 | + $raw_imap_headers = (array) imap_rfc822_parse_headers($this->raw); |
|
239 | 239 | foreach ($raw_imap_headers as $key => $values) { |
240 | 240 | $key = str_replace("-", "_", $key); |
241 | 241 | $imap_headers[$key] = $values; |
@@ -263,11 +263,11 @@ 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); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | $value = trim(rtrim(substr($line, $pos + 1))); |
276 | 276 | if (isset($headers[$key])) { |
277 | 277 | $headers[$key][] = $value; |
278 | - } else { |
|
278 | + }else { |
|
279 | 279 | $headers[$key] = [$value]; |
280 | 280 | } |
281 | 281 | $prev_header = $key; |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | case 'reply_to': |
295 | 295 | case 'sender': |
296 | 296 | $value = $this->decodeAddresses($values); |
297 | - $headers[$key . "address"] = implode(", ", $values); |
|
297 | + $headers[$key."address"] = implode(", ", $values); |
|
298 | 298 | break; |
299 | 299 | case 'subject': |
300 | 300 | $value = implode(" ", $values); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $value = implode(" ", $values); |
314 | 314 | } elseif ($available_values > 2) { |
315 | 315 | $value = array_values($values); |
316 | - } else { |
|
316 | + }else { |
|
317 | 317 | $value = ""; |
318 | 318 | } |
319 | 319 | } |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $headers[$key] = $value; |
323 | 323 | } |
324 | 324 | |
325 | - return (object)array_merge($headers, $imap_headers); |
|
325 | + return (object) array_merge($headers, $imap_headers); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -338,7 +338,7 @@ discard block |
||
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 | ]]; |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | private function findPriority(): void { |
503 | 503 | if (($priority = $this->get("x_priority")) === null) return; |
504 | - switch ((int)"$priority") { |
|
504 | + switch ((int) "$priority") { |
|
505 | 505 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
506 | 506 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
507 | 507 | break; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | if (isset($parsed_address['address'])) { |
541 | 541 | $mail_address = explode('@', $parsed_address['address']); |
542 | 542 | if (count($mail_address) == 2) { |
543 | - $addresses[] = (object)[ |
|
543 | + $addresses[] = (object) [ |
|
544 | 544 | "personal" => $parsed_address['display'] ?? '', |
545 | 545 | "mailbox" => $mail_address[0], |
546 | 546 | "host" => $mail_address[1], |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $name = trim(rtrim($matches["name"])); |
569 | 569 | $email = trim(rtrim($matches["email"])); |
570 | 570 | [$mailbox, $host] = array_pad(explode("@", $email), 2, null); |
571 | - $addresses[] = (object)[ |
|
571 | + $addresses[] = (object) [ |
|
572 | 572 | "personal" => $name, |
573 | 573 | "mailbox" => $mailbox, |
574 | 574 | "host" => $host, |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | } |
606 | 606 | |
607 | 607 | foreach ($list as $item) { |
608 | - $address = (object)$item; |
|
608 | + $address = (object) $item; |
|
609 | 609 | |
610 | 610 | if (!property_exists($address, 'mailbox')) { |
611 | 611 | $address->mailbox = false; |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | } |
616 | 616 | if (!property_exists($address, 'personal')) { |
617 | 617 | $address->personal = false; |
618 | - } else { |
|
618 | + }else { |
|
619 | 619 | $personalParts = $this->mime_header_decode($address->personal); |
620 | 620 | |
621 | 621 | if (is_array($personalParts)) { |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | } |
631 | 631 | } |
632 | 632 | |
633 | - $address->mail = ($address->mailbox && $address->host) ? $address->mailbox . '@' . $address->host : false; |
|
634 | - $address->full = ($address->personal) ? $address->personal . ' <' . $address->mail . '>' : $address->mail; |
|
633 | + $address->mail = ($address->mailbox && $address->host) ? $address->mailbox.'@'.$address->host : false; |
|
634 | + $address->full = ($address->personal) ? $address->personal.' <'.$address->mail.'>' : $address->mail; |
|
635 | 635 | |
636 | 636 | $addresses[] = new Address($address); |
637 | 637 | } |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | foreach ($this->attributes as $key => $value) { |
647 | 647 | if (is_array($value)) { |
648 | 648 | $value = implode(", ", $value); |
649 | - } else { |
|
650 | - $value = (string)$value; |
|
649 | + }else { |
|
650 | + $value = (string) $value; |
|
651 | 651 | } |
652 | 652 | // Only parse strings and don't parse any attributes like the user-agent |
653 | 653 | if (($key == "user_agent") === false) { |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | $parsed_date = Carbon::parse($date); |
727 | 727 | } catch (Exception $_e) { |
728 | 728 | if (!isset($this->config["fallback_date"])) { |
729 | - throw new InvalidMessageDateException("Invalid message date. ID:" . $this->get("message_id") . " Date:" . $header->date . "/" . $date, 1100, $e); |
|
729 | + throw new InvalidMessageDateException("Invalid message date. ID:".$this->get("message_id")." Date:".$header->date."/".$date, 1100, $e); |
|
730 | 730 | } |
731 | 731 | $parsed_date = Carbon::parse($this->config["fallback_date"]); |
732 | 732 | } |
@@ -284,7 +284,9 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | foreach ($headers as $key => $values) { |
287 | - if (isset($imap_headers[$key])) continue; |
|
287 | + if (isset($imap_headers[$key])) { |
|
288 | + continue; |
|
289 | + } |
|
288 | 290 | $value = null; |
289 | 291 | switch ($key) { |
290 | 292 | case 'from': |
@@ -500,7 +502,9 @@ discard block |
||
500 | 502 | * Try to extract the priority from a given raw header string |
501 | 503 | */ |
502 | 504 | private function findPriority(): void { |
503 | - if (($priority = $this->get("x_priority")) === null) return; |
|
505 | + if (($priority = $this->get("x_priority")) === null) { |
|
506 | + return; |
|
507 | + } |
|
504 | 508 | switch ((int)"$priority") { |
505 | 509 | case IMAP::MESSAGE_PRIORITY_HIGHEST; |
506 | 510 | $priority = IMAP::MESSAGE_PRIORITY_HIGHEST; |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | public function findContentType(): void{ |
80 | 80 | $content_type = $this->header->get("content_type"); |
81 | 81 | $content_type = is_array($content_type) ? implode(' ', $content_type) : $content_type; |
82 | - if(stripos($content_type, 'multipart') === 0) { |
|
82 | + if (stripos($content_type, 'multipart') === 0) { |
|
83 | 83 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
84 | - }else{ |
|
84 | + }else { |
|
85 | 85 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
86 | 86 | } |
87 | 87 | } |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | * @throws InvalidMessageDateException |
119 | 119 | */ |
120 | 120 | private function detectParts(string $boundary, string $context, int $part_number = 0): array { |
121 | - $base_parts = explode( $boundary, $context); |
|
121 | + $base_parts = explode($boundary, $context); |
|
122 | 122 | $final_parts = []; |
123 | - foreach($base_parts as $ctx) { |
|
123 | + foreach ($base_parts as $ctx) { |
|
124 | 124 | $ctx = substr($ctx, 2); |
125 | 125 | if ($ctx !== "--" && $ctx != "") { |
126 | 126 | $parts = $this->parsePart($ctx, $part_number); |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * @throws InvalidMessageDateException |
143 | 143 | */ |
144 | 144 | public function find_parts(): array { |
145 | - if($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
146 | - if (($boundary = $this->header->getBoundary()) === null) { |
|
145 | + if ($this->type === IMAP::MESSAGE_TYPE_MULTIPART) { |
|
146 | + if (($boundary = $this->header->getBoundary()) === null) { |
|
147 | 147 | throw new MessageContentFetchingException("no content found", 0); |
148 | 148 | } |
149 | 149 |
@@ -81,7 +81,7 @@ |
||
81 | 81 | $content_type = is_array($content_type) ? implode(' ', $content_type) : $content_type; |
82 | 82 | if(stripos($content_type, 'multipart') === 0) { |
83 | 83 | $this->type = IMAP::MESSAGE_TYPE_MULTIPART; |
84 | - }else{ |
|
84 | + } else{ |
|
85 | 85 | $this->type = IMAP::MESSAGE_TYPE_TEXT; |
86 | 86 | } |
87 | 87 | } |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | public static function get(string $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 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function setConfig($config): self { |
176 | 176 | |
177 | - if(is_array($config) === false) { |
|
177 | + if (is_array($config) === false) { |
|
178 | 178 | $config = require $config; |
179 | 179 | } |
180 | 180 | |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | $vendor_config = require $path; |
185 | 185 | $config = $this->array_merge_recursive_distinct($vendor_config, $config); |
186 | 186 | |
187 | - if(is_array($config)){ |
|
188 | - if(isset($config['default'])){ |
|
189 | - if(isset($config['accounts']) && $config['default'] != false){ |
|
187 | + if (is_array($config)) { |
|
188 | + if (isset($config['default'])) { |
|
189 | + if (isset($config['accounts']) && $config['default'] != false) { |
|
190 | 190 | |
191 | 191 | $default_config = $vendor_config['accounts']['default']; |
192 | - if(isset($config['accounts'][$config['default']])){ |
|
192 | + if (isset($config['accounts'][$config['default']])) { |
|
193 | 193 | $default_config = array_merge($default_config, $config['accounts'][$config['default']]); |
194 | 194 | } |
195 | 195 | |
196 | - if(is_array($config['accounts'])){ |
|
197 | - foreach($config['accounts'] as $account_key => $account){ |
|
196 | + if (is_array($config['accounts'])) { |
|
197 | + foreach ($config['accounts'] as $account_key => $account) { |
|
198 | 198 | $config['accounts'][$account_key] = array_merge($default_config, $account); |
199 | 199 | } |
200 | 200 | } |
@@ -233,20 +233,20 @@ discard block |
||
233 | 233 | return array_keys($arr) !== range(0, count($arr) - 1); |
234 | 234 | }; |
235 | 235 | |
236 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
236 | + if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
237 | 237 | |
238 | - foreach($arrays as $append) { |
|
238 | + foreach ($arrays as $append) { |
|
239 | 239 | |
240 | - if(!is_array($append)) $append = array($append); |
|
240 | + if (!is_array($append)) $append = array($append); |
|
241 | 241 | |
242 | - foreach($append as $key => $value) { |
|
242 | + foreach ($append as $key => $value) { |
|
243 | 243 | |
244 | - if(!array_key_exists($key, $base) and !is_numeric($key)) { |
|
244 | + if (!array_key_exists($key, $base) and !is_numeric($key)) { |
|
245 | 245 | $base[$key] = $value; |
246 | 246 | continue; |
247 | 247 | } |
248 | 248 | |
249 | - if( |
|
249 | + if ( |
|
250 | 250 | ( |
251 | 251 | is_array($value) |
252 | 252 | && $isAssoc($value) |
@@ -260,9 +260,9 @@ discard block |
||
260 | 260 | // else merging $baseConfig['dispositions'] = ['attachment', 'inline'] with $customConfig['dispositions'] = ['attachment'] |
261 | 261 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
262 | 262 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
263 | - } else if(is_numeric($key)) { |
|
264 | - if(!in_array($value, $base)) $base[] = $value; |
|
265 | - } else { |
|
263 | + }else if (is_numeric($key)) { |
|
264 | + if (!in_array($value, $base)) $base[] = $value; |
|
265 | + }else { |
|
266 | 266 | $base[$key] = $value; |
267 | 267 | } |
268 | 268 |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | if($value === null) { |
81 | 81 | if(isset(self::$config[$part])) { |
82 | 82 | $value = self::$config[$part]; |
83 | - }else{ |
|
83 | + } else{ |
|
84 | 84 | break; |
85 | 85 | } |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | if(isset($value[$part])) { |
88 | 88 | $value = $value[$part]; |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
@@ -229,15 +229,21 @@ discard block |
||
229 | 229 | |
230 | 230 | // From https://stackoverflow.com/a/173479 |
231 | 231 | $isAssoc = function(array $arr): bool { |
232 | - if (array() === $arr) return false; |
|
232 | + if (array() === $arr) { |
|
233 | + return false; |
|
234 | + } |
|
233 | 235 | return array_keys($arr) !== range(0, count($arr) - 1); |
234 | 236 | }; |
235 | 237 | |
236 | - if(!is_array($base)) $base = empty($base) ? array() : array($base); |
|
238 | + if(!is_array($base)) { |
|
239 | + $base = empty($base) ? array() : array($base); |
|
240 | + } |
|
237 | 241 | |
238 | 242 | foreach($arrays as $append) { |
239 | 243 | |
240 | - if(!is_array($append)) $append = array($append); |
|
244 | + if(!is_array($append)) { |
|
245 | + $append = array($append); |
|
246 | + } |
|
241 | 247 | |
242 | 248 | foreach($append as $key => $value) { |
243 | 249 | |
@@ -261,7 +267,9 @@ discard block |
||
261 | 267 | // results in $resultConfig['dispositions'] = ['attachment', 'inline'] |
262 | 268 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $value); |
263 | 269 | } else if(is_numeric($key)) { |
264 | - if(!in_array($value, $base)) $base[] = $value; |
|
270 | + if(!in_array($value, $base)) { |
|
271 | + $base[] = $value; |
|
272 | + } |
|
265 | 273 | } else { |
266 | 274 | $base[$key] = $value; |
267 | 275 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $value = $this->default_account_config[$key]; |
206 | 206 | if(isset($config[$key])) { |
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + } elseif(isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -237,39 +237,39 @@ discard block |
||
237 | 237 | if(isset($config['masks']['message'])) { |
238 | 238 | if(class_exists($config['masks']['message'])) { |
239 | 239 | $this->default_message_mask = $config['masks']['message']; |
240 | - }else{ |
|
240 | + } else{ |
|
241 | 241 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
242 | 242 | } |
243 | - }else{ |
|
243 | + } else{ |
|
244 | 244 | if(class_exists($default_config['message'])) { |
245 | 245 | $this->default_message_mask = $default_config['message']; |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
248 | 248 | } |
249 | 249 | } |
250 | 250 | if(isset($config['masks']['attachment'])) { |
251 | 251 | if(class_exists($config['masks']['attachment'])) { |
252 | 252 | $this->default_attachment_mask = $config['masks']['attachment']; |
253 | - }else{ |
|
253 | + } else{ |
|
254 | 254 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
255 | 255 | } |
256 | - }else{ |
|
256 | + } else{ |
|
257 | 257 | if(class_exists($default_config['attachment'])) { |
258 | 258 | $this->default_attachment_mask = $default_config['attachment']; |
259 | - }else{ |
|
259 | + } else{ |
|
260 | 260 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
261 | 261 | } |
262 | 262 | } |
263 | - }else{ |
|
263 | + } else{ |
|
264 | 264 | if(class_exists($default_config['message'])) { |
265 | 265 | $this->default_message_mask = $default_config['message']; |
266 | - }else{ |
|
266 | + } else{ |
|
267 | 267 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
268 | 268 | } |
269 | 269 | |
270 | 270 | if(class_exists($default_config['attachment'])) { |
271 | 271 | $this->default_attachment_mask = $default_config['attachment']; |
272 | - }else{ |
|
272 | + } else{ |
|
273 | 273 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
274 | 274 | } |
275 | 275 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
334 | 334 | $this->connection->setConnectionTimeout($this->timeout); |
335 | 335 | $this->connection->setProxy($this->proxy); |
336 | - }else{ |
|
336 | + } else{ |
|
337 | 337 | if (extension_loaded('imap') === false) { |
338 | 338 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
339 | 339 | } |
@@ -516,7 +516,9 @@ discard block |
||
516 | 516 | $this->checkConnection(); |
517 | 517 | $status = $this->connection->createFolder($folder); |
518 | 518 | |
519 | - if($expunge) $this->expunge(); |
|
519 | + if($expunge) { |
|
520 | + $this->expunge(); |
|
521 | + } |
|
520 | 522 | |
521 | 523 | $folder = $this->getFolder($folder); |
522 | 524 | if($status && $folder) { |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | */ |
204 | 204 | private function setAccountConfig(string $key, array $config, array $default_config): void { |
205 | 205 | $value = $this->default_account_config[$key]; |
206 | - if(isset($config[$key])) { |
|
206 | + if (isset($config[$key])) { |
|
207 | 207 | $value = $config[$key]; |
208 | - }elseif(isset($default_config[$key])) { |
|
208 | + }elseif (isset($default_config[$key])) { |
|
209 | 209 | $value = $default_config[$key]; |
210 | 210 | } |
211 | 211 | $this->$key = $value; |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | */ |
218 | 218 | protected function setEventsFromConfig($config): void { |
219 | 219 | $events = ClientManager::get("events"); |
220 | - if(isset($config['events'])){ |
|
221 | - foreach($config['events'] as $section => $events) { |
|
220 | + if (isset($config['events'])) { |
|
221 | + foreach ($config['events'] as $section => $events) { |
|
222 | 222 | $events[$section] = array_merge($events[$section], $events); |
223 | 223 | } |
224 | 224 | } |
@@ -232,45 +232,45 @@ discard block |
||
232 | 232 | * @throws MaskNotFoundException |
233 | 233 | */ |
234 | 234 | protected function setMaskFromConfig($config): void { |
235 | - $default_config = ClientManager::get("masks"); |
|
235 | + $default_config = ClientManager::get("masks"); |
|
236 | 236 | |
237 | - if(isset($config['masks'])){ |
|
238 | - if(isset($config['masks']['message'])) { |
|
239 | - if(class_exists($config['masks']['message'])) { |
|
237 | + if (isset($config['masks'])) { |
|
238 | + if (isset($config['masks']['message'])) { |
|
239 | + if (class_exists($config['masks']['message'])) { |
|
240 | 240 | $this->default_message_mask = $config['masks']['message']; |
241 | - }else{ |
|
241 | + }else { |
|
242 | 242 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['message']); |
243 | 243 | } |
244 | - }else{ |
|
245 | - if(class_exists($default_config['message'])) { |
|
244 | + }else { |
|
245 | + if (class_exists($default_config['message'])) { |
|
246 | 246 | $this->default_message_mask = $default_config['message']; |
247 | - }else{ |
|
247 | + }else { |
|
248 | 248 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
249 | 249 | } |
250 | 250 | } |
251 | - if(isset($config['masks']['attachment'])) { |
|
252 | - if(class_exists($config['masks']['attachment'])) { |
|
251 | + if (isset($config['masks']['attachment'])) { |
|
252 | + if (class_exists($config['masks']['attachment'])) { |
|
253 | 253 | $this->default_attachment_mask = $config['masks']['attachment']; |
254 | - }else{ |
|
254 | + }else { |
|
255 | 255 | throw new MaskNotFoundException("Unknown mask provided: ".$config['masks']['attachment']); |
256 | 256 | } |
257 | - }else{ |
|
258 | - if(class_exists($default_config['attachment'])) { |
|
257 | + }else { |
|
258 | + if (class_exists($default_config['attachment'])) { |
|
259 | 259 | $this->default_attachment_mask = $default_config['attachment']; |
260 | - }else{ |
|
260 | + }else { |
|
261 | 261 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
262 | 262 | } |
263 | 263 | } |
264 | - }else{ |
|
265 | - if(class_exists($default_config['message'])) { |
|
264 | + }else { |
|
265 | + if (class_exists($default_config['message'])) { |
|
266 | 266 | $this->default_message_mask = $default_config['message']; |
267 | - }else{ |
|
267 | + }else { |
|
268 | 268 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['message']); |
269 | 269 | } |
270 | 270 | |
271 | - if(class_exists($default_config['attachment'])) { |
|
271 | + if (class_exists($default_config['attachment'])) { |
|
272 | 272 | $this->default_attachment_mask = $default_config['attachment']; |
273 | - }else{ |
|
273 | + }else { |
|
274 | 274 | throw new MaskNotFoundException("Unknown mask provided: ".$default_config['attachment']); |
275 | 275 | } |
276 | 276 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $this->connection = new ImapProtocol($this->validate_cert, $this->encryption); |
335 | 335 | $this->connection->setConnectionTimeout($this->timeout); |
336 | 336 | $this->connection->setProxy($this->proxy); |
337 | - }else{ |
|
337 | + }else { |
|
338 | 338 | if (extension_loaded('imap') === false) { |
339 | 339 | throw new ConnectionFailedException("connection setup failed", 0, new ProtocolNotSupportedException($protocol." is an unsupported protocol")); |
340 | 340 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | try { |
357 | 357 | $this->connection->connect($this->host, $this->port); |
358 | - } catch (ErrorException|Exceptions\RuntimeException $e) { |
|
358 | + } catch (ErrorException | Exceptions\RuntimeException $e) { |
|
359 | 359 | throw new ConnectionFailedException("connection setup failed", 0, $e); |
360 | 360 | } |
361 | 361 | $this->authenticate(); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | // Set delimiter to false to force selection via getFolderByName (maybe useful for uncommon folder names) |
415 | 415 | $delimiter = is_null($delimiter) ? ClientManager::get('options.delimiter', "/") : $delimiter; |
416 | - if (strpos($folder_name, (string)$delimiter) !== false) { |
|
416 | + if (strpos($folder_name, (string) $delimiter) !== false) { |
|
417 | 417 | return $this->getFolderByPath($folder_name); |
418 | 418 | } |
419 | 419 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | $pattern = $parent_folder.($hierarchical ? '%' : '*'); |
466 | 466 | $items = $this->connection->folders('', $pattern); |
467 | 467 | |
468 | - if(is_array($items)){ |
|
468 | + if (is_array($items)) { |
|
469 | 469 | foreach ($items as $folder_name => $item) { |
470 | 470 | $folder = new Folder($this, $folder_name, $item["delimiter"], $item["flags"]); |
471 | 471 | |
@@ -517,10 +517,10 @@ discard block |
||
517 | 517 | $this->checkConnection(); |
518 | 518 | $status = $this->connection->createFolder($folder); |
519 | 519 | |
520 | - if($expunge) $this->expunge(); |
|
520 | + if ($expunge) $this->expunge(); |
|
521 | 521 | |
522 | 522 | $folder = $this->getFolder($folder); |
523 | - if($status && $folder) { |
|
523 | + if ($status && $folder) { |
|
524 | 524 | $event = $this->getEvent("folder", "new"); |
525 | 525 | $event::dispatch($folder); |
526 | 526 | } |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * @throws MaskNotFoundException |
649 | 649 | */ |
650 | 650 | public function setDefaultMessageMask(string $mask): self { |
651 | - if(class_exists($mask)) { |
|
651 | + if (class_exists($mask)) { |
|
652 | 652 | $this->default_message_mask = $mask; |
653 | 653 | |
654 | 654 | return $this; |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @throws MaskNotFoundException |
675 | 675 | */ |
676 | 676 | public function setDefaultAttachmentMask(string $mask): self { |
677 | - if(class_exists($mask)) { |
|
677 | + if (class_exists($mask)) { |
|
678 | 678 | $this->default_attachment_mask = $mask; |
679 | 679 | |
680 | 680 | return $this; |
@@ -246,7 +246,7 @@ |
||
246 | 246 | if (is_numeric($uid)) { |
247 | 247 | return ""; |
248 | 248 | } |
249 | - return (string)$uid; |
|
249 | + return (string) $uid; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | public function buildUIDCommand($command, $uid) : string { |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | throw new AuthFailedException($message); |
89 | 89 | } |
90 | 90 | |
91 | - if(!$this->stream) { |
|
91 | + if (!$this->stream) { |
|
92 | 92 | $errors = \imap_errors(); |
93 | 93 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
94 | 94 | throw new AuthFailedException($message); |
95 | 95 | } |
96 | 96 | |
97 | 97 | $errors = \imap_errors(); |
98 | - if(is_array($errors)) { |
|
98 | + if (is_array($errors)) { |
|
99 | 99 | $status = $this->examineFolder(); |
100 | - if($status['exists'] !== 0) { |
|
100 | + if ($status['exists'] !== 0) { |
|
101 | 101 | $message = implode("; ", (is_array($errors) ? $errors : array())); |
102 | 102 | throw new RuntimeException($message); |
103 | 103 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | if (!$this->cert_validation) { |
129 | 129 | $address .= '/novalidate-cert'; |
130 | 130 | } |
131 | - if (in_array($this->encryption,['tls', 'notls', 'ssl'])) { |
|
131 | + if (in_array($this->encryption, ['tls', 'notls', 'ssl'])) { |
|
132 | 132 | $address .= '/'.$this->encryption; |
133 | 133 | } elseif ($this->encryption === "starttls") { |
134 | 134 | $address .= '/tls'; |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | |
287 | 287 | $overview = $this->overview("1:*"); |
288 | 288 | $uids = []; |
289 | - foreach($overview as $set){ |
|
289 | + foreach ($overview as $set) { |
|
290 | 290 | $uids[$set->msgno] = $set->uid; |
291 | 291 | } |
292 | 292 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return array |
316 | 316 | */ |
317 | 317 | public function overview(string $sequence, $uid = IMAP::ST_UID): array { |
318 | - return \imap_fetch_overview($this->stream, $sequence,$uid ? IMAP::ST_UID : IMAP::NIL); |
|
318 | + return \imap_fetch_overview($this->stream, $sequence, $uid ? IMAP::ST_UID : IMAP::NIL); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | $result = []; |
331 | 331 | |
332 | 332 | $items = \imap_getmailboxes($this->stream, $this->getAddress(), $reference.$folder); |
333 | - if(is_array($items)){ |
|
333 | + if (is_array($items)) { |
|
334 | 334 | foreach ($items as $item) { |
335 | 335 | $name = $this->decodeFolderName($item->name); |
336 | 336 | $result[$name] = ['delimiter' => $item->delimiter, 'flags' => []]; |
337 | 337 | } |
338 | - }else{ |
|
338 | + }else { |
|
339 | 339 | throw new RuntimeException(\imap_last_error()); |
340 | 340 | } |
341 | 341 | |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | public function store(array $flags, int $from, $to = null, $mode = null, bool $silent = true, $uid = IMAP::ST_UID, $item = null) { |
359 | 359 | $flag = trim(is_array($flags) ? implode(" ", $flags) : $flags); |
360 | 360 | |
361 | - if ($mode == "+"){ |
|
361 | + if ($mode == "+") { |
|
362 | 362 | $status = \imap_setflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
363 | - }else{ |
|
363 | + }else { |
|
364 | 364 | $status = \imap_clearflag_full($this->stream, $from, $flag, $uid ? IMAP::ST_UID : IMAP::NIL); |
365 | 365 | } |
366 | 366 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | */ |
383 | 383 | public function appendMessage(string $folder, string $message, $flags = null, $date = null): bool { |
384 | 384 | if ($date != null) { |
385 | - if ($date instanceof \Carbon\Carbon){ |
|
385 | + if ($date instanceof \Carbon\Carbon) { |
|
386 | 386 | $date = $date->format('d-M-Y H:i:s O'); |
387 | 387 | } |
388 | 388 | return \imap_append($this->stream, $folder, $message, $flags, $date); |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | * @return array|bool Tokens if operation successful, false if an error occurred |
415 | 415 | */ |
416 | 416 | public function copyManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
417 | - foreach($messages as $msg) { |
|
417 | + foreach ($messages as $msg) { |
|
418 | 418 | if ($this->copyMessage($folder, $msg, null, $uid) == false) { |
419 | 419 | return false; |
420 | 420 | } |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | * @return array|bool Tokens if operation successful, false if an error occurred |
447 | 447 | */ |
448 | 448 | public function moveManyMessages(array $messages, string $folder, $uid = IMAP::ST_UID) { |
449 | - foreach($messages as $msg) { |
|
449 | + foreach ($messages as $msg) { |
|
450 | 450 | if ($this->moveMessage($folder, $msg, null, $uid) == false) { |
451 | 451 | return false; |
452 | 452 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $stack = []; |
152 | 152 | |
153 | 153 | // replace any trailing <NL> including spaces with a single space |
154 | - $line = rtrim($line) . ' '; |
|
154 | + $line = rtrim($line).' '; |
|
155 | 155 | while (($pos = strpos($line, ' ')) !== false) { |
156 | 156 | $token = substr($line, 0, $pos); |
157 | 157 | if (!strlen($token)) { |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | if (strlen($token) > $chars) { |
182 | 182 | $line = substr($token, $chars); |
183 | 183 | $token = substr($token, 0, $chars); |
184 | - } else { |
|
184 | + }else { |
|
185 | 185 | $line .= $this->nextLine(); |
186 | 186 | } |
187 | 187 | $tokens[] = $token; |
188 | - $line = trim($line) . ' '; |
|
188 | + $line = trim($line).' '; |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $line = $this->nextTaggedLine($tag); // get next tag |
236 | 236 | if (!$dontParse) { |
237 | 237 | $tokens = $this->decodeLine($line); |
238 | - } else { |
|
238 | + }else { |
|
239 | 239 | $tokens = $line; |
240 | 240 | } |
241 | 241 | if ($this->debug) echo "<< ".$line."\n"; |
@@ -287,27 +287,27 @@ discard block |
||
287 | 287 | public function sendRequest(string $command, array $tokens = [], ?string &$tag = null): void { |
288 | 288 | if (!$tag) { |
289 | 289 | $this->noun++; |
290 | - $tag = 'TAG' . $this->noun; |
|
290 | + $tag = 'TAG'.$this->noun; |
|
291 | 291 | } |
292 | 292 | |
293 | - $line = $tag . ' ' . $command; |
|
293 | + $line = $tag.' '.$command; |
|
294 | 294 | |
295 | 295 | foreach ($tokens as $token) { |
296 | 296 | if (is_array($token)) { |
297 | - if (fwrite($this->stream, $line . ' ' . $token[0] . "\r\n") === false) { |
|
297 | + if (fwrite($this->stream, $line.' '.$token[0]."\r\n") === false) { |
|
298 | 298 | throw new RuntimeException('failed to write - connection closed?'); |
299 | 299 | } |
300 | 300 | if (!$this->assumedNextLine('+ ')) { |
301 | 301 | throw new RuntimeException('failed to send literal string'); |
302 | 302 | } |
303 | 303 | $line = $token[1]; |
304 | - } else { |
|
305 | - $line .= ' ' . $token; |
|
304 | + }else { |
|
305 | + $line .= ' '.$token; |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | if ($this->debug) echo ">> ".$line."\n"; |
309 | 309 | |
310 | - if (fwrite($this->stream, $line . "\r\n") === false) { |
|
310 | + if (fwrite($this->stream, $line."\r\n") === false) { |
|
311 | 311 | throw new RuntimeException('failed to write - connection closed?'); |
312 | 312 | } |
313 | 313 | } |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | public function escapeString($string) { |
338 | 338 | if (func_num_args() < 2) { |
339 | 339 | if (strpos($string, "\n") !== false) { |
340 | - return ['{' . strlen($string) . '}', $string]; |
|
340 | + return ['{'.strlen($string).'}', $string]; |
|
341 | 341 | } |
342 | - return '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $string) . '"'; |
|
342 | + return '"'.str_replace(['\\', '"'], ['\\\\', '\\"'], $string).'"'; |
|
343 | 343 | } |
344 | 344 | $result = []; |
345 | 345 | foreach (func_get_args() as $string) { |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | } |
364 | 364 | $result[] = $this->escapeList($v); |
365 | 365 | } |
366 | - return '(' . implode(' ', $result) . ')'; |
|
366 | + return '('.implode(' ', $result).')'; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | error_log("got an extra server challenge: $response"); |
405 | 405 | // respond with an empty response. |
406 | 406 | $this->sendRequest(''); |
407 | - } else { |
|
407 | + }else { |
|
408 | 408 | if (preg_match('/^NO /i', $response) || |
409 | 409 | preg_match('/^BAD /i', $response)) { |
410 | 410 | error_log("got failure response: $response"); |
@@ -491,10 +491,10 @@ discard block |
||
491 | 491 | $result[strtolower($tokens[1])] = $tokens[0]; |
492 | 492 | break; |
493 | 493 | case '[UIDVALIDITY': |
494 | - $result['uidvalidity'] = (int)$tokens[2]; |
|
494 | + $result['uidvalidity'] = (int) $tokens[2]; |
|
495 | 495 | break; |
496 | 496 | case '[UIDNEXT': |
497 | - $result['uidnext'] = (int)$tokens[2]; |
|
497 | + $result['uidnext'] = (int) $tokens[2]; |
|
498 | 498 | break; |
499 | 499 | default: |
500 | 500 | // ignore |
@@ -551,14 +551,14 @@ discard block |
||
551 | 551 | if (is_array($from)) { |
552 | 552 | $set = implode(',', $from); |
553 | 553 | } elseif ($to === null) { |
554 | - $set = (int)$from; |
|
554 | + $set = (int) $from; |
|
555 | 555 | } elseif ($to === INF) { |
556 | - $set = (int)$from . ':*'; |
|
557 | - } else { |
|
558 | - $set = (int)$from . ':' . (int)$to; |
|
556 | + $set = (int) $from.':*'; |
|
557 | + }else { |
|
558 | + $set = (int) $from.':'.(int) $to; |
|
559 | 559 | } |
560 | 560 | |
561 | - $items = (array)$items; |
|
561 | + $items = (array) $items; |
|
562 | 562 | $itemList = $this->escapeList($items); |
563 | 563 | |
564 | 564 | $this->sendRequest($this->buildUIDCommand("FETCH", $uid), [$set, $itemList], $tag); |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | $count = is_countable($tokens[2]) ? count($tokens[2]) : 0; |
577 | 577 | if ($tokens[2][$count - 2] == 'UID') { |
578 | 578 | $uidKey = $count - 1; |
579 | - } else if ($tokens[2][0] == 'UID') { |
|
579 | + }else if ($tokens[2][0] == 'UID') { |
|
580 | 580 | $uidKey = 1; |
581 | - } else { |
|
581 | + }else { |
|
582 | 582 | $uidKey = array_search('UID', $tokens[2]) + 1; |
583 | 583 | } |
584 | 584 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $data = $tokens[2][1]; |
596 | 596 | } elseif ($uid && $tokens[2][2] == $items[0]) { |
597 | 597 | $data = $tokens[2][3]; |
598 | - } else { |
|
598 | + }else { |
|
599 | 599 | // maybe the server send an other field we didn't wanted |
600 | 600 | $count = is_countable($tokens[2]) ? count($tokens[2]) : 0; |
601 | 601 | // we start with 2, because 0 was already checked |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | break; |
608 | 608 | } |
609 | 609 | } |
610 | - } else { |
|
610 | + }else { |
|
611 | 611 | $data = []; |
612 | 612 | while (key($tokens[2]) !== null) { |
613 | 613 | $data[current($tokens[2])] = next($tokens[2]); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } |
625 | 625 | if ($uid) { |
626 | 626 | $result[$tokens[2][$uidKey]] = $data; |
627 | - }else{ |
|
627 | + }else { |
|
628 | 628 | $result[$tokens[0]] = $data; |
629 | 629 | } |
630 | 630 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | |
691 | 691 | if ($this->enable_uid_cache && $this->uid_cache) { |
692 | 692 | $uids = $this->uid_cache; |
693 | - } else { |
|
693 | + }else { |
|
694 | 694 | try { |
695 | 695 | $uids = $this->fetch('UID', 1, INF); |
696 | 696 | $this->setUidCache($uids); // set cache for this folder |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | $response = $this->requestAndResponse($command, [$set, $item, $flags], $silent); |
791 | 791 | |
792 | 792 | if ($silent) { |
793 | - return (bool)$response; |
|
793 | + return (bool) $response; |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | $result = []; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | $ids = []; |
1095 | 1095 | foreach ($uids as $msgn => $v) { |
1096 | 1096 | $id = $uid ? $v : $msgn; |
1097 | - if ( ($to >= $id && $from <= $id) || ($to === "*" && $from <= $id) ){ |
|
1097 | + if (($to >= $id && $from <= $id) || ($to === "*" && $from <= $id)) { |
|
1098 | 1098 | $ids[] = $id; |
1099 | 1099 | } |
1100 | 1100 | } |
@@ -1127,10 +1127,10 @@ discard block |
||
1127 | 1127 | * @return int|string |
1128 | 1128 | */ |
1129 | 1129 | public function buildSet($from, $to = null) { |
1130 | - $set = (int)$from; |
|
1130 | + $set = (int) $from; |
|
1131 | 1131 | if ($to === null) { |
1132 | 1132 | return $set; |
1133 | 1133 | } |
1134 | - return $set . ':' . ($to == INF ? '*' : (int)$to); |
|
1134 | + return $set.':'.($to == INF ? '*' : (int) $to); |
|
1135 | 1135 | } |
1136 | 1136 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | protected function parse(): void { |
160 | 160 | if ($this->header === null) { |
161 | 161 | $body = $this->findHeaders(); |
162 | - }else{ |
|
162 | + }else { |
|
163 | 163 | $body = $this->raw; |
164 | 164 | } |
165 | 165 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $this->name = $this->header->get("name"); |
172 | 172 | $this->filename = $this->header->get("filename"); |
173 | 173 | |
174 | - if(!empty($this->header->get("id"))) { |
|
174 | + if (!empty($this->header->get("id"))) { |
|
175 | 175 | $this->id = $this->header->get("id"); |
176 | - } else if(!empty($this->header->get("x_attachment_id"))){ |
|
176 | + }else if (!empty($this->header->get("x_attachment_id"))) { |
|
177 | 177 | $this->id = $this->header->get("x_attachment_id"); |
178 | - } else if(!empty($this->header->get("content_id"))){ |
|
178 | + }else if (!empty($this->header->get("content_id"))) { |
|
179 | 179 | $this->id = strtr($this->header->get("content_id"), [ |
180 | 180 | '<' => '', |
181 | 181 | '>' => '' |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | } |
184 | 184 | |
185 | 185 | $content_types = $this->header->get("content_type"); |
186 | - if(!empty($content_types)){ |
|
186 | + if (!empty($content_types)) { |
|
187 | 187 | $this->subtype = $this->parseSubtype($content_types); |
188 | 188 | $content_type = $content_types; |
189 | 189 | if (is_array($content_types)) { |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return string |
225 | 225 | */ |
226 | - private function parseSubtype($content_type){ |
|
226 | + private function parseSubtype($content_type) { |
|
227 | 227 | if (is_array($content_type)) { |
228 | - foreach ($content_type as $part){ |
|
229 | - if ((strpos($part, "/")) !== false){ |
|
228 | + foreach ($content_type as $part) { |
|
229 | + if ((strpos($part, "/")) !== false) { |
|
230 | 230 | return $this->parseSubtype($part); |
231 | 231 | } |
232 | 232 | } |
233 | 233 | return null; |
234 | 234 | } |
235 | - if (($pos = strpos($content_type, "/")) !== false){ |
|
235 | + if (($pos = strpos($content_type, "/")) !== false) { |
|
236 | 236 | return substr($content_type, $pos + 1); |
237 | 237 | } |
238 | 238 | return null; |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | */ |
244 | 244 | private function parseDisposition(): void { |
245 | 245 | $content_disposition = $this->header->get("content_disposition"); |
246 | - if($content_disposition !== null) { |
|
246 | + if ($content_disposition !== null) { |
|
247 | 247 | $this->ifdisposition = true; |
248 | 248 | $this->disposition = (is_array($content_disposition)) ? implode(' ', $content_disposition) : $content_disposition; |
249 | 249 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | private function parseDescription(): void { |
256 | 256 | $content_description = $this->header->get("content_description"); |
257 | - if($content_description !== null) { |
|
257 | + if ($content_description !== null) { |
|
258 | 258 | $this->ifdescription = true; |
259 | 259 | $this->description = $content_description; |
260 | 260 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | private function parseEncoding(): void { |
267 | 267 | $encoding = $this->header->get("content_transfer_encoding"); |
268 | - if($encoding !== null) { |
|
268 | + if ($encoding !== null) { |
|
269 | 269 | switch (strtolower($encoding)) { |
270 | 270 | case "quoted-printable": |
271 | 271 | $this->encoding = IMAP::MESSAGE_ENC_QUOTED_PRINTABLE; |
@@ -159,7 +159,7 @@ |
||
159 | 159 | protected function parse(): void { |
160 | 160 | if ($this->header === null) { |
161 | 161 | $body = $this->findHeaders(); |
162 | - }else{ |
|
162 | + } else{ |
|
163 | 163 | $body = $this->raw; |
164 | 164 | } |
165 | 165 |