mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 08:57:03 +03:00
More params and returns to PHP 7.3+
This commit is contained in:
parent
3d246ae842
commit
26c38b3ec9
95 changed files with 1028 additions and 4865 deletions
|
|
@ -57,9 +57,6 @@ class Attachment
|
|||
*/
|
||||
private $sContentLocation;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID,
|
||||
$aCustomContentTypeParams = array(), $sContentLocation = '')
|
||||
{
|
||||
|
|
@ -75,18 +72,9 @@ class Attachment
|
|||
|
||||
/**
|
||||
* @param resource $rResource
|
||||
* @param string $sFileName = ''
|
||||
* @param int $iFileSize = 0
|
||||
* @param bool $bIsInline = false
|
||||
* @param bool $bIsLinked = false
|
||||
* @param string $sCID = ''
|
||||
* @param array $aCustomContentTypeParams = array()
|
||||
* @param string $sContentLocation = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Attachment
|
||||
*/
|
||||
public static function NewInstance($rResource, $sFileName = '', $iFileSize = 0, $bIsInline = false,
|
||||
$bIsLinked = false, $sCID = '', $aCustomContentTypeParams = array(), $sContentLocation = '')
|
||||
public static function NewInstance($rResource, string $sFileName = '', int $iFileSize = 0, bool $bIsInline = false,
|
||||
bool $bIsLinked = false, string $sCID = '', array $aCustomContentTypeParams = array(), string $sContentLocation = '') : self
|
||||
{
|
||||
return new self($rResource, $sFileName, $iFileSize, $bIsInline, $bIsLinked, $sCID, $aCustomContentTypeParams, $sContentLocation);
|
||||
}
|
||||
|
|
@ -99,99 +87,63 @@ class Attachment
|
|||
return $this->rResource;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentType()
|
||||
public function ContentType() : string
|
||||
{
|
||||
return \MailSo\Base\Utils::MimeContentType($this->sFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function CustomContentTypeParams()
|
||||
public function CustomContentTypeParams() : array
|
||||
{
|
||||
return $this->aCustomContentTypeParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function CID()
|
||||
public function CID() : string
|
||||
{
|
||||
return $this->sCID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentLocation()
|
||||
public function ContentLocation() : string
|
||||
{
|
||||
return $this->sContentLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FileName()
|
||||
public function FileName() : string
|
||||
{
|
||||
return $this->sFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function FileSize()
|
||||
public function FileSize() : int
|
||||
{
|
||||
return $this->iFileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInline()
|
||||
public function IsInline() : bool
|
||||
{
|
||||
return $this->bIsInline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsImage()
|
||||
public function IsImage() : bool
|
||||
{
|
||||
return 'image' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsArchive()
|
||||
public function IsArchive() : bool
|
||||
{
|
||||
return 'archive' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsPdf()
|
||||
public function IsPdf() : bool
|
||||
{
|
||||
return 'pdf' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsDoc()
|
||||
public function IsDoc() : bool
|
||||
{
|
||||
return 'doc' === \MailSo\Base\Utils::ContentTypeType($this->ContentType(), $this->FileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsLinked()
|
||||
public function IsLinked() : bool
|
||||
{
|
||||
return $this->bIsLinked && 0 < \strlen($this->sCID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,38 +25,26 @@ class AttachmentCollection extends \MailSo\Base\Collection
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\AttachmentCollection
|
||||
*/
|
||||
public static function NewInstance()
|
||||
public static function NewInstance() : \MailSo\Mime\AttachmentCollection
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function LinkedAttachments()
|
||||
public function LinkedAttachments() : array
|
||||
{
|
||||
return $this->FilterList(function ($oItem) {
|
||||
return $oItem && $oItem->IsLinked();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function UnlinkedAttachments()
|
||||
public function UnlinkedAttachments() : array
|
||||
{
|
||||
return $this->FilterList(function ($oItem) {
|
||||
return $oItem && !$oItem->IsLinked();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function SizeOfAttachments()
|
||||
public function SizeOfAttachments() : int
|
||||
{
|
||||
$iResult = 0;
|
||||
$this->ForeachList(function ($oItem) use (&$iResult) {
|
||||
|
|
|
|||
|
|
@ -38,11 +38,6 @@ class Email
|
|||
private $sDkimValue;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param string $sEmail
|
||||
* @param string $sDisplayName = ''
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct($sEmail, $sDisplayName = '')
|
||||
|
|
@ -62,25 +57,17 @@ class Email
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
* @param string $sDisplayName = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Email
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function NewInstance($sEmail, $sDisplayName = '')
|
||||
public static function NewInstance(string $sEmail, string $sDisplayName = '') : self
|
||||
{
|
||||
return new self($sEmail, $sDisplayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmailAddress
|
||||
* @return \MailSo\Mime\Email
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function Parse($sEmailAddress)
|
||||
public static function Parse(string $sEmailAddress) : self
|
||||
{
|
||||
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
|
||||
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
|
||||
|
|
@ -207,88 +194,50 @@ class Email
|
|||
return Email::NewInstance($sEmail, $sName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetEmail($bIdn = false)
|
||||
public function GetEmail(bool $bIdn = false) : string
|
||||
{
|
||||
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDisplayName()
|
||||
public function GetDisplayName() : string
|
||||
{
|
||||
return $this->sDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDkimStatus()
|
||||
public function GetDkimStatus() : string
|
||||
{
|
||||
return $this->sDkimStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDkimValue()
|
||||
public function GetDkimValue() : string
|
||||
{
|
||||
return $this->sDkimValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetAccountName()
|
||||
public function GetAccountName() : string
|
||||
{
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDomain($bIdn = false)
|
||||
public function GetDomain(bool $bIdn = false) : string
|
||||
{
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDkimStatus
|
||||
* @param string $sDkimValue = ''
|
||||
*/
|
||||
public function SetDkimStatusAndValue($sDkimStatus, $sDkimValue = '')
|
||||
public function SetDkimStatusAndValue(string $sDkimStatus, string $sDkimValue = '')
|
||||
{
|
||||
$this->sDkimStatus = \MailSo\Mime\Enumerations\DkimStatus::normalizeValue($sDkimStatus);
|
||||
$this->sDkimValue = $sDkimValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
* @param bool $bDkim = true
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToArray($bIdn = false, $bDkim = true)
|
||||
public function ToArray(bool $bIdn = false, bool $bDkim = true) : array
|
||||
{
|
||||
return $bDkim ?
|
||||
array($this->sDisplayName, $this->GetEmail($bIdn), $this->sDkimStatus, $this->sDkimValue) :
|
||||
array($this->sDisplayName, $this->GetEmail($bIdn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
|
||||
{
|
||||
$sReturn = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class EmailCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @param string $sEmailAddresses = ''
|
||||
*/
|
||||
protected function __construct($sEmailAddresses = '')
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
@ -33,30 +28,17 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmailAddresses = ''
|
||||
*
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public static function NewInstance($sEmailAddresses = '')
|
||||
public static function NewInstance(string $sEmailAddresses = '') : self
|
||||
{
|
||||
return new self($sEmailAddresses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmailAddresses
|
||||
*
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public static function Parse($sEmailAddresses)
|
||||
public static function Parse(string $sEmailAddresses) : self
|
||||
{
|
||||
return self::NewInstance($sEmailAddresses);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function ToArray()
|
||||
public function ToArray() : array
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
|
|
@ -68,12 +50,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return $aReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function MergeWithOtherCollection(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function MergeWithOtherCollection(EmailCollection $oEmails) : self
|
||||
{
|
||||
$aEmails =& $oEmails->GetAsArray();
|
||||
foreach ($aEmails as /* @var $oEmail \MailSo\Mime\Email */ $oEmail)
|
||||
|
|
@ -84,10 +61,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function Unique()
|
||||
public function Unique() : self
|
||||
{
|
||||
$aCache = array();
|
||||
$aReturn = array();
|
||||
|
|
@ -108,13 +82,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
|
||||
{
|
||||
$aReturn = $aEmails = array();
|
||||
$aEmails =& $this->GetAsArray();
|
||||
|
|
@ -126,12 +94,7 @@ class EmailCollection extends \MailSo\Base\Collection
|
|||
return \implode(', ', $aReturn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawEmails
|
||||
*
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
private function parseEmailAddresses($sRawEmails)
|
||||
private function parseEmailAddresses(string $sRawEmails) : self
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
|
|||
|
|
@ -44,12 +44,6 @@ class EmailDep
|
|||
private $sDkimValue;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param string $sEmail
|
||||
* @param string $sDisplayName = ''
|
||||
* @param string $sRemark = ''
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
private function __construct($sEmail, $sDisplayName = '', $sRemark = '')
|
||||
|
|
@ -70,26 +64,17 @@ class EmailDep
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
* @param string $sDisplayName = ''
|
||||
* @param string $sRemark = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Email
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function NewInstance($sEmail, $sDisplayName = '', $sRemark = '')
|
||||
public static function NewInstance(string $sEmail, string $sDisplayName = '', string $sRemark = '') : \MailSo\Mime\Email
|
||||
{
|
||||
return new self($sEmail, $sDisplayName, $sRemark);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmailAddress
|
||||
* @return \MailSo\Mime\Email
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public static function Parse($sEmailAddress)
|
||||
public static function Parse(string $sEmailAddress) : \MailSo\Mime\Email
|
||||
{
|
||||
$sEmailAddress = \MailSo\Base\Utils::Trim($sEmailAddress);
|
||||
if (!\MailSo\Base\Validator::NotEmptyString($sEmailAddress, true))
|
||||
|
|
@ -216,95 +201,54 @@ class EmailDep
|
|||
return Email::NewInstance($sEmail, $sName, $sComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetEmail($bIdn = false)
|
||||
public function GetEmail(bool $bIdn = false) : string
|
||||
{
|
||||
return $bIdn ? \MailSo\Base\Utils::IdnToUtf8($this->sEmail) : $this->sEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDisplayName()
|
||||
public function GetDisplayName() : string
|
||||
{
|
||||
return $this->sDisplayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetRemark()
|
||||
public function GetRemark() : string
|
||||
{
|
||||
return $this->sRemark;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDkimStatus()
|
||||
public function GetDkimStatus() : string
|
||||
{
|
||||
return $this->sDkimStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDkimValue()
|
||||
public function GetDkimValue() : string
|
||||
{
|
||||
return $this->sDkimValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetAccountName()
|
||||
public function GetAccountName() : string
|
||||
{
|
||||
return \MailSo\Base\Utils::GetAccountNameFromEmail($this->GetEmail(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetDomain($bIdn = false)
|
||||
public function GetDomain(bool $bIdn = false) : string
|
||||
{
|
||||
return \MailSo\Base\Utils::GetDomainFromEmail($this->GetEmail($bIdn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDkimStatus
|
||||
* @param string $sDkimValue = ''
|
||||
*/
|
||||
public function SetDkimStatusAndValue($sDkimStatus, $sDkimValue = '')
|
||||
public function SetDkimStatusAndValue(string $sDkimStatus, string $sDkimValue = '') : void
|
||||
{
|
||||
$this->sDkimStatus = \MailSo\Mime\Enumerations\DkimStatus::normalizeValue($sDkimStatus);
|
||||
$this->sDkimValue = $sDkimValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bIdn = false
|
||||
* @param bool $bDkim = true
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ToArray($bIdn = false, $bDkim = true)
|
||||
public function ToArray(bool $bIdn = false, bool $bDkim = true) : array
|
||||
{
|
||||
return $bDkim ? array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark, $this->sDkimStatus, $this->sDkimValue) :
|
||||
array($this->sDisplayName, $this->GetEmail($bIdn), $this->sRemark);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
* @param bool $bIdn = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false, $bIdn = false)
|
||||
public function ToString(bool $bConvertSpecialsName = false, bool $bIdn = false) : string
|
||||
{
|
||||
$sReturn = '';
|
||||
|
||||
|
|
|
|||
|
|
@ -26,12 +26,7 @@ class DkimStatus
|
|||
const TEMP_ERROR = 'temperror';
|
||||
const PREM_ERROR = 'permerror';
|
||||
|
||||
/**
|
||||
* @param string $sStatus
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function verifyValue($sStatus)
|
||||
public static function verifyValue(string $sStatus) : bool
|
||||
{
|
||||
return \in_array($sStatus, array(
|
||||
self::NONE,
|
||||
|
|
@ -44,12 +39,7 @@ class DkimStatus
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sStatus
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeValue($sStatus)
|
||||
public static function normalizeValue(string $sStatus) : string
|
||||
{
|
||||
$sStatus = \strtolower(\trim($sStatus));
|
||||
return self::verifyValue($sStatus) ? $sStatus : self::NONE;
|
||||
|
|
|
|||
|
|
@ -47,14 +47,6 @@ class Header
|
|||
*/
|
||||
private $sParentCharset;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
* @param string $sEncodedValueForReparse
|
||||
* @param string $sParentCharset = ''
|
||||
*/
|
||||
private function __construct($sName, $sValue, $sEncodedValueForReparse, $sParentCharset = '')
|
||||
{
|
||||
$this->sParentCharset = $sParentCharset;
|
||||
|
|
@ -62,12 +54,7 @@ class Header
|
|||
$this->initInputData($sName, $sValue, $sEncodedValueForReparse);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
* @param string $sEncodedValueForReparse
|
||||
*/
|
||||
private function initInputData($sName, $sValue, $sEncodedValueForReparse) : void
|
||||
private function initInputData(string $sName, string $sValue, string $sEncodedValueForReparse) : void
|
||||
{
|
||||
$this->sName = trim($sName);
|
||||
$this->sFullValue = trim($sValue);
|
||||
|
|
@ -99,26 +86,12 @@ class Header
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue = ''
|
||||
* @param string $sEncodedValueForReparse = ''
|
||||
* @param string $sParentCharset = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Header
|
||||
*/
|
||||
public static function NewInstance($sName, $sValue = '', $sEncodedValueForReparse = '', $sParentCharset = '')
|
||||
public static function NewInstance(string $sName, string $sValue = '', string $sEncodedValueForReparse = '', string $sParentCharset = '') : \MailSo\Mime\Header
|
||||
{
|
||||
return new self($sName, $sValue, $sEncodedValueForReparse, $sParentCharset);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEncodedLines
|
||||
* @param string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1
|
||||
*
|
||||
* @return \MailSo\Mime\Header | false
|
||||
*/
|
||||
public static function NewInstanceFromEncodedString($sEncodedLines, $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1)
|
||||
public static function NewInstanceFromEncodedString(string $sEncodedLines, string $sIncomingCharset = \MailSo\Base\Enumerations\Charset::ISO_8859_1) : \MailSo\Mime\Header
|
||||
{
|
||||
if (empty($sIncomingCharset))
|
||||
{
|
||||
|
|
@ -139,43 +112,27 @@ class Header
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Name()
|
||||
public function Name() : string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function NameWithDelimitrom()
|
||||
public function NameWithDelimitrom() : string
|
||||
{
|
||||
return $this->Name().': ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Value()
|
||||
public function Value() : string
|
||||
{
|
||||
return $this->sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FullValue()
|
||||
public function FullValue() : string
|
||||
{
|
||||
return $this->sFullValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sParentCharset
|
||||
* @return \MailSo\Mime\Header
|
||||
*/
|
||||
public function SetParentCharset($sParentCharset)
|
||||
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\Header
|
||||
{
|
||||
if ($this->sParentCharset !== $sParentCharset && $this->IsReparsed() && 0 < \strlen($this->sEncodedValueForReparse))
|
||||
{
|
||||
|
|
@ -191,29 +148,19 @@ class Header
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\ParameterCollection | null
|
||||
*/
|
||||
public function Parameters()
|
||||
public function Parameters() : ?\MailSo\Mime\ParameterCollection
|
||||
{
|
||||
return $this->oParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sValue
|
||||
* @return string
|
||||
*/
|
||||
private function wordWrapHelper($sValue, $sGlue = "\r\n ")
|
||||
private function wordWrapHelper(string $sValue, string $sGlue = "\r\n ") : string
|
||||
{
|
||||
return \trim(substr(wordwrap($this->NameWithDelimitrom().$sValue,
|
||||
\MailSo\Mime\Enumerations\Constants::LINE_LENGTH, $sGlue
|
||||
), \strlen($this->NameWithDelimitrom())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function EncodedValue()
|
||||
public function EncodedValue() : string
|
||||
{
|
||||
$sResult = $this->sFullValue;
|
||||
|
||||
|
|
@ -250,18 +197,12 @@ class Header
|
|||
return $this->NameWithDelimitrom().$this->wordWrapHelper($sResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsSubject()
|
||||
public function IsSubject() : bool
|
||||
{
|
||||
return \strtolower(\MailSo\Mime\Enumerations\Header::SUBJECT) === \strtolower($this->Name());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsParameterized()
|
||||
public function IsParameterized() : bool
|
||||
{
|
||||
return \in_array(\strtolower($this->sName), array(
|
||||
\strtolower(\MailSo\Mime\Enumerations\Header::CONTENT_TYPE),
|
||||
|
|
@ -269,10 +210,7 @@ class Header
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsEmail()
|
||||
public function IsEmail() : bool
|
||||
{
|
||||
return \in_array(\strtolower($this->sName), array(
|
||||
\strtolower(\MailSo\Mime\Enumerations\Header::FROM_),
|
||||
|
|
@ -285,10 +223,7 @@ class Header
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ValueWithCharsetAutoDetect()
|
||||
public function ValueWithCharsetAutoDetect() : string
|
||||
{
|
||||
$sValue = $this->Value();
|
||||
if (!\MailSo\Base\Utils::IsAscii($sValue) &&
|
||||
|
|
@ -306,10 +241,7 @@ class Header
|
|||
return $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsReparsed()
|
||||
public function IsReparsed() : bool
|
||||
{
|
||||
return $this->IsEmail() || $this->IsSubject() || $this->IsParameterized();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class HeaderCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
protected $sRawHeaders;
|
||||
|
||||
/**
|
||||
|
|
@ -27,12 +25,6 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
*/
|
||||
protected $sParentCharset;
|
||||
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @param string $sRawHeaders = ''
|
||||
* @param bool $bStoreRawHeaders = true
|
||||
*/
|
||||
protected function __construct($sRawHeaders = '', $bStoreRawHeaders = true)
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
@ -46,73 +38,42 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawHeaders = ''
|
||||
* @param bool $bStoreRawHeaders = true
|
||||
*
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*/
|
||||
public static function NewInstance($sRawHeaders = '', $bStoreRawHeaders = true)
|
||||
public static function NewInstance(string $sRawHeaders = '', bool $bStoreRawHeaders = true) : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
return new self($sRawHeaders, $bStoreRawHeaders);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
* @param bool $bToTop = false
|
||||
*
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function AddByName($sName, $sValue, $bToTop = false)
|
||||
public function AddByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
return $this->Add(Header::NewInstance($sName, $sValue), $bToTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
* @param bool $bToTop = false
|
||||
*
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*
|
||||
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function SetByName($sName, $sValue, $bToTop = false)
|
||||
public function SetByName(string $sName, string $sValue, bool $bToTop = false) : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
return $this->RemoveByName($sName)->Add(Header::NewInstance($sName, $sValue), $bToTop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Header | null
|
||||
*/
|
||||
public function &GetByIndex($iIndex)
|
||||
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Header
|
||||
{
|
||||
$mResult = null;
|
||||
$mResult =& parent::GetByIndex($iIndex);
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @param bool $bCharsetAutoDetect = false
|
||||
* @return string
|
||||
*/
|
||||
public function ValueByName($sHeaderName, $bCharsetAutoDetect = false)
|
||||
public function ValueByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : string
|
||||
{
|
||||
$oHeader = null;
|
||||
$oHeader =& $this->GetByName($sHeaderName);
|
||||
return (null !== $oHeader) ? ($bCharsetAutoDetect ? $oHeader->ValueWithCharsetAutoDetect() : $oHeader->Value()) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @param bool $bCharsetAutoDetect = false
|
||||
* @return array
|
||||
*/
|
||||
public function ValuesByName($sHeaderName, $bCharsetAutoDetect = false)
|
||||
public function ValuesByName(string $sHeaderName, bool $bCharsetAutoDetect = false) : array
|
||||
{
|
||||
$aResult = array();
|
||||
$oHeader = null;
|
||||
|
|
@ -130,12 +91,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
*
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*/
|
||||
public function RemoveByName($sHeaderName)
|
||||
public function RemoveByName(string $sHeaderName) : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
$aResult = $this->FilterList(function ($oHeader) use ($sHeaderName) {
|
||||
return $oHeader && \strtolower($oHeader->Name()) !== \strtolower($sHeaderName);
|
||||
|
|
@ -144,13 +100,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @param bool $bCharsetAutoDetect = false
|
||||
*
|
||||
* @return \MailSo\Mime\EmailCollection|null
|
||||
*/
|
||||
public function GetAsEmailCollection($sHeaderName, $bCharsetAutoDetect = false)
|
||||
public function GetAsEmailCollection(string $sHeaderName, bool $bCharsetAutoDetect = false) : ?\MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = null;
|
||||
$sValue = $this->ValueByName($sHeaderName, $bCharsetAutoDetect);
|
||||
|
|
@ -162,11 +112,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $oResult && 0 < $oResult->Count() ? $oResult : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @return \MailSo\Mime\ParameterCollection|null
|
||||
*/
|
||||
public function ParametersByName($sHeaderName)
|
||||
public function ParametersByName(string $sHeaderName) : ?\MailSo\Mime\ParameterCollection
|
||||
{
|
||||
$oParameters = $oHeader = null;
|
||||
$oHeader =& $this->GetByName($sHeaderName);
|
||||
|
|
@ -178,22 +124,13 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $oParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @param string $sParamName
|
||||
* @return string
|
||||
*/
|
||||
public function ParameterValue($sHeaderName, $sParamName)
|
||||
public function ParameterValue(string $sHeaderName, string $sParamName) : string
|
||||
{
|
||||
$oParameters = $this->ParametersByName($sHeaderName);
|
||||
return (null !== $oParameters) ? $oParameters->ParameterValueByName($sParamName) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @return \MailSo\Mime\Header | false
|
||||
*/
|
||||
public function &GetByName($sHeaderName)
|
||||
public function &GetByName(string $sHeaderName) : \MailSo\Mime\Header
|
||||
{
|
||||
$oResult = $oHeader = null;
|
||||
|
||||
|
|
@ -211,11 +148,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $oResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sParentCharset
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*/
|
||||
public function SetParentCharset($sParentCharset)
|
||||
public function SetParentCharset(string $sParentCharset) : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
if (0 < \strlen($sParentCharset))
|
||||
{
|
||||
|
|
@ -243,14 +176,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
$this->sRawHeaders = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawHeaders
|
||||
* @param bool $bStoreRawHeaders = false
|
||||
* @param string $sParentCharset = ''
|
||||
*
|
||||
* @return \MailSo\Mime\HeaderCollection
|
||||
*/
|
||||
public function Parse($sRawHeaders, $bStoreRawHeaders = false, $sParentCharset = '')
|
||||
public function Parse(string $sRawHeaders, bool $bStoreRawHeaders = false, string $sParentCharset = '') : \MailSo\Mime\HeaderCollection
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
@ -340,10 +266,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function DkimStatuses()
|
||||
public function DkimStatuses() : int
|
||||
{
|
||||
$aResult = array();
|
||||
|
||||
|
|
@ -419,10 +342,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function PopulateEmailColectionByDkim($oEmails)
|
||||
public function PopulateEmailColectionByDkim($oEmails) : int
|
||||
{
|
||||
if ($oEmails && $oEmails instanceof \MailSo\Mime\EmailCollection)
|
||||
{
|
||||
|
|
@ -447,10 +367,7 @@ class HeaderCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ToEncodedString()
|
||||
public function ToEncodedString() : string
|
||||
{
|
||||
$aResult = array();
|
||||
$aHeaders =& $this->GetAsArray();
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ class Message
|
|||
*/
|
||||
private $bAddDefaultXMailer;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->aHeadersValue = array();
|
||||
|
|
@ -54,38 +51,26 @@ class Message
|
|||
$this->bAddDefaultXMailer = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public static function NewInstance()
|
||||
public static function NewInstance() : self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function DoesNotCreateEmptyTextPart()
|
||||
public function DoesNotCreateEmptyTextPart() : self
|
||||
{
|
||||
$this->bAddEmptyTextPart = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function DoesNotAddDefaultXMailer()
|
||||
public function DoesNotAddDefaultXMailer() : self
|
||||
{
|
||||
$this->bAddDefaultXMailer = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function MessageId()
|
||||
public function MessageId() : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (!empty($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID]))
|
||||
|
|
@ -95,43 +80,28 @@ class Message
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sMessageId
|
||||
*/
|
||||
public function SetMessageId($sMessageId) : void
|
||||
public function SetMessageId(string $sMessageId) : void
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::MESSAGE_ID] = $sMessageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHostName = ''
|
||||
*/
|
||||
public function RegenerateMessageId($sHostName = '') : void
|
||||
public function RegenerateMessageId(string $sHostName = '') : void
|
||||
{
|
||||
$this->SetMessageId($this->generateNewMessageId($sHostName));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\AttachmentCollection
|
||||
*/
|
||||
public function Attachments()
|
||||
public function Attachments() : \MailSo\Mime\AttachmentCollection
|
||||
{
|
||||
return $this->oAttachmentCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetSubject()
|
||||
public function GetSubject() : string
|
||||
{
|
||||
return isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT]) ?
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Email|null
|
||||
*/
|
||||
public function GetFrom()
|
||||
public function GetFrom() : ?\MailSo\Mime\Email
|
||||
{
|
||||
$oResult = null;
|
||||
|
||||
|
|
@ -144,10 +114,7 @@ class Message
|
|||
return $oResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function GetTo()
|
||||
public function GetTo() : \MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
|
||||
|
||||
|
|
@ -160,10 +127,7 @@ class Message
|
|||
return $oResult->Unique();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection|null
|
||||
*/
|
||||
public function GetBcc()
|
||||
public function GetBcc() : ?\MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = null;
|
||||
|
||||
|
|
@ -176,10 +140,7 @@ class Message
|
|||
return $oResult ? $oResult->Unique() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\EmailCollection
|
||||
*/
|
||||
public function GetRcpt()
|
||||
public function GetRcpt() : \MailSo\Mime\EmailCollection
|
||||
{
|
||||
$oResult = \MailSo\Mime\EmailCollection::NewInstance();
|
||||
|
||||
|
|
@ -204,13 +165,7 @@ class Message
|
|||
return $oResult->Unique();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHeaderName
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetCustomHeader($sHeaderName, $sValue)
|
||||
public function SetCustomHeader(string $sHeaderName, string $sValue) : self
|
||||
{
|
||||
$sHeaderName = \trim($sHeaderName);
|
||||
if (0 < \strlen($sHeaderName))
|
||||
|
|
@ -221,36 +176,21 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sSubject
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetSubject($sSubject)
|
||||
public function SetSubject(string $sSubject) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SUBJECT] = $sSubject;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sInReplyTo
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetInReplyTo($sInReplyTo)
|
||||
public function SetInReplyTo(string $sInReplyTo) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::IN_REPLY_TO] = $sInReplyTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sReferences
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetReferences($sReferences)
|
||||
public function SetReferences(string $sReferences) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REFERENCES] =
|
||||
\MailSo\Base\Utils::StripSpaces($sReferences);
|
||||
|
|
@ -258,12 +198,7 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetReadReceipt($sEmail)
|
||||
public function SetReadReceipt(string $sEmail) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DISPOSITION_NOTIFICATION_TO] = $sEmail;
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_CONFIRM_READING_TO] = $sEmail;
|
||||
|
|
@ -271,22 +206,12 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetReadConfirmation($sEmail)
|
||||
public function SetReadConfirmation(string $sEmail) : self
|
||||
{
|
||||
return $this->SetReadReceipt($sEmail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iValue
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetPriority($iValue)
|
||||
public function SetPriority(int $iValue) : self
|
||||
{
|
||||
$sResult = '';
|
||||
switch ($iValue)
|
||||
|
|
@ -310,12 +235,7 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iValue
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetSensitivity($iValue)
|
||||
public function SetSensitivity(int $iValue) : self
|
||||
{
|
||||
$sResult = '';
|
||||
switch ($iValue)
|
||||
|
|
@ -339,110 +259,63 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sXMailer
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetXMailer($sXMailer)
|
||||
public function SetXMailer(string $sXMailer) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_MAILER] = $sXMailer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Email $oEmail
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetFrom(\MailSo\Mime\Email $oEmail)
|
||||
public function SetFrom(\MailSo\Mime\Email $oEmail) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::FROM_] = $oEmail;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetTo(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function SetTo(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::TO_] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iDateTime
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetDate($iDateTime)
|
||||
public function SetDate(int $iDateTime) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE] = gmdate('r', $iDateTime);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetReplyTo(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function SetReplyTo(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::REPLY_TO] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetCc(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function SetCc(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::CC] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetBcc(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function SetBcc(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::BCC] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\EmailCollection $oEmails
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetSender(\MailSo\Mime\EmailCollection $oEmails)
|
||||
public function SetSender(\MailSo\Mime\EmailCollection $oEmails) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::SENDER] = $oEmails;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sType
|
||||
* @param string $sUid
|
||||
* @param string $sFolder
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function SetDraftInfo($sType, $sUid, $sFolder)
|
||||
public function SetDraftInfo(string $sType, string $sUid, string $sFolder) : self
|
||||
{
|
||||
$this->aHeadersValue[\MailSo\Mime\Enumerations\Header::X_DRAFT_INFO] = \MailSo\Mime\ParameterCollection::NewInstance()
|
||||
->Add(\MailSo\Mime\Parameter::NewInstance('type', $sType))
|
||||
|
|
@ -453,70 +326,39 @@ class Message
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPlain
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function AddPlain($sPlain)
|
||||
public function AddPlain(string $sPlain) : self
|
||||
{
|
||||
return $this->AddAlternative(
|
||||
\MailSo\Mime\Enumerations\MimeType::TEXT_PLAIN, trim($sPlain),
|
||||
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
|
||||
}
|
||||
/**
|
||||
* @param string $sHtml
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function AddHtml($sHtml)
|
||||
|
||||
public function AddHtml(string $sHtml) : self
|
||||
{
|
||||
return $this->AddAlternative(
|
||||
\MailSo\Mime\Enumerations\MimeType::TEXT_HTML, trim($sHtml),
|
||||
\MailSo\Base\Enumerations\Encoding::QUOTED_PRINTABLE_LOWER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtmlOrPlainText
|
||||
* @param bool $bIsHtml = false
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function AddText($sHtmlOrPlainText, $bIsHtml = false)
|
||||
public function AddText(string $sHtmlOrPlainText, bool $bIsHtml = false) : self
|
||||
{
|
||||
return $bIsHtml ? $this->AddHtml($sHtmlOrPlainText) : $this->AddPlain($sHtmlOrPlainText);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sContentType
|
||||
* @param string|resource $mData
|
||||
* @param string $sContentTransferEncoding = ''
|
||||
* @param array $aCustomContentTypeParams = array()
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
public function AddAlternative($sContentType, $mData, $sContentTransferEncoding = '', $aCustomContentTypeParams = array())
|
||||
public function AddAlternative(string $sContentType, $mData, string $sContentTransferEncoding = '', array $aCustomContentTypeParams = array()) : self
|
||||
{
|
||||
$this->aAlternativeParts[] = array($sContentType, $mData, $sContentTransferEncoding, $aCustomContentTypeParams);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function generateNewBoundary()
|
||||
private function generateNewBoundary() : string
|
||||
{
|
||||
return '--='.\MailSo\Config::$BoundaryPrefix.
|
||||
\rand(100, 999).'_'.rand(100000000, 999999999).'.'.\time();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHostName = ''
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateNewMessageId($sHostName = '')
|
||||
private function generateNewMessageId(string $sHostName = '') : string
|
||||
{
|
||||
if (0 === \strlen($sHostName))
|
||||
{
|
||||
|
|
@ -538,12 +380,7 @@ class Message
|
|||
(\MailSo\Base\Utils::FunctionExistsAndEnabled('getmypid') ? @\getmypid() : '')).'@'.$sHostName.'>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Attachment $oAttachment
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function createNewMessageAttachmentBody($oAttachment)
|
||||
private function createNewMessageAttachmentBody(\MailSo\Mime\Attachment $oAttachment) : \MailSo\Mime\Part
|
||||
{
|
||||
$oAttachmentPart = Part::NewInstance();
|
||||
|
||||
|
|
@ -621,12 +458,7 @@ class Message
|
|||
return $oAttachmentPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aAlternativeData
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function createNewMessageAlternativePartBody($aAlternativeData)
|
||||
private function createNewMessageAlternativePartBody(array $aAlternativeData) : \MailSo\Mime\Part
|
||||
{
|
||||
$oAlternativePart = null;
|
||||
|
||||
|
|
@ -699,13 +531,7 @@ class Message
|
|||
return $oAlternativePart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Part $oPlainPart
|
||||
* @param \MailSo\Mime\Part $oHtmlPart
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function createNewMessageSimpleOrAlternativeBody()
|
||||
private function createNewMessageSimpleOrAlternativeBody() : \MailSo\Mime\Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
if (1 < count($this->aAlternativeParts))
|
||||
|
|
@ -770,12 +596,7 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Part $oIncPart
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function createNewMessageRelatedBody($oIncPart)
|
||||
private function createNewMessageRelatedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
|
||||
|
|
@ -810,12 +631,7 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Part $oIncPart
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function createNewMessageMixedBody($oIncPart)
|
||||
private function createNewMessageMixedBody(\MailSo\Mime\Part $oIncPart) : \MailSo\Mime\Part
|
||||
{
|
||||
$oResultPart = null;
|
||||
|
||||
|
|
@ -848,13 +664,7 @@ class Message
|
|||
return $oResultPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Mime\Part $oIncPart
|
||||
* @param bool $bWithoutBcc = false
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
private function setDefaultHeaders($oIncPart, $bWithoutBcc = false)
|
||||
private function setDefaultHeaders(\MailSo\Mime\Part $oIncPart, bool $bWithoutBcc = false) : \MailSo\Mime\Part
|
||||
{
|
||||
if (!isset($this->aHeadersValue[\MailSo\Mime\Enumerations\Header::DATE]))
|
||||
{
|
||||
|
|
@ -896,12 +706,7 @@ class Message
|
|||
return $oIncPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bWithoutBcc = false
|
||||
*
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function ToPart($bWithoutBcc = false)
|
||||
public function ToPart(bool $bWithoutBcc = false) : \MailSo\Mime\Part
|
||||
{
|
||||
$oPart = $this->createNewMessageSimpleOrAlternativeBody();
|
||||
$oPart = $this->createNewMessageRelatedBody($oPart);
|
||||
|
|
@ -912,21 +717,14 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $bWithoutBcc = false
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function ToStream($bWithoutBcc = false)
|
||||
public function ToStream(bool $bWithoutBcc = false)
|
||||
{
|
||||
return $this->ToPart($bWithoutBcc)->ToStream();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bWithoutBcc = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bWithoutBcc = false)
|
||||
public function ToString(bool $bWithoutBcc = false) : string
|
||||
{
|
||||
return \stream_get_contents($this->ToStream($bWithoutBcc));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,45 +27,24 @@ class Parameter
|
|||
*/
|
||||
private $sValue;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
* @param string $sName
|
||||
* @param string $sValue
|
||||
*/
|
||||
private function __construct($sName, $sValue)
|
||||
{
|
||||
$this->sName = $sName;
|
||||
$this->sValue = $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Parameter
|
||||
*/
|
||||
public static function NewInstance($sName, $sValue = '')
|
||||
public static function NewInstance(string $sName, string $sValue = '') : self
|
||||
{
|
||||
return new self($sName, $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
* @param string $sValue = ''
|
||||
*
|
||||
* @return \MailSo\Mime\Parameter
|
||||
*/
|
||||
public static function CreateFromParameterLine($sRawParam)
|
||||
public static function CreateFromParameterLine(string $sRawParam) : self
|
||||
{
|
||||
$oParameter = self::NewInstance('');
|
||||
return $oParameter->Parse($sRawParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Parameter
|
||||
*/
|
||||
public function Reset()
|
||||
public function Reset() : self
|
||||
{
|
||||
$this->sName = '';
|
||||
$this->sValue = '';
|
||||
|
|
@ -73,29 +52,17 @@ class Parameter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Name()
|
||||
public function Name() : string
|
||||
{
|
||||
return $this->sName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Value()
|
||||
public function Value() : string
|
||||
{
|
||||
return $this->sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawParam
|
||||
* @param string $sSeparator = '='
|
||||
*
|
||||
* @return \MailSo\Mime\Parameter
|
||||
*/
|
||||
public function Parse($sRawParam, $sSeparator = '=')
|
||||
public function Parse(string $sRawParam, string $sSeparator = '=') : self
|
||||
{
|
||||
$this->Reset();
|
||||
|
||||
|
|
@ -110,12 +77,7 @@ class Parameter
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
{
|
||||
$sResult = '';
|
||||
if (0 < strlen($this->sName))
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class ParameterCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*
|
||||
* @param string $sRawParams = ''
|
||||
*/
|
||||
protected function __construct($sRawParams = '')
|
||||
{
|
||||
parent::__construct();
|
||||
|
|
@ -32,32 +27,19 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawParams = ''
|
||||
*
|
||||
* @return \MailSo\Mime\ParameterCollection
|
||||
*/
|
||||
public static function NewInstance($sRawParams = '')
|
||||
public static function NewInstance(string $sRawParams = '') : self
|
||||
{
|
||||
return new self($sRawParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Parameter|null
|
||||
*/
|
||||
public function &GetByIndex($iIndex)
|
||||
public function &GetByIndex(int $iIndex) : ?\MailSo\Mime\Parameter
|
||||
{
|
||||
$mResult = null;
|
||||
$mResult =& parent::GetByIndex($iIndex);
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ParameterValueByName($sName)
|
||||
public function ParameterValueByName(string $sName) : string
|
||||
{
|
||||
$sResult = '';
|
||||
$sName = \trim($sName);
|
||||
|
|
@ -75,12 +57,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawParams
|
||||
*
|
||||
* @return \MailSo\Mime\ParameterCollection
|
||||
*/
|
||||
public function Parse($sRawParams)
|
||||
public function Parse(string $sRawParams) : self
|
||||
{
|
||||
$this->Clear();
|
||||
|
||||
|
|
@ -96,12 +73,7 @@ class ParameterCollection extends \MailSo\Base\Collection
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConvertSpecialsName = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function ToString($bConvertSpecialsName = false)
|
||||
public function ToString(bool $bConvertSpecialsName = false) : string
|
||||
{
|
||||
$aResult = array();
|
||||
$aParams =& $this->GetAsArray();
|
||||
|
|
|
|||
|
|
@ -69,27 +69,18 @@ class Part
|
|||
*/
|
||||
private $iParseBuffer;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
$this->iParseBuffer = \MailSo\Mime\Part::DEFAUL_BUFFER;
|
||||
$this->Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public static function NewInstance()
|
||||
public static function NewInstance() : self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function Reset()
|
||||
public function Reset() : self
|
||||
{
|
||||
\MailSo\Base\ResourceRegistry::CloseMemoryResource($this->Body);
|
||||
$this->Body = null;
|
||||
|
|
@ -103,117 +94,78 @@ class Part
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function Boundary()
|
||||
public function Boundary() : string
|
||||
{
|
||||
return $this->sBoundary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ParentCharset()
|
||||
public function ParentCharset() : string
|
||||
{
|
||||
return (0 < \strlen($this->sCharset)) ? $this->sParentCharset : self::$DefaultCharset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sParentCharset
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function SetParentCharset($sParentCharset)
|
||||
public function SetParentCharset(string $sParentCharset) : self
|
||||
{
|
||||
$this->sParentCharset = $sParentCharset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sBoundary
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function SetBoundary($sBoundary)
|
||||
public function SetBoundary(string $sBoundary) : self
|
||||
{
|
||||
$this->sBoundary = $sBoundary;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $iParseBuffer
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function SetParseBuffer($iParseBuffer)
|
||||
public function SetParseBuffer(int $iParseBuffer) : self
|
||||
{
|
||||
$this->iParseBuffer = $iParseBuffer;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function HeaderCharset()
|
||||
public function HeaderCharset() : string
|
||||
{
|
||||
return ($this->Headers) ? trim(strtolower($this->Headers->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\Parameter::CHARSET))) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function HeaderBoundary()
|
||||
public function HeaderBoundary() : string
|
||||
{
|
||||
return ($this->Headers) ? trim($this->Headers->ParameterValue(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE,
|
||||
\MailSo\Mime\Enumerations\Parameter::BOUNDARY)) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentType()
|
||||
public function ContentType() : string
|
||||
{
|
||||
return ($this->Headers) ?
|
||||
trim(strtolower($this->Headers->ValueByName(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE))) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentTransferEncoding()
|
||||
public function ContentTransferEncoding() : string
|
||||
{
|
||||
return ($this->Headers) ?
|
||||
trim(strtolower($this->Headers->ValueByName(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_TRANSFER_ENCODING))) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentID()
|
||||
public function ContentID() : string
|
||||
{
|
||||
return ($this->Headers) ? trim($this->Headers->ValueByName(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_ID)) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ContentLocation()
|
||||
public function ContentLocation() : string
|
||||
{
|
||||
return ($this->Headers) ? trim($this->Headers->ValueByName(
|
||||
\MailSo\Mime\Enumerations\Header::CONTENT_LOCATION)) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsFlowedFormat()
|
||||
public function IsFlowedFormat() : bool
|
||||
{
|
||||
$bResult = false;
|
||||
if ($this->Headers)
|
||||
|
|
@ -231,10 +183,7 @@ class Part
|
|||
return $bResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function FileName()
|
||||
public function FileName() : string
|
||||
{
|
||||
$sResult = '';
|
||||
if ($this->Headers)
|
||||
|
|
@ -254,11 +203,7 @@ class Part
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function ParseFromFile($sFileName)
|
||||
public function ParseFromFile(string $sFileName) : self
|
||||
{
|
||||
$rStreamHandle = (@file_exists($sFileName)) ? @fopen($sFileName, 'rb') : false;
|
||||
if (is_resource($rStreamHandle))
|
||||
|
|
@ -274,11 +219,7 @@ class Part
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sRawMessage
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function ParseFromString($sRawMessage)
|
||||
public function ParseFromString(string $sRawMessage) : self
|
||||
{
|
||||
$rStreamHandle = (0 < strlen($sRawMessage)) ?
|
||||
\MailSo\Base\ResourceRegistry::CreateMemoryResource() : false;
|
||||
|
|
@ -299,9 +240,8 @@ class Part
|
|||
|
||||
/**
|
||||
* @param resource $rStreamHandle
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function ParseFromStream($rStreamHandle)
|
||||
public function ParseFromStream($rStreamHandle) : self
|
||||
{
|
||||
$this->Reset();
|
||||
|
||||
|
|
@ -361,10 +301,9 @@ class Part
|
|||
|
||||
/**
|
||||
* @param resource $rStreamHandle
|
||||
* @return \MailSo\Mime\Part
|
||||
*/
|
||||
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, &$iOffset,
|
||||
&$sPrevBuffer, &$sBuffer, &$aBoundaryStack, &$bIsOef, $bNotFirstRead = false)
|
||||
public function ParseFromStreamRecursion($rStreamHandle, &$oCallbackClass, int &$iOffset,
|
||||
string &$sPrevBuffer, string &$sBuffer, array &$aBoundaryStack, bool &$bIsOef, bool $bNotFirstRead = false) : self
|
||||
{
|
||||
$oCallbackClass->StartParseMimePart($this);
|
||||
|
||||
|
|
@ -610,7 +549,7 @@ class Part
|
|||
}
|
||||
|
||||
/**
|
||||
* @return resorce
|
||||
* @return resource
|
||||
*/
|
||||
public function Rewind()
|
||||
{
|
||||
|
|
@ -625,7 +564,7 @@ class Part
|
|||
}
|
||||
|
||||
/**
|
||||
* @return resorce
|
||||
* @return resource
|
||||
*/
|
||||
public function ToStream()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,28 +17,20 @@ namespace MailSo\Mime;
|
|||
*/
|
||||
class PartCollection extends \MailSo\Base\Collection
|
||||
{
|
||||
/**
|
||||
* @access protected
|
||||
*/
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailSo\Mime\PartCollection
|
||||
*/
|
||||
public static function NewInstance()
|
||||
public static function NewInstance() : self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sBoundary
|
||||
*
|
||||
* @return resorce
|
||||
* @return resource
|
||||
*/
|
||||
public function ToStream($sBoundary)
|
||||
public function ToStream(string $sBoundary)
|
||||
{
|
||||
$rResult = null;
|
||||
if (0 < \strlen($sBoundary))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue