Cleanup & Speedup *Collection objects

This commit is contained in:
djmaze 2020-03-19 15:21:00 +01:00
parent f6fdb69c65
commit ebfde6e360
12 changed files with 169 additions and 209 deletions

View file

@ -15,7 +15,7 @@ namespace MailSo\Base;
* @category MailSo
* @package Base
*/
abstract class Collection extends \ArrayObject /*implements \ArrayAccess, \Traversable, \Countable, \Ds\Collection */
abstract class Collection extends \ArrayObject
{
/**
* @param mixed $mItem
@ -37,16 +37,6 @@ abstract class Collection extends \ArrayObject /*implements \ArrayAccess, \Trave
return $this;
}
public function AddArray(array $aItems) : self
{
foreach ($aItems as $mItem)
{
$this->append($mItem);
}
return $this;
}
public function Clear() : void
{
$this->exchangeArray([]);
@ -59,45 +49,11 @@ abstract class Collection extends \ArrayObject /*implements \ArrayAccess, \Trave
);
}
public function MapList(callable $cCallback) : array
public function Crop(int $length = null, int $offset = 0, bool $preserve_keys = false)
{
$aResult = array();
if (\is_callable($cCallback))
{
foreach ($this as $oItem)
{
$aResult[] = \call_user_func($cCallback, $oItem);
}
}
return $aResult;
}
public function FilterList(callable $cCallback) : array
{
$aResult = array();
if (\is_callable($cCallback))
{
foreach ($this as $oItem)
{
if (\call_user_func($cCallback, $oItem))
{
$aResult[] = $oItem;
}
}
}
return $aResult;
}
public function ForeachList(callable $cCallback) : void
{
if (\is_callable($cCallback))
{
foreach ($this as $oItem)
{
\call_user_func($cCallback, $oItem);
}
}
$this->exchangeArray(
array_slice($this->getArrayCopy(), $offset, $length, $preserve_keys)
);
return $this;
}
}

View file

@ -27,33 +27,41 @@ class AttachmentCollection extends \MailSo\Base\Collection
return new self();
}
public function append(Attachment $oFolder, bool $bToTop = false) : void
{
parent::append($oFolder, $bToTop);
}
public function InlineCount() : int
{
$aList = $this->FilterList(function ($oAttachment) {
return $oAttachment && $oAttachment->IsInline();
});
return \is_array($aList) ? \count($aList) : 0;
$iCount = 0;
foreach ($this as $oAttachment) {
if ($oAttachment && $oAttachment->IsInline()) {
++$iCount;
}
}
return $iCount;
}
public function NonInlineCount() : int
{
$aList = $this->FilterList(function ($oAttachment) {
return $oAttachment && !$oAttachment->IsInline();
});
return \is_array($aList) ? \count($aList) : 0;
$iCount = 0;
foreach ($this as $oAttachment) {
if ($oAttachment && !$oAttachment->IsInline()) {
++$iCount;
}
}
return $iCount;
}
public function SpecData() : array
{
return $this->MapList(function ($oAttachment) {
if ($oAttachment)
{
return array($oAttachment->FileName(true), $oAttachment->MimeType());
}
return null;
});
$aResult = array();
foreach ($this as $oAttachment) {
$aResult[] = $oAttachment
? array($oAttachment->FileName(true), $oAttachment->MimeType())
: null;
}
return $aResult;
}
}

View file

@ -155,15 +155,14 @@ class Folder
public function HasVisibleSubFolders() : bool
{
$sList = array();
if ($this->oSubFolders)
{
$sList = $this->oSubFolders->FilterList(function (\MailSo\Mail\Folder $oFolder) {
return $oFolder->IsSubscribed();
});
if ($this->oSubFolders) {
foreach ($this->oSubFolders as $oFolder) {
if ($oFolder->IsSubscribed()) {
return true;
}
}
}
return 0 < \count($sList);
return false;
}
public function IsSubscribed() : bool

View file

@ -58,10 +58,15 @@ class FolderCollection extends \MailSo\Base\Collection
return new self();
}
public function GetByFullNameRaw(string $sFullNameRaw) : ?\MailSo\Mail\Folder
public function append(Folder $oFolder, bool $bToTop = false) : void
{
parent::append($oFolder, $bToTop);
}
public function GetByFullNameRaw(string $sFullNameRaw) : ?Folder
{
$mResult = null;
foreach ($this as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($this as $oFolder)
{
if ($oFolder->FullNameRaw() === $sFullNameRaw)
{
@ -75,10 +80,6 @@ class FolderCollection extends \MailSo\Base\Collection
{
break;
}
else
{
$mResult = null;
}
}
}
@ -88,7 +89,7 @@ class FolderCollection extends \MailSo\Base\Collection
public function CountRec() : int
{
$iResult = $this->Count();
foreach ($this as /* @var $oFolder \MailSo\Mail\Folder */ $oFolder)
foreach ($this as $oFolder)
{
if ($oFolder)
{
@ -135,7 +136,7 @@ class FolderCollection extends \MailSo\Base\Collection
$this->Clear();
$aSortedByLenImapFolders = array();
foreach ($aUnsortedMailFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
foreach ($aUnsortedMailFolders as /* @var $oMailFolder Folder */ $oMailFolder)
{
$aSortedByLenImapFolders[$oMailFolder->FullNameRaw()] =& $oMailFolder;
unset($oMailFolder);
@ -143,7 +144,7 @@ class FolderCollection extends \MailSo\Base\Collection
unset($aUnsortedMailFolders);
$aAddedFolders = array();
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder Folder */ $oMailFolder)
{
$sDelimiter = $oMailFolder->Delimiter();
$aFolderExplode = \explode($sDelimiter, $oMailFolder->FullNameRaw());
@ -181,7 +182,7 @@ class FolderCollection extends \MailSo\Base\Collection
return \strnatcmp($oFolderA->FullNameRaw(), $oFolderB->FullNameRaw());
});
foreach ($aSortedByLenImapFolders as /* @var $oMailFolder \MailSo\Mail\Folder */ $oMailFolder)
foreach ($aSortedByLenImapFolders as $oMailFolder)
{
$this->AddWithPositionSearch($oMailFolder);
unset($oMailFolder);
@ -190,14 +191,14 @@ class FolderCollection extends \MailSo\Base\Collection
unset($aSortedByLenImapFolders);
}
public function AddWithPositionSearch(\MailSo\Mail\Folder $oMailFolder) : bool
public function AddWithPositionSearch(Folder $oMailFolder) : bool
{
$oItemFolder = null;
$bIsAdded = false;
foreach ($this as /* @var $oItemFolder \MailSo\Mail\Folder */ $oItemFolder)
foreach ($this as $oItemFolder)
{
if ($oMailFolder instanceof \MailSo\Mail\Folder &&
if ($oMailFolder instanceof Folder &&
0 === \strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw().$oItemFolder->Delimiter()))
{
if ($oItemFolder->SubFolders(true)->AddWithPositionSearch($oMailFolder))
@ -209,7 +210,7 @@ class FolderCollection extends \MailSo\Base\Collection
}
}
if (!$bIsAdded && $oMailFolder instanceof \MailSo\Mail\Folder)
if (!$bIsAdded && $oMailFolder instanceof Folder)
{
$bIsAdded = true;
$this->append($oMailFolder);

View file

@ -1842,8 +1842,7 @@ class MailClient
if ($bUseThreadSortIfSupported && 0 === $iThreadUid && \is_array($mAllThreads) && 0 < \count($mAllThreads))
{
$oMessageCollection->ForeachList(function (/* @var $oMessage \MailSo\Mail\Message */ $oMessage) use ($mAllThreads) {
foreach ($oMessageCollection as $oMessage) {
$iUid = $oMessage->Uid();
if (isset($mAllThreads[$iUid]) && \is_array($mAllThreads[$iUid]) && 0 < \count($mAllThreads[$iUid]))
{
@ -1853,7 +1852,7 @@ class MailClient
$oMessage->SetThreads(\array_map('trim', $aSubThreads));
unset($aSubThreads);
}
});
}
}
return $oMessageCollection;

View file

@ -491,7 +491,9 @@ class Message
$this->oCc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::CC, $bCharsetAutoDetect);
$this->oBcc = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::BCC, $bCharsetAutoDetect);
$oHeaders->PopulateEmailColectionByDkim($this->oFrom);
if ($this->oFrom) {
$oHeaders->PopulateEmailColectionByDkim($this->oFrom);
}
$this->oSender = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::SENDER, $bCharsetAutoDetect);
$this->oReplyTo = $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::REPLY_TO, $bCharsetAutoDetect);
@ -582,32 +584,28 @@ class Message
}
$sDraftInfo = $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO);
if (0 < \strlen($sDraftInfo))
{
if (0 < \strlen($sDraftInfo)) {
$sType = '';
$sFolder = '';
$sUid = '';
\MailSo\Mime\ParameterCollection::NewInstance($sDraftInfo)
->ForeachList(function ($oParameter) use (&$sType, &$sFolder, &$sUid) {
$oParameters = \MailSo\Mime\ParameterCollection::NewInstance($sDraftInfo);
foreach ($oParameters as $oParameter) {
switch (\strtolower($oParameter->Name()))
{
case 'type':
$sType = $oParameter->Value();
break;
case 'uid':
$sUid = $oParameter->Value();
break;
case 'folder':
$sFolder = \base64_decode($oParameter->Value());
break;
}
}
switch (\strtolower($oParameter->Name()))
{
case 'type':
$sType = $oParameter->Value();
break;
case 'uid':
$sUid = $oParameter->Value();
break;
case 'folder':
$sFolder = \base64_decode($oParameter->Value());
break;
}
})
;
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && 0 < \strlen($sUid))
{
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && 0 < \strlen($sUid)) {
$this->aDraftInfo = array($sType, $sUid, $sFolder);
}
}

