@@ -32,7 +32,8 @@ |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - /** @return bool|bool[] */ |
|
| 35 | + /** @param boolean $clear |
|
| 36 | +/** @return bool|bool[] */ |
|
| 36 | 37 | protected function flags( $flags, $clear ) { |
| 37 | 38 | $cb = [$this->mailbox()->imap(), $clear ? 'unflag' : 'flag']; |
| 38 | 39 | |
@@ -179,7 +179,7 @@ |
||
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | if ( $bytes = $part->parameter('bytes') ) { |
| 182 | - $name .= ' (' . number_format($bytes/1024, 1) . 'kb)'; |
|
| 182 | + $name .= ' (' . number_format($bytes / 1024, 1) . 'kb)'; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | $parts[] = $name; |
@@ -33,13 +33,14 @@ discard block |
||
| 33 | 33 | return $parts; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - /** @return IMAPMessagePartInterface */ |
|
| 36 | + /** @param integer $index |
|
| 37 | +/** @return IMAPMessagePartInterface */ |
|
| 37 | 38 | public function part( $index ) { |
| 38 | 39 | $parts = $this->parts(); |
| 39 | 40 | return @$parts[$index]; |
| 40 | 41 | } |
| 41 | 42 | |
| 42 | - /** @return array */ |
|
| 43 | + /** @return string */ |
|
| 43 | 44 | public function parameters() { |
| 44 | 45 | if ( empty($this->parameters) ) { |
| 45 | 46 | $structure = $this->structure(); |
@@ -57,7 +58,8 @@ discard block |
||
| 57 | 58 | return $this->parameters; |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | - /** @return mixed */ |
|
| 61 | + /** @param string $name |
|
| 62 | +/** @return mixed */ |
|
| 61 | 63 | public function parameter( $name ) { |
| 62 | 64 | $parameters = $this->parameters(); |
| 63 | 65 | $structure = $this->structure(); |
@@ -80,7 +82,8 @@ discard block |
||
| 80 | 82 | return $this->headers; |
| 81 | 83 | } |
| 82 | 84 | |
| 83 | - /** @return string|string[] */ |
|
| 85 | + /** @param string $name |
|
| 86 | +/** @return string|string[] */ |
|
| 84 | 87 | public function header( $name ) { |
| 85 | 88 | $headers = $this->headers(); |
| 86 | 89 | $header = $headers[strtolower($name)] ?? [null]; |
@@ -106,7 +109,9 @@ discard block |
||
| 106 | 109 | } |
| 107 | 110 | } |
| 108 | 111 | |
| 109 | - /** @return string */ |
|
| 112 | + /** @param string[] $subtypes |
|
| 113 | +/** @return string |
|
| 114 | +* @param boolean $recursive */ |
|
| 110 | 115 | public function subtypeContent( $subtypes, $recursive ) { |
| 111 | 116 | if ( $part = $this->subtypePart($subtypes, $recursive) ) { |
| 112 | 117 | return $part->content(); |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | $this->parameters['bytes'] = @$structure->bytes; |
| 48 | 48 | |
| 49 | 49 | foreach ( (array) @$structure->parameters as $param ) { |
| 50 | - $this->parameters[ strtolower($param->attribute) ] = $param->value; |
|
| 50 | + $this->parameters[strtolower($param->attribute)] = $param->value; |
|
| 51 | 51 | } |
| 52 | 52 | foreach ( (array) @$structure->dparameters as $param ) { |
| 53 | - $this->parameters[ strtolower($param->attribute) ] = $param->value; |
|
| 53 | + $this->parameters[strtolower($param->attribute)] = $param->value; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function parameter( $name ) { |
| 62 | 62 | $parameters = $this->parameters(); |
| 63 | 63 | $structure = $this->structure(); |
| 64 | - return @$parameters[ strtolower($name) ] ?: @$structure->$name; |
|
| 64 | + return @$parameters[strtolower($name)] ?: @$structure->$name; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** @return string[] */ |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $headers = array_map('mb_decode_mimeheader', $headers); |
| 72 | 72 | |
| 73 | 73 | $this->headers = []; |
| 74 | - foreach ($headers as $header) { |
|
| 74 | + foreach ( $headers as $header ) { |
|
| 75 | 75 | $x = explode(':', $header, 2); |
| 76 | - $this->headers[ trim(strtolower($x[0])) ][] = trim($x[1]); |
|
| 76 | + $this->headers[trim(strtolower($x[0]))][] = trim($x[1]); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $parts = $recursive ? $this->allParts() : $this->parts(); |
| 95 | 95 | array_unshift($parts, $this); |
| 96 | 96 | |
| 97 | - return array_values(array_filter($parts, function(IMAPMessagePartInterface $part) use ($subtypes) { |
|
| 97 | + return array_values(array_filter($parts, function( IMAPMessagePartInterface $part ) use ($subtypes) { |
|
| 98 | 98 | return in_array($part->subtype(), $subtypes); |
| 99 | 99 | })); |
| 100 | 100 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | /** @return string */ |
| 59 | 59 | public function safeFilename() { |
| 60 | - if ($filename = $this->filename()) { |
|
| 60 | + if ( $filename = $this->filename() ) { |
|
| 61 | 61 | return trim(preg_replace('#_+#', '_', preg_replace('#[^a-z0-9\-_\.]+#i', '', $filename)), '_'); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | /** @return string */ |
| 74 | 74 | public function decodedContent() { |
| 75 | - if ($raw = $this->content()) { |
|
| 76 | - switch ($this->parameter('encoding')) { |
|
| 75 | + if ( $raw = $this->content() ) { |
|
| 76 | + switch ( $this->parameter('encoding') ) { |
|
| 77 | 77 | case ENC7BIT: |
| 78 | 78 | case ENC8BIT: |
| 79 | 79 | case ENCQUOTEDPRINTABLE: |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | /** @return string */ |
| 91 | 91 | public function headerString() { |
| 92 | - if ($this->subtype() == 'RFC822') { |
|
| 92 | + if ( $this->subtype() == 'RFC822' ) { |
|
| 93 | 93 | $x = explode("\r\n\r\n", $this->content()); |
| 94 | 94 | return trim($x[0]); |
| 95 | 95 | } |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** @return bool */ |
| 101 | - public function saveAttachment($dir, $filenameOverride = null) { |
|
| 102 | - if ($filename = $this->safeFilename()) { |
|
| 101 | + public function saveAttachment( $dir, $filenameOverride = null ) { |
|
| 102 | + if ( $filename = $this->safeFilename() ) { |
|
| 103 | 103 | $filepath = realpath($dir) . '/' . ($filenameOverride ?? $filename); |
| 104 | - if (file_put_contents($filepath, $this->decodedContent())) { |
|
| 104 | + if ( file_put_contents($filepath, $this->decodedContent()) ) { |
|
| 105 | 105 | return true; |
| 106 | 106 | } |
| 107 | 107 | } |