Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into hotfix/translator-caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function getPartHeadersArray($partnum)
* Get the headers of a given part as a string
*
* @param int $partnum
* @param string $EOL
* @return string
*/
public function getPartHeaders($partnum, $EOL = Mime::LINEEND)
Expand All @@ -160,6 +161,7 @@ public function getPartHeaders($partnum, $EOL = Mime::LINEEND)
* Get the (encoded) content of a given part as a string
*
* @param int $partnum
* @param string $EOL
* @return string
*/
public function getPartContent($partnum, $EOL = Mime::LINEEND)
Expand All @@ -174,6 +176,7 @@ public function getPartContent($partnum, $EOL = Mime::LINEEND)
*
* @param string $body
* @param string $boundary
* @throws Exception\RuntimeException
* @return array
*/
protected static function _disassembleMime($body, $boundary)
Expand All @@ -183,7 +186,7 @@ protected static function _disassembleMime($body, $boundary)
// find every mime part limiter and cut out the
// string before it.
// the part before the first boundary string is discarded:
$p = strpos($body, '--'.$boundary."\n", $start);
$p = strpos($body, '--' . $boundary."\n", $start);
if ($p === false) {
// no parts found!
return array();
Expand Down Expand Up @@ -215,6 +218,7 @@ protected static function _disassembleMime($body, $boundary)
* @param string $message
* @param string $boundary
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @throws Exception\RuntimeException
* @return \Zend\Mime\Message
*/
public static function createFromMessage($message, $boundary, $EOL = Mime::LINEEND)
Expand Down
15 changes: 8 additions & 7 deletions src/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function isPrintable($str)
*
* @param string $str
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param string $lineEnd Defaults to {@link LINEEND}
* @return string
*/
public static function encodeQuotedPrintable($str,
Expand Down Expand Up @@ -168,7 +168,7 @@ private static function _encodeQuotedPrintable($str)
* @param string $str
* @param string $charset
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param string $lineEnd Defaults to {@link LINEEND}
* @return string
*/
public static function encodeQuotedPrintableHeader($str, $charset,
Expand Down Expand Up @@ -198,7 +198,7 @@ public static function encodeQuotedPrintableHeader($str, $charset,
if ($token == '=20') {
// only if we have a single char token or space, we can append the
// tempstring it to the current line or start a new line if necessary.
if (strlen($lines[$currentLine].$tmp) > $lineLength) {
if (strlen($lines[$currentLine] . $tmp) > $lineLength) {
$lines[$currentLine+1] = $tmp;
} else {
$lines[$currentLine] .= $tmp;
Expand All @@ -213,7 +213,7 @@ public static function encodeQuotedPrintableHeader($str, $charset,

// assemble the lines together by pre- and appending delimiters, charset, encoding.
for ($i = 0; $i < count($lines); $i++) {
$lines[$i] = " ".$prefix.$lines[$i]."?=";
$lines[$i] = " " . $prefix . $lines[$i] . "?=";
}
$str = trim(implode($lineEnd, $lines));
return $str;
Expand Down Expand Up @@ -241,7 +241,7 @@ private static function getNextQuotedPrintableToken($str)
* @param string $str
* @param string $charset
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param string $lineEnd Defaults to {@link LINEEND}
* @return string
*/
public static function encodeBase64Header($str,
Expand All @@ -265,7 +265,7 @@ public static function encodeBase64Header($str,
*
* @param string $str
* @param int $lineLength Defaults to {@link LINELENGTH}
* @param int $lineEnd Defaults to {@link LINEEND}
* @param string $lineEnd Defaults to {@link LINEEND}
* @return string
*/
public static function encodeBase64($str,
Expand Down Expand Up @@ -330,7 +330,7 @@ public function boundary()
/**
* Return a MIME boundary line
*
* @param mixed $EOL Defaults to {@link LINEEND}
* @param string $EOL Defaults to {@link LINEEND}
* @access public
* @return string
*/
Expand All @@ -342,6 +342,7 @@ public function boundaryLine($EOL = self::LINEEND)
/**
* Return MIME ending
*
* @param string $EOL Defaults to {@link LINEEND}
* @access public
* @return string
*/
Expand Down
11 changes: 6 additions & 5 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ public function getEncodedStream()
/**
* Get the Content of the current Mime Part in the given encoding.
*
* @return String
* @param string $EOL
* @return string
*/
public function getContent($EOL = Mime::LINEEND)
{
if ($this->isStream) {
return stream_get_contents($this->getEncodedStream());
} else {
return Mime::encode($this->content, $this->encoding, $EOL);
}
return Mime::encode($this->content, $this->encoding, $EOL);
}

/**
Expand All @@ -136,15 +136,15 @@ public function getRawContent()
{
if ($this->isStream) {
return stream_get_contents($this->content);
} else {
return $this->content;
}
return $this->content;
}

/**
* Create and return the array of headers for this MIME part
*
* @access public
* @param string $EOL
* @return array
*/
public function getHeadersArray($EOL = Mime::LINEEND)
Expand Down Expand Up @@ -197,6 +197,7 @@ public function getHeadersArray($EOL = Mime::LINEEND)
/**
* Return the headers for this part as a string
*
* @param string $EOL
* @return String
*/
public function getHeaders($EOL = Mime::LINEEND)
Expand Down
4 changes: 2 additions & 2 deletions test/PartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testStreamEncoding()
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(base64_decode($encoded),$original);
$this->assertEquals(base64_decode($encoded), $original);

// test QuotedPrintable
$fp = fopen($testfile,'rb');
Expand All @@ -97,7 +97,7 @@ public function testStreamEncoding()
$this->assertTrue(is_resource($fp2));
$encoded = stream_get_contents($fp2);
fclose($fp);
$this->assertEquals(quoted_printable_decode($encoded),$original);
$this->assertEquals(quoted_printable_decode($encoded), $original);
}

/**
Expand Down

0 comments on commit 14bf51d

Please sign in to comment.