snappymail/rainloop/v/0.0.0/app/libraries/MailSo/Mime/PartCollection.php
djmaze f6fdb69c65 Changed: MailSo\*Collection now extends \ArrayObject
Changed: fixed __constructor param type hinting
Replace: &$o with $o as objects don't need & referencing
2020-03-18 23:14:00 +01:00

56 lines
1,009 B
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();
}
/**
* @return resource
*/
public function ToStream(string $sBoundary)
{
$rResult = null;
if (0 < \strlen($sBoundary))
{
$aResult = array();
foreach ($this 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;
}
}