diff --git a/src/Decode.php b/src/Decode.php index 599dd87..13afa7a 100644 --- a/src/Decode.php +++ b/src/Decode.php @@ -76,7 +76,7 @@ public static function splitMime($body, $boundary) */ public static function splitMessageStruct($message, $boundary, $EOL = Mime::LINEEND) { - $parts = self::splitMime($message, $boundary); + $parts = static::splitMime($message, $boundary); if (count($parts) <= 0) { return null; } @@ -84,7 +84,7 @@ public static function splitMessageStruct($message, $boundary, $EOL = Mime::LINE $headers = null; // "Declare" variable before the first usage "for reading" $body = null; // "Declare" variable before the first usage "for reading" foreach ($parts as $part) { - self::splitMessage($part, $headers, $body, $EOL); + static::splitMessage($part, $headers, $body, $EOL); $result[] = array('header' => $headers, 'body' => $body ); } @@ -155,7 +155,7 @@ public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LI */ public static function splitContentType($type, $wantedPart = null) { - return self::splitHeaderField($type, $wantedPart, 'type'); + return static::splitHeaderField($type, $wantedPart, 'type'); } /** diff --git a/src/Mime.php b/src/Mime.php index 1e587db..6f4e0cd 100644 --- a/src/Mime.php +++ b/src/Mime.php @@ -99,7 +99,7 @@ class Mime */ public static function isPrintable($str) { - return (strcspn($str, self::$qpKeysString) == strlen($str)); + return (strcspn($str, static::$qpKeysString) == strlen($str)); } /** @@ -154,7 +154,7 @@ public static function encodeQuotedPrintable($str, private static function _encodeQuotedPrintable($str) { $str = str_replace('=', '=3D', $str); - $str = str_replace(self::$qpKeys, self::$qpReplaceValues, $str); + $str = str_replace(static::$qpKeys, static::$qpReplaceValues, $str); $str = rtrim($str); return $str; } @@ -191,7 +191,7 @@ public static function encodeQuotedPrintableHeader($str, $charset, $tmp = ""; while (strlen($str) > 0) { $currentLine = max(count($lines)-1, 0); - $token = self::getNextQuotedPrintableToken($str); + $token = static::getNextQuotedPrintableToken($str); $str = substr($str, strlen($token)); $tmp .= $token; @@ -253,7 +253,7 @@ public static function encodeBase64Header($str, $suffix = '?='; $remainingLength = $lineLength - strlen($prefix) - strlen($suffix); - $encodedValue = self::encodeBase64($str, $remainingLength, $lineEnd); + $encodedValue = static::encodeBase64($str, $remainingLength, $lineEnd); $encodedValue = str_replace($lineEnd, $suffix . $lineEnd . ' ' . $prefix, $encodedValue); $encodedValue = $prefix . $encodedValue . $suffix; return $encodedValue; @@ -285,7 +285,7 @@ public function __construct($boundary = null) { // This string needs to be somewhat unique if ($boundary === null) { - $this->boundary = '=_' . md5(microtime(1) . self::$makeUnique++); + $this->boundary = '=_' . md5(microtime(1) . static::$makeUnique++); } else { $this->boundary = $boundary; } @@ -303,10 +303,10 @@ public static function encode($str, $encoding, $EOL = self::LINEEND) { switch ($encoding) { case self::ENCODING_BASE64: - return self::encodeBase64($str, self::LINELENGTH, $EOL); + return static::encodeBase64($str, self::LINELENGTH, $EOL); case self::ENCODING_QUOTEDPRINTABLE: - return self::encodeQuotedPrintable($str, self::LINELENGTH, $EOL); + return static::encodeQuotedPrintable($str, self::LINELENGTH, $EOL); default: /** diff --git a/src/Part.php b/src/Part.php index a3f01f5..8fbdb87 100644 --- a/src/Part.php +++ b/src/Part.php @@ -70,10 +70,11 @@ public function isStream() * if this was created with a stream, return a filtered stream for * reading the content. very useful for large file attachments. * + * @param string $EOL * @return stream * @throws Exception\RuntimeException if not a stream or unable to append filter */ - public function getEncodedStream() + public function getEncodedStream($EOL = Mime::LINEEND) { if (!$this->isStream) { throw new Exception\RuntimeException('Attempt to get a stream from a string part'); @@ -88,7 +89,7 @@ public function getEncodedStream() STREAM_FILTER_READ, array( 'line-length' => 76, - 'line-break-chars' => Mime::LINEEND + 'line-break-chars' => $EOL ) ); if (!is_resource($filter)) { @@ -102,7 +103,7 @@ public function getEncodedStream() STREAM_FILTER_READ, array( 'line-length' => 76, - 'line-break-chars' => Mime::LINEEND + 'line-break-chars' => $EOL ) ); if (!is_resource($filter)) { @@ -123,7 +124,7 @@ public function getEncodedStream() public function getContent($EOL = Mime::LINEEND) { if ($this->isStream) { - return stream_get_contents($this->getEncodedStream()); + return stream_get_contents($this->getEncodedStream($EOL)); } return Mime::encode($this->content, $this->encoding, $EOL); }