View file

@ -89,6 +89,11 @@ class MessageCollection extends \MailSo\Base\Collection
return new self();
}
public function append(Message $oMessage, bool $bToTop = false) : void
{
parent::append($oMessage, $bToTop);
}
public function Clear() : void
{
parent::Clear();

View file

@ -17,43 +17,49 @@ namespace MailSo\Mime;
*/
class AttachmentCollection extends \MailSo\Base\Collection
{
/**
* @access protected
*/
protected function __construct()
{
parent::__construct();
}
public static function NewInstance() : \MailSo\Mime\AttachmentCollection
public static function NewInstance() : self
{
return new self();
}
public function append(Attachment $oFolder, bool $bToTop = false) : void
{
parent::append($oFolder, $bToTop);
}
public function LinkedAttachments() : array
{
return $this->FilterList(function ($oItem) {
return $oItem && $oItem->IsLinked();
});
$aResult = array();
foreach ($this as $oAttachment) {
if ($oAttachment->IsLinked()) {
$aResult[] = $oAttachment;
}
}
return $aResult;
}
public function UnlinkedAttachments() : array
{
return $this->FilterList(function ($oItem) {
return $oItem && !$oItem->IsLinked();
});
$aResult = array();
foreach ($this as $oAttachment) {
if (!$oAttachment->IsLinked()) {
$aResult[] = $oAttachment;
}
}
return $aResult;
}
public function SizeOfAttachments() : int
{
$iResult = 0;
$this->ForeachList(function ($oItem) use (&$iResult) {
if ($oItem)
{
$iResult += $oItem->FileSize();
}
});
foreach ($this as $oAttachment) {
$iResult += $oAttachment->FileSize();
}
return $iResult;
}
}

View file

@ -33,6 +33,11 @@ class EmailCollection extends \MailSo\Base\Collection
return new self($sEmailAddresses);
}
public function append(Email $oEmail, bool $bToTop = false) : void
{
parent::append($oEmail, $bToTop);
}
public static function Parse(string $sEmailAddresses) : self
{
return self::NewInstance($sEmailAddresses);
@ -41,7 +46,7 @@ class EmailCollection extends \MailSo\Base\Collection
public function ToArray() : array
{
$aReturn = array();
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($this as $oEmail)
{
$aReturn[] = $oEmail->ToArray();
}
@ -51,7 +56,7 @@ class EmailCollection extends \MailSo\Base\Collection
public function MergeWithOtherCollection(EmailCollection $oEmails) : self
{
foreach ($oEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($oEmails as $oEmail)
{
$this->append($oEmail);
}
@ -63,7 +68,7 @@ class EmailCollection extends \MailSo\Base\Collection
{
$aReturn = array();
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($this as $oEmail)
{
$sEmail = $oEmail->GetEmail();
if (!isset($aReturn[$sEmail]))
@ -80,7 +85,7 @@ class EmailCollection extends \MailSo\Base\Collection
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
{
$aReturn = array();
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
foreach ($this as $oEmail)
{
$aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn);
}
@ -169,7 +174,7 @@ class EmailCollection extends \MailSo\Base\Collection
try
{
$this->append(
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos))
Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos))
);
$iEmailStartPos = $iCurrentPos + 1;
@ -189,7 +194,7 @@ class EmailCollection extends \MailSo\Base\Collection
try
{
$this->append(
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos))
Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos))
);
}
catch (\MailSo\Base\Exceptions\InvalidArgumentException $oException) {}

