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

Commit

Permalink
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 47 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.4-dev",
"dev-develop": "2.5-dev"
"dev-master": "2.2-dev",
"dev-develop": "2.3-dev"
}
},
"autoload-dev": {
Expand Down
9 changes: 2 additions & 7 deletions src/Decode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime;

use Zend\Mail\Headers;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
* @package Zend_Mime
*/
class Decode
{
/**
Expand Down Expand Up @@ -101,7 +96,7 @@ public static function splitMessageStruct($message, $boundary, $EOL = Mime::LINE
* @param Headers $headers output param, headers container
* @param string $body output param, content of message
* @param string $EOL EOL string; defaults to {@link Zend_Mime::LINEEND}
* @param boolean $strict enable strict mode for parsing message
* @param bool $strict enable strict mode for parsing message
* @return null
*/
public static function splitMessage($message, &$headers, &$body, $EOL = Mime::LINEEND, $strict = false)
Expand Down
7 changes: 1 addition & 6 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime\Exception;

/**
* @category Zend
* @package Zend_Mime
*/
interface ExceptionInterface
{}
6 changes: 1 addition & 5 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime\Exception;

/**
* Exception for Zend_Mime component.
*
* @category Zend
* @package Zend_Mime
*/
class RuntimeException
extends \RuntimeException
Expand Down
22 changes: 9 additions & 13 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime;

/**
* @category Zend
* @package Zend_Mime
*/
class Message
{

Expand Down Expand Up @@ -57,7 +52,7 @@ public function addPart(Part $part)
* Check if message needs to be sent as multipart
* MIME message or if it has only one part.
*
* @return boolean
* @return bool
*/
public function isMultiPart()
{
Expand Down Expand Up @@ -111,9 +106,9 @@ public function getMime()
*/
public function generateMessage($EOL = Mime::LINEEND)
{
if (! $this->isMultiPart()) {
$body = array_shift($this->parts);
$body = $body->getContent($EOL);
if (!$this->isMultiPart()) {
$part = current($this->parts);
$body = $part->getContent($EOL);
} else {
$mime = $this->getMime();

Expand Down Expand Up @@ -181,8 +176,8 @@ public function getPartContent($partnum, $EOL = Mime::LINEEND)
*/
protected static function _disassembleMime($body, $boundary)
{
$start = 0;
$res = array();
$start = 0;
$res = array();
// find every mime part limiter and cut out the
// string before it.
// the part before the first boundary string is discarded:
Expand Down Expand Up @@ -225,7 +220,7 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
{
$parts = Decode::splitMessageStruct($message, $boundary, $EOL);

$res = new self();
$res = new static();
foreach ($parts as $part) {
// now we build a new MimePart for the current Message Part:
$newPart = new Part($part['body']);
Expand Down Expand Up @@ -265,6 +260,7 @@ public static function createFromMessage($message, $boundary, $EOL = Mime::LINEE
}
$res->addPart($newPart);
}

return $res;
}
}
8 changes: 2 additions & 6 deletions src/Mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime;

/**
* Support class for MultiPart Mime Messages
*
* @category Zend
* @package Zend_Mime
*/
class Mime
{
Expand Down Expand Up @@ -95,7 +91,7 @@ class Mime
* false, encode the string for secure delivery.
*
* @param string $str
* @return boolean
* @return bool
*/
public static function isPrintable($str)
{
Expand Down
7 changes: 2 additions & 5 deletions src/Part.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/

namespace Zend\Mime;

/**
* Class representing a MIME part.
*
* @category Zend
* @package Zend_Mime
*/
class Part
{
Expand Down Expand Up @@ -70,6 +66,7 @@ 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
*/
Expand Down
14 changes: 13 additions & 1 deletion test/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/
Expand Down Expand Up @@ -116,4 +116,16 @@ public function testDecodeMimeMessage()
$this->assertEquals('base64', $part2->encoding);
$this->assertEquals('12', $part2->id);
}

public function testNonMultipartMessageShouldNotRemovePartFromMessage()
{
$message = new Mime\Message(); // No Parts
$part = new Mime\Part('This is a test');
$message->addPart($part);
$message->generateMessage();

$parts = $message->getParts();
$test = current($parts);
$this->assertSame($part, $test);
}
}
2 changes: 1 addition & 1 deletion test/MimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/
Expand Down
2 changes: 1 addition & 1 deletion test/PartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Mime
*/
Expand Down

0 comments on commit 52c4962

Please sign in to comment.