snappymail/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php
2020-03-19 15:21:00 +01:00

61 lines
1 KiB
PHP

<?php
/*
* 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.
*/
namespace MailSo\Mime;
/**
* @category MailSo
* @package Mime
*/
class PartCollection extends \MailSo\Base\Collection
{
protected function __construct()
{
parent::__construct();
}
public static function NewInstance() : self
{
return new self();
}
public function append(Part $oPart, bool $bToTop = false) : void
{
parent::append($oPart, $bToTop);
}
/**
* @return resource
*/
public function ToStream(string $sBoundary)
{
$rResult = null;
if (0 < \strlen($sBoundary))
{
$aResult = array();
foreach ($this as $oPart)
{
if (0 < count($aResult))
{
$aResult[] = Enumerations\Constants::CRLF.
'--'.$sBoundary.Enumerations\Constants::CRLF;
}
$aResult[] = $oPart->ToStream();
}
return \MailSo\Base\StreamWrappers\SubStreams::CreateStream($aResult);
}
return $rResult;
}
}