View file

@ -18,22 +18,18 @@ namespace MailSo\Mime;
class HeaderCollection extends \MailSo\Base\Collection
{
protected $sRawHeaders;
protected $sRawHeaders = '';
/**
* @var string
*/
protected $sParentCharset;
protected $sParentCharset = '';
protected function __construct(string $sRawHeaders = '', bool $bStoreRawHeaders = true)
{
parent::__construct();
$this->sRawHeaders = '';
$this->sParentCharset = '';
if (0 < \strlen($sRawHeaders))
{
if (0 < \strlen($sRawHeaders)) {
$this->Parse($sRawHeaders, $bStoreRawHeaders);
}
}
@ -43,6 +39,11 @@ class HeaderCollection extends \MailSo\Base\Collection
return new self($sRawHeaders, $bStoreRawHeaders);
}
public function append(Header $oHeader, bool $bToTop = false) : void
{
parent::append($oHeader, $bToTop);
}
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : self
{
$this->append(Header::NewInstance($sName, $sValue), $bToTop);
@ -63,16 +64,12 @@ class HeaderCollection extends \MailSo\Base\Collection
public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array
{
$aResult = array();
$sHeaderNameLower = \strtolower($sHeaderName);
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
{
if ($sHeaderNameLower === \strtolower($oHeader->Name()))
{
foreach ($this as $oHeader) {
if ($sHeaderNameLower === \strtolower($oHeader->Name())) {
$aResult[] = $bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value();
}
}
return $aResult;
}
@ -85,19 +82,17 @@ class HeaderCollection extends \MailSo\Base\Collection
return $this;
}
public function GetAsEmailCollection(string $sHeaderName, bool $bCharsetAutoDetect = false) : ?\MailSo\Mime\EmailCollection
public function GetAsEmailCollection(string $sHeaderName, bool $bCharsetAutoDetect = false) : ?EmailCollection
{
$oResult = null;
$sValue = $this->ValueByName($sHeaderName, $bCharsetAutoDetect);
if (0 < \strlen($sValue))
{
$oResult = \MailSo\Mime\EmailCollection::NewInstance($sValue);
if (0 < \strlen($sValue)) {
$oResult = EmailCollection::NewInstance($sValue);
}
return $oResult && 0 < $oResult->Count() ? $oResult : null;
}
public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection
public function ParametersByName(string $sHeaderName) : ?ParameterCollection
{
$oHeader = $this->GetByName($sHeaderName);
return $oHeader ? $oHeader->Parameters() : null;
@ -109,35 +104,27 @@ class HeaderCollection extends \MailSo\Base\Collection
return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : '';
}
public function GetByName(string $sHeaderName) : ?\MailSo\Mime\Header
public function GetByName(string $sHeaderName) : ?Header
{
$sHeaderNameLower = \strtolower($sHeaderName);
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
{
if ($sHeaderNameLower === \strtolower($oHeader->Name()))
{
foreach ($this as $oHeader) {
if ($sHeaderNameLower === \strtolower($oHeader->Name())) {
return $oHeader;
}
}
return null;
}
public function SetParentCharset(string $sParentCharset) : self
{
if (0 < \strlen($sParentCharset))
{
if ($this->sParentCharset !== $sParentCharset)
{
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
{
if (0 < \strlen($sParentCharset)){
if ($this->sParentCharset !== $sParentCharset) {
foreach ($this as $oHeader) {
$oHeader->SetParentCharset($sParentCharset);
}
$this->sParentCharset = $sParentCharset;
}
}
return $this;
}
@ -151,13 +138,11 @@ class HeaderCollection extends \MailSo\Base\Collection
{
$this->Clear();
if ($bStoreRawHeaders)
{
if ($bStoreRawHeaders) {
$this->sRawHeaders = $sRawHeaders;
}
if (0 === \strlen($this->sParentCharset))
{
if (0 === \strlen($this->sParentCharset)) {
$this->sParentCharset = $sParentCharset;
}
@ -165,10 +150,8 @@ class HeaderCollection extends \MailSo\Base\Collection
$sName = null;
$sValue = null;
foreach ($aHeaders as $sHeadersValue)
{
if (0 === strlen($sHeadersValue))
{
foreach ($aHeaders as $sHeadersValue) {
if (0 === strlen($sHeadersValue)) {
continue;
}
@ -241,7 +224,7 @@ class HeaderCollection extends \MailSo\Base\Collection
{
$aResult = array();
$aHeaders = $this->ValuesByName(\MailSo\Mime\Enumerations\Header::AUTHENTICATION_RESULTS);
$aHeaders = $this->ValuesByName(Enumerations\Header::AUTHENTICATION_RESULTS);
if (\is_array($aHeaders) && 0 < \count($aHeaders))
{
foreach ($aHeaders as $sHeaderValue)
@ -280,7 +263,7 @@ class HeaderCollection extends \MailSo\Base\Collection
else
{
// X-DKIM-Authentication-Results: signer="hostinger.com" status="pass"
$aHeaders = $this->ValuesByName(\MailSo\Mime\Enumerations\Header::X_DKIM_AUTHENTICATION_RESULTS);
$aHeaders = $this->ValuesByName(Enumerations\Header::X_DKIM_AUTHENTICATION_RESULTS);
if (\is_array($aHeaders) && 0 < \count($aHeaders))
{
foreach ($aHeaders as $sHeaderValue)
@ -313,27 +296,19 @@ class HeaderCollection extends \MailSo\Base\Collection
return $aResult;
}
public function PopulateEmailColectionByDkim($oEmails) : void
public function PopulateEmailColectionByDkim(EmailCollection $oEmails) : void
{
if ($oEmails && $oEmails instanceof \MailSo\Mime\EmailCollection)
{
$aDkimStatuses = $this->DkimStatuses();
if (\is_array($aDkimStatuses) && 0 < \count($aDkimStatuses))
{
$oEmails->ForeachList(function (/* @var $oItem \MailSo\Mime\Email */ $oItem) use ($aDkimStatuses) {
if ($oItem && $oItem instanceof \MailSo\Mime\Email)
$aDkimStatuses = $this->DkimStatuses();
if (\is_array($aDkimStatuses) && 0 < \count($aDkimStatuses)) {
foreach ($oEmails as $oEmail) {
$sEmail = $oEmail->GetEmail();
foreach ($aDkimStatuses as $aDkimData) {
if (isset($aDkimData[0], $aDkimData[1]) &&
$aDkimData[1] === \strstr($sEmail, $aDkimData[1]))
{
$sEmail = $oItem->GetEmail();
foreach ($aDkimStatuses as $aDkimData)
{
if (isset($aDkimData[0], $aDkimData[1]) &&
$aDkimData[1] === \strstr($sEmail, $aDkimData[1]))
{
$oItem->SetDkimStatusAndValue($aDkimData[0], empty($aDkimData[2]) ? '' : $aDkimData[2]);
}
}
$oEmail->SetDkimStatusAndValue($aDkimData[0], empty($aDkimData[2]) ? '' : $aDkimData[2]);
}
});
}
}
}
}
@ -341,11 +316,9 @@ class HeaderCollection extends \MailSo\Base\Collection
public function ToEncodedString() : string
{
$aResult = array();
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
{
foreach ($this as $oHeader) {
$aResult[] = $oHeader->EncodedValue();
}
return \implode(\MailSo\Mime\Enumerations\Constants::CRLF, $aResult);
return \implode(Enumerations\Constants::CRLF, $aResult);
}
}

View file

@ -32,11 +32,16 @@ class ParameterCollection extends \MailSo\Base\Collection
return new self($sRawParams);
}
public function append(Parameter $oHeader, bool $bToTop = false) : void
{
parent::append($oHeader, $bToTop);
}
public function ParameterValueByName(string $sName) : string
{
$sName = \strtolower(\trim($sName));
foreach ($this as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam)
foreach ($this as $oParam)
{
if ($sName === \strtolower($oParam->Name()))
{
@ -66,7 +71,7 @@ class ParameterCollection extends \MailSo\Base\Collection
public function ToString(bool $bConvertSpecialsName = false) : string
{
$aResult = array();
foreach ($this as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
foreach ($this as $oParam)
{
$sLine = $oParam->ToString($bConvertSpecialsName);
if (0 < \strlen($sLine))
@ -86,7 +91,7 @@ class ParameterCollection extends \MailSo\Base\Collection
$this->Clear();
$aPreParams = array();
foreach ($aDataToReParse as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
foreach ($aDataToReParse as $oParam)
{
$aMatch = array();
$sParamName = $oParam->Name();

View file

@ -27,6 +27,11 @@ class PartCollection extends \MailSo\Base\Collection
return new self();
}
public function append(Part $oPart, bool $bToTop = false) : void
{
parent::append($oPart, $bToTop);
}
/**
* @return resource
*/
@ -37,12 +42,12 @@ class PartCollection extends \MailSo\Base\Collection
{
$aResult = array();
foreach ($this as /* @var $oPart \MailSo\Mime\Part */ $oPart)
foreach ($this as $oPart)
{
if (0 < count($aResult))
{
$aResult[] = \MailSo\Mime\Enumerations\Constants::CRLF.
'--'.$sBoundary.\MailSo\Mime\Enumerations\Constants::CRLF;
$aResult[] = Enumerations\Constants::CRLF.
'--'.$sBoundary.Enumerations\Constants::CRLF;
}
$aResult[] = $oPart->ToStream();