@@ -69,7 +69,7 @@ |
||
| 69 | 69 | protected function iteratorToLowercaseArray( $iterator ) { |
| 70 | 70 | $data = []; |
| 71 | 71 | foreach ( $iterator as $name => $value ) { |
| 72 | - $data[ strtolower($name) ] = $value; |
|
| 72 | + $data[strtolower($name)] = $value; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return $data; |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( $options['limit'] && isset($messages[ $options['limit'] - 1 ]) ) { |
|
| 98 | + if ( $options['limit'] && isset($messages[$options['limit'] - 1]) ) { |
|
| 99 | 99 | break; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -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: |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** @return bool */ |
| 91 | - public function saveAttachment($dir, $filenameOverride = null) { |
|
| 92 | - if ($filename = $this->safeFilename()) { |
|
| 91 | + public function saveAttachment( $dir, $filenameOverride = null ) { |
|
| 92 | + if ( $filename = $this->safeFilename() ) { |
|
| 93 | 93 | $filepath = realpath($dir) . '/' . ($filenameOverride ?? $filename); |
| 94 | - if (file_put_contents($filepath, $this->decodedContent())) { |
|
| 94 | + if ( file_put_contents($filepath, $this->decodedContent()) ) { |
|
| 95 | 95 | return true; |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -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; |
@@ -36,13 +36,14 @@ discard block |
||
| 36 | 36 | return $parts; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - /** @return IMAPMessagePart */ |
|
| 39 | + /** @param integer $index |
|
| 40 | +/** @return IMAPMessagePart */ |
|
| 40 | 41 | public function part( $index ) { |
| 41 | 42 | $parts = $this->parts(); |
| 42 | 43 | return @$parts[$index]; |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | - /** @return array */ |
|
| 46 | + /** @return string */ |
|
| 46 | 47 | public function parameters() { |
| 47 | 48 | if ( $this->parameters === null ) { |
| 48 | 49 | $this->parameters = []; |
@@ -61,14 +62,15 @@ discard block |
||
| 61 | 62 | return $this->parameters; |
| 62 | 63 | } |
| 63 | 64 | |
| 64 | - /** @return mixed */ |
|
| 65 | + /** @param string $name |
|
| 66 | +/** @return mixed */ |
|
| 65 | 67 | public function parameter( $name ) { |
| 66 | 68 | $parameters = $this->parameters(); |
| 67 | 69 | $structure = $this->structure(); |
| 68 | 70 | return @$parameters[ strtolower($name) ] ?: @$structure->$name; |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | - /** @return string[][] */ |
|
| 73 | + /** @return string */ |
|
| 72 | 74 | public function headers() { |
| 73 | 75 | if ( $this->headers === null ) { |
| 74 | 76 | $header = $this->headerString(); |
@@ -89,7 +91,8 @@ discard block |
||
| 89 | 91 | return $this->headers; |
| 90 | 92 | } |
| 91 | 93 | |
| 92 | - /** @return string|string[] */ |
|
| 94 | + /** @param string $name |
|
| 95 | +/** @return string|string[] */ |
|
| 93 | 96 | public function header( $name ) { |
| 94 | 97 | $headers = $this->headers(); |
| 95 | 98 | $header = $headers[strtolower($name)] ?? [null]; |
@@ -115,7 +118,9 @@ discard block |
||
| 115 | 118 | } |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | - /** @return string */ |
|
| 121 | + /** @param string[] $subtypes |
|
| 122 | +/** @return string |
|
| 123 | +* @param boolean $recursive */ |
|
| 119 | 124 | public function subtypeContent( $subtypes, $recursive ) { |
| 120 | 125 | if ( $part = $this->subtypePart($subtypes, $recursive) ) { |
| 121 | 126 | return $part->content(); |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $this->parameters['bytes'] = @$structure->bytes; |
| 52 | 52 | |
| 53 | 53 | foreach ( (array) @$structure->parameters as $param ) { |
| 54 | - $this->parameters[ strtolower($param->attribute) ] = $param->value; |
|
| 54 | + $this->parameters[strtolower($param->attribute)] = $param->value; |
|
| 55 | 55 | } |
| 56 | 56 | foreach ( (array) @$structure->dparameters as $param ) { |
| 57 | - $this->parameters[ strtolower($param->attribute) ] = $param->value; |
|
| 57 | + $this->parameters[strtolower($param->attribute)] = $param->value; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | public function parameter( $name ) { |
| 66 | 66 | $parameters = $this->parameters(); |
| 67 | 67 | $structure = $this->structure(); |
| 68 | - return @$parameters[ strtolower($name) ] ?: @$structure->$name; |
|
| 68 | + return @$parameters[strtolower($name)] ?: @$structure->$name; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** @return string[][] */ |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | $headers = array_map('mb_decode_mimeheader', $headers); |
| 81 | 81 | |
| 82 | 82 | $this->headers = []; |
| 83 | - foreach ($headers as $header) { |
|
| 83 | + foreach ( $headers as $header ) { |
|
| 84 | 84 | $x = explode(':', $header, 2); |
| 85 | - $this->headers[ trim(strtolower($x[0])) ][] = trim($x[1]); |
|
| 85 | + $this->headers[trim(strtolower($x[0]))][] = trim($x[1]); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | $parts = $recursive ? $this->allParts() : $this->parts(); |
| 104 | 104 | array_unshift($parts, $this); |
| 105 | 105 | |
| 106 | - return array_values(array_filter($parts, function(IMAPMessagePartInterface $part) use ($subtypes) { |
|
| 106 | + return array_values(array_filter($parts, function( IMAPMessagePartInterface $part ) use ($subtypes) { |
|
| 107 | 107 | return in_array($part->subtype(), $subtypes); |
| 108 | 108 | })); |
| 109 | 109 | } |