mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 17:07:03 +03:00
Changed: MailSo\*Collection now extends \ArrayObject
Changed: fixed __constructor param type hinting Replace: &$o with $o as objects don't need & referencing
This commit is contained in:
parent
9bb44e7f98
commit
f6fdb69c65
30 changed files with 290 additions and 736 deletions
|
|
@ -57,8 +57,8 @@ class Attachment
|
|||
*/
|
||||
private $sContentLocation;
|
||||
|
||||
private function __construct($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID,
|
||||
$aCustomContentTypeParams = array(), $sContentLocation = '')
|
||||
private function __construct($rResource, string $sFileName, int $iFileSize, bool $bIsInline, bool $bIsLinked, string $sCID,
|
||||
array $aCustomContentTypeParams = array(), string $sContentLocation = '')
|
||||
{
|
||||
$this->rResource = $rResource;
|
||||
$this->sFileName = $sFileName;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Email
|
|||
/**
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct($sEmail, $sDisplayName = '')
|
||||
private function __construct(string $sEmail, string $sDisplayName = '')
|
||||
{
|
||||
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class EmailCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
protected function __construct($sEmailAddresses = '')
|
||||
protected function __construct(string $sEmailAddresses = '')
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
|
@ -40,9 +40,8 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
public function ToArray() : array
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
$aReturn = array();
|
||||
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$aReturn[] = $oEmail->ToArray();
|
||||
}
|
||||
|
|
@ -52,10 +51,9 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
public function MergeWithOtherCollection(EmailCollection $oEmails) : self
|
||||
{
|
||||
$aEmails =& $oEmails->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
foreach ($oEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$this->Add($oEmail);
|
||||
$this->append($oEmail);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -63,30 +61,26 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
public function Unique() : self
|
||||
{
|
||||
$aCache = array();
|
||||
$aReturn = array();
|
||||
|
||||
$aEmails =& $this->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$sEmail = $oEmail->GetEmail();
|
||||
if (!isset($aCache[$sEmail]))
|
||||
if (!isset($aReturn[$sEmail]))
|
||||
{
|
||||
$aCache[$sEmail] = true;
|
||||
$aReturn[] = $oEmail;
|
||||
$aReturn[$sEmail] = $oEmail;
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetAsArray($aReturn);
|
||||
$this->exchangeArray(array_values($aReturn));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
$aReturn = array();
|
||||
foreach ($this as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
{
|
||||
$aReturn[] = $oEmail->ToString($bConvertSpecialsName, $bIdn);
|
||||
}
|
||||
|
|
@ -174,7 +168,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
|
||||
try
|
||||
{
|
||||
$this->Add(
|
||||
$this->append(
|
||||
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iEmailEndPos - $iEmailStartPos))
|
||||
);
|
||||
|
||||
|
|
@ -194,7 +188,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
{
|
||||
try
|
||||
{
|
||||
$this->Add(
|
||||
$this->append(
|
||||
\MailSo\Mime\Email::Parse(\substr($sWorkingRecipients, $iEmailStartPos, $iCurrentPos - $iEmailStartPos))
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class EmailDep
|
|||
/**
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct($sEmail, $sDisplayName = '', $sRemark = '')
|
||||
private function __construct(string $sEmail, string $sDisplayName = '', string $sRemark = '')
|
||||
{
|
||||
if (!\MailSo\Base\Validator::NotEmptyString($sEmail, true))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Header
|
|||
*/
|
||||
private $sParentCharset;
|
||||
|
||||
private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '')
|
||||
private function __construct(string $sName, string $sValue, string $sEncodedValueForReparse, string $sParentCharset = '')
|
||||
{
|
||||
$this->sParentCharset = $sParentCharset;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,11 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
protected $sRawHeaders;
|
||||
|
||||
/**
|
||||
* @var strign
|
||||
* @var string
|
||||
*/
|
||||
protected $sParentCharset;
|
||||
|
||||
protected function __construct($sRawHeaders = '', $bStoreRawHeaders = true)
|
||||
protected function __construct(string $sRawHeaders = '', bool $bStoreRawHeaders = true)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
|
@ -38,49 +38,34 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : \MailSo\Mime\HeaderCollection
|
||||
public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : self
|
||||
{
|
||||
return new self($sRawHeaders, $bStoreRawHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
|
||||
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : self
|
||||
{
|
||||
return $this->Add(Header::NewInstance($sName, $sValue), $bToTop);
|
||||
$this->append(Header::NewInstance($sName, $sValue), $bToTop);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function SetByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
|
||||
public function SetByName(string $sName, string $sValue, bool $bToTop = false) : self
|
||||
{
|
||||
return $this->RemoveByName($sName)->Add(Header::NewInstance($sName, $sValue), $bToTop);
|
||||
}
|
||||
|
||||
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Header
|
||||
{
|
||||
$mResult = null;
|
||||
$mResult =& parent::GetByIndex($iIndex);
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string
|
||||
{
|
||||
$oHeader = null;
|
||||
$oHeader =& $this->GetByName($sHeaderName);
|
||||
return (null !== $oHeader) ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
|
||||
$oHeader = $this->GetByName($sHeaderName);
|
||||
return $oHeader ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
|
||||
}
|
||||
|
||||
public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array
|
||||
{
|
||||
$aResult = array();
|
||||
$oHeader = null;
|
||||
|
||||
$sHeaderNameLower = \strtolower($sHeaderName);
|
||||
$aHeaders =& $this->GetAsArray();
|
||||
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
|
||||
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
|
||||
{
|
||||
if ($sHeaderNameLower === \strtolower($oHeader->Name()))
|
||||
{
|
||||
|
|
@ -91,12 +76,12 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
public function RemoveByName(string $sHeaderName) : \MailSo\Mime\HeaderCollection
|
||||
public function RemoveByName(string $sHeaderName) : self
|
||||
{
|
||||
$aResult = $this->FilterList(function ($oHeader) use ($sHeaderName) {
|
||||
return $oHeader && \strtolower($oHeader->Name()) !== \strtolower($sHeaderName);
|
||||
});
|
||||
$this->SetAsArray($aResult);
|
||||
$sHeaderName = \strtolower($sHeaderName);
|
||||
$this->exchangeArray(array_filter($this->getArrayCopy(), function ($oHeader) use ($sHeaderName) {
|
||||
return $oHeader && \strtolower($oHeader->Name()) !== $sHeaderName;
|
||||
}));
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -114,14 +99,8 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
|
||||
public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection
|
||||
{
|
||||
$oParameters = $oHeader = null;
|
||||
$oHeader =& $this->GetByName($sHeaderName);
|
||||
if ($oHeader)
|
||||
{
|
||||
$oParameters = $oHeader->Parameters();
|
||||
}
|
||||
|
||||
return $oParameters;
|
||||
$oHeader = $this->GetByName($sHeaderName);
|
||||
return $oHeader ? $oHeader->Parameters() : null;
|
||||
}
|
||||
|
||||
public function ParameterValue(string $sHeaderName, string $sParamName) : string
|
||||
|
|
@ -130,34 +109,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) : ?\MailSo\Mime\Header
|
||||
{
|
||||
$oResult = $oHeader = null;
|
||||
|
||||
$sHeaderNameLower = \strtolower($sHeaderName);
|
||||
$aHeaders =& $this->GetAsArray();
|
||||
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
|
||||
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
|
||||
{
|
||||
if ($sHeaderNameLower === \strtolower($oHeader->Name()))
|
||||
{
|
||||
$oResult =& $oHeader;
|
||||
break;
|
||||
return $oHeader;
|
||||
}
|
||||
}
|
||||
|
||||
return $oResult;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\HeaderCollection
|
||||
public function SetParentCharset(string $sParentCharset) : self
|
||||
{
|
||||
if (0 < \strlen($sParentCharset))
|
||||
{
|
||||
if ($this->sParentCharset !== $sParentCharset)
|
||||
{
|
||||
$oHeader = null;
|
||||
$aHeaders =& $this->GetAsArray();
|
||||
|
||||
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
|
||||
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
|
||||
{
|
||||
$oHeader->SetParentCharset($sParentCharset);
|
||||
}
|
||||
|
|
@ -171,12 +143,11 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
|
||||
public function Clear() : void
|
||||
{
|
||||
parent::Clear();
|
||||
|
||||
$this->exchangeArray(array());
|
||||
$this->sRawHeaders = '';
|
||||
}
|
||||
|
||||
public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : \MailSo\Mime\HeaderCollection
|
||||
public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : self
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
@ -236,7 +207,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
$oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset);
|
||||
if ($oHeader)
|
||||
{
|
||||
$this->Add($oHeader);
|
||||
$this->append($oHeader);
|
||||
}
|
||||
|
||||
$sName = null;
|
||||
|
|
@ -259,7 +230,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
$oHeader = Header::NewInstanceFromEncodedString($sName.': '.$sValue, $this->sParentCharset);
|
||||
if ($oHeader)
|
||||
{
|
||||
$this->Add($oHeader);
|
||||
$this->append($oHeader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -370,8 +341,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
public function ToEncodedString() : string
|
||||
{
|
||||
$aResult = array();
|
||||
$aHeaders =& $this->GetAsArray();
|
||||
foreach ($aHeaders as /* @var $oHeader \MailSo\Mime\Header */ &$oHeader)
|
||||
foreach ($this as /* @var $oHeader \MailSo\Mime\Header */ $oHeader)
|
||||
{
|
||||
$aResult[] = $oHeader->EncodedValue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,14 +402,14 @@ class Message
|
|||
\MailSo\Mime\Enumerations\Parameter::FILENAME, $sFileName));
|
||||
}
|
||||
|
||||
$oAttachmentPart->Headers->Add(
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
$oAttachment->ContentType().';'.
|
||||
(($oContentTypeParameters) ? ' '.$oContentTypeParameters->ToString() : '')
|
||||
)
|
||||
);
|
||||
|
||||
$oAttachmentPart->Headers->Add(
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_DISPOSITION,
|
||||
($oAttachment->IsInline() ? 'inline' : 'attachment').';'.
|
||||
(($oContentDispositionParameters) ? ' '.$oContentDispositionParameters->ToString() : '')
|
||||
|
|
@ -418,14 +418,14 @@ class Message
|
|||
|
||||
if (0 < strlen($sCID))
|
||||
{
|
||||
$oAttachmentPart->Headers->Add(
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_ID, $sCID)
|
||||
);
|
||||
}
|
||||
|
||||
if (0 < strlen($sContentLocation))
|
||||
{
|
||||
$oAttachmentPart->Headers->Add(
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION, $sContentLocation)
|
||||
);
|
||||
}
|
||||
|
|
@ -434,7 +434,7 @@ class Message
|
|||
|
||||
if ('message/rfc822' !== strtolower($oAttachment->ContentType()))
|
||||
{
|
||||
$oAttachmentPart->Headers->Add(
|
||||
$oAttachmentPart->Headers->append(
|
||||
Header::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
\MailSo\Base\Enumerations\Encoding::BASE64_LOWER
|
||||
|
|
@ -466,7 +466,7 @@ class Message
|
|||
{
|
||||
$oAlternativePart = Part::NewInstance();
|
||||
$oParameters = ParameterCollection::NewInstance();
|
||||
$oParameters->Add(
|
||||
$oParameters->append(
|
||||
Parameter::NewInstance(
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET,
|
||||
\MailSo\Base\Enumerations\Charset::UTF_8)
|
||||
|
|
@ -476,11 +476,11 @@ class Message
|
|||
{
|
||||
foreach ($aAlternativeData[3] as $sName => $sValue)
|
||||
{
|
||||
$oParameters->Add(Parameter::NewInstance($sName, $sValue));
|
||||
$oParameters->append(Parameter::NewInstance($sName, $sValue));
|
||||
}
|
||||
}
|
||||
|
||||
$oAlternativePart->Headers->Add(
|
||||
$oAlternativePart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
$aAlternativeData[0].'; '.$oParameters->ToString())
|
||||
);
|
||||
|
|
@ -501,7 +501,7 @@ class Message
|
|||
|
||||
if (isset($aAlternativeData[2]) && 0 < strlen($aAlternativeData[2]))
|
||||
{
|
||||
$oAlternativePart->Headers->Add(
|
||||
$oAlternativePart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING,
|
||||
$aAlternativeData[2]
|
||||
)
|
||||
|
|
@ -538,7 +538,7 @@ class Message
|
|||
{
|
||||
$oResultPart = Part::NewInstance();
|
||||
|
||||
$oResultPart->Headers->Add(
|
||||
$oResultPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\MimeType::MULTIPART_ALTERNATIVE.'; '.
|
||||
ParameterCollection::NewInstance()->Add(
|
||||
|
|
@ -554,7 +554,7 @@ class Message
|
|||
$oAlternativePart = $this->createNewMessageAlternativePartBody($aAlternativeData);
|
||||
if ($oAlternativePart)
|
||||
{
|
||||
$oResultPart->SubParts->Add($oAlternativePart);
|
||||
$oResultPart->SubParts->append($oAlternativePart);
|
||||
}
|
||||
|
||||
unset($oAlternativePart);
|
||||
|
|
@ -580,7 +580,7 @@ class Message
|
|||
}
|
||||
else
|
||||
{
|
||||
$aAttachments = $this->oAttachmentCollection->CloneAsArray();
|
||||
$aAttachments = $this->oAttachmentCollection->getArrayCopy();
|
||||
if (\is_array($aAttachments) && 1 === count($aAttachments) && isset($aAttachments[0]))
|
||||
{
|
||||
$this->oAttachmentCollection->Clear();
|
||||
|
|
@ -605,7 +605,7 @@ class Message
|
|||
{
|
||||
$oResultPart = Part::NewInstance();
|
||||
|
||||
$oResultPart->Headers->Add(
|
||||
$oResultPart->Headers->append(
|
||||
Header::NewInstance(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\MimeType::MULTIPART_RELATED.'; '.
|
||||
ParameterCollection::NewInstance()->Add(
|
||||
|
|
@ -616,11 +616,11 @@ class Message
|
|||
)
|
||||
);
|
||||
|
||||
$oResultPart->SubParts->Add($oIncPart);
|
||||
$oResultPart->SubParts->append($oIncPart);
|
||||
|
||||
foreach ($aAttachments as $oAttachment)
|
||||
{
|
||||
$oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment));
|
||||
$oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -649,11 +649,11 @@ class Message
|
|||
)->ToString()
|
||||
);
|
||||
|
||||
$oResultPart->SubParts->Add($oIncPart);
|
||||
$oResultPart->SubParts->append($oIncPart);
|
||||
|
||||
foreach ($aAttachments as $oAttachment)
|
||||
{
|
||||
$oResultPart->SubParts->Add($this->createNewMessageAttachmentBody($oAttachment));
|
||||
$oResultPart->SubParts->append($this->createNewMessageAttachmentBody($oAttachment));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Parameter
|
|||
*/
|
||||
private $sValue;
|
||||
|
||||
private function __construct($sName, $sValue)
|
||||
private function __construct(string $sName, string $sValue)
|
||||
{
|
||||
$this->sName = $sName;
|
||||
$this->sValue = $sValue;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class ParameterCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
protected function __construct($sRawParams = '')
|
||||
protected function __construct(string $sRawParams = '')
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
|
@ -32,29 +32,19 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
return new self($sRawParams);
|
||||
}
|
||||
|
||||
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Parameter
|
||||
{
|
||||
$mResult = null;
|
||||
$mResult =& parent::GetByIndex($iIndex);
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
public function ParameterValueByName(string $sName) : string
|
||||
{
|
||||
$sResult = '';
|
||||
$sName = \trim($sName);
|
||||
$sName = \strtolower(\trim($sName));
|
||||
|
||||
$aParams =& $this->GetAsArray();
|
||||
foreach ($aParams as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam)
|
||||
foreach ($this as /* @var $oParam \MailSo\Mime\ParameterCollection */ $oParam)
|
||||
{
|
||||
if (\strtolower($sName) === \strtolower($oParam->Name()))
|
||||
if ($sName === \strtolower($oParam->Name()))
|
||||
{
|
||||
$sResult = $oParam->Value();
|
||||
break;
|
||||
return $oParam->Value();
|
||||
}
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
return '';
|
||||
}
|
||||
|
||||
public function Parse(string $sRawParams) : self
|
||||
|
|
@ -65,7 +55,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
|
||||
foreach ($aDataToParse as $sParam)
|
||||
{
|
||||
$this->Add(Parameter::CreateFromParameterLine($sParam));
|
||||
$this->append(Parameter::CreateFromParameterLine($sParam));
|
||||
}
|
||||
|
||||
$this->reParseParameters();
|
||||
|
|
@ -76,8 +66,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
{
|
||||
$aResult = array();
|
||||
$aParams =& $this->GetAsArray();
|
||||
foreach ($aParams as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
|
||||
foreach ($this as /* @var $oParam \MailSo\Mime\Parameter */ $oParam)
|
||||
{
|
||||
$sLine = $oParam->ToString($bConvertSpecialsName);
|
||||
if (0 < \strlen($sLine))
|
||||
|
|
@ -91,7 +80,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
|
||||
private function reParseParameters() : void
|
||||
{
|
||||
$aDataToReParse = $this->CloneAsArray();
|
||||
$aDataToReParse = $this->getArrayCopy();
|
||||
$sCharset = \MailSo\Base\Enumerations\Charset::UTF_8;
|
||||
|
||||
$this->Clear();
|
||||
|
|
@ -146,7 +135,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->Add($oParam);
|
||||
$this->append($oParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +151,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
$sCharset, \MailSo\Base\Enumerations\Charset::UTF_8);
|
||||
}
|
||||
|
||||
$this->Add(Parameter::NewInstance($sName, $sResult));
|
||||
$this->append(Parameter::NewInstance($sName, $sResult));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ class Part
|
|||
$sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef);
|
||||
|
||||
$sFirstNotNullCharset = null;
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart)
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
|
||||
{
|
||||
$sCharset = $oMimePart->HeaderCharset();
|
||||
if (0 < strlen($sCharset))
|
||||
|
|
@ -275,7 +275,7 @@ class Part
|
|||
$sForceCharset = self::$ForceCharset;
|
||||
if (0 < strlen($sForceCharset))
|
||||
{
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart)
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
|
||||
{
|
||||
$oMimePart->SetParentCharset($sForceCharset);
|
||||
$oMimePart->Headers->SetParentCharset($sForceCharset);
|
||||
|
|
@ -286,7 +286,7 @@ class Part
|
|||
$sFirstNotNullCharset = (null !== $sFirstNotNullCharset)
|
||||
? $sFirstNotNullCharset : self::$DefaultCharset;
|
||||
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ &$oMimePart)
|
||||
foreach ($this->LineParts as /* @var $oMimePart \MailSo\Mime\Part */ $oMimePart)
|
||||
{
|
||||
$sHeaderCharset = $oMimePart->HeaderCharset();
|
||||
$oMimePart->SetParentCharset((0 < strlen($sHeaderCharset)) ? $sHeaderCharset : $sFirstNotNullCharset);
|
||||
|
|
@ -302,7 +302,7 @@ class Part
|
|||
/**
|
||||
* @param resource $rStreamHandle
|
||||
*/
|
||||
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, int &$iOffset,
|
||||
public function ParseFromStreamRecursion($rStreamHandle, $oCallbackClass, int &$iOffset,
|
||||
string &$sPrevBuffer, string &$sBuffer, array &$aBoundaryStack, bool &$bIsOef, bool $bNotFirstRead = false) : self
|
||||
{
|
||||
$oCallbackClass->StartParseMimePart($this);
|
||||
|
|
@ -496,7 +496,7 @@ class Part
|
|||
->ParseFromStreamRecursion($rStreamHandle, $oCallbackClass,
|
||||
$iOffset, $sPrevBuffer, $sBuffer, $aBoundaryStack, $bIsOef, true);
|
||||
|
||||
$this->SubParts->Add($oSubPart);
|
||||
$this->SubParts->append($oSubPart);
|
||||
$this->LineParts[] =& $oSubPart;
|
||||
//$iParsePosition = self::POS_HEADERS;
|
||||
unset($oSubPart);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ class PartCollection extends \MailSo\Base\Collection
|
|||
{
|
||||
$aResult = array();
|
||||
|
||||
$aParts =& $this->GetAsArray();
|
||||
foreach ($aParts as /* @var $oPart \MailSo\Mime\Part */ &$oPart)
|
||||
foreach ($this as /* @var $oPart \MailSo\Mime\Part */ $oPart)
|
||||
{
|
||||
if (0 < count($aResult))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue