snappymail/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php

66 lines
1.1 KiB
PHP
Raw Normal View History

2013-09-25 03:04:44 +08:00
<?php
2014-10-17 18:15:19 +08:00
/*
* This file is part of MailSo.
*
* (c) 2014 Usenko Timur
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
2013-09-25 03:04:44 +08:00
namespace MailSo\Mime;
/**
* @category MailSo
* @package Mime
*/
class PartCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
}
/**
* @return \MailSo\Mime\PartCollection
*/
public static function NewInstance()
{
return new self();
}
/**
* @param string $sBoundary
*
* @return resorce
*/
public function ToStream($sBoundary)
{
$rResult = null;
2013-10-31 05:03:32 +08:00
if (0 < \strlen($sBoundary))
2013-09-25 03:04:44 +08:00
{
$aResult = array();
$aParts =& $this->GetAsArray();
foreach ($aParts as /* @var $oPart \MailSo\Mime\Part */ &$oPart)
{
if (0 < count($aResult))
{
$aResult[] = \MailSo\Mime\Enumerations\Constants::CRLF.
'--'.$sBoundary.\MailSo\Mime\Enumerations\Constants::CRLF;
}
$aResult[] = $oPart->ToStream();
}
return \MailSo\Base\StreamWrappers\SubStreams::CreateStream($aResult);
}
return $rResult;
}
}