mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 15:07:02 +03:00
Cleanup & Speedup *Collection objects
This commit is contained in:
parent
f6fdb69c65
commit
ebfde6e360
12 changed files with 169 additions and 209 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue