<?php
/**
 * This code is licensed under AGPLv3 license or Afterlogic Software License
 * if commercial version of the product was purchased.
 * For full statements of the licenses see LICENSE-AFTERLOGIC and LICENSE-AGPL3 files.
 */

namespace MailSo\Mail;

/**
 * @license https://www.gnu.org/licenses/agpl-3.0.html AGPL-3.0
 * @license https://afterlogic.com/products/common-licensing Afterlogic Software License
 * @copyright Copyright (c) 2019, Afterlogic Corp.
 *
 * @category MailSo
 * @package Mail
 */
class AttachmentCollection extends \MailSo\Base\Collection
{
    /**
     * @access protected
     */
    protected function __construct()
    {
        parent::__construct();
    }

    /**
     * @return \MailSo\Mail\AttachmentCollection
     */
    public static function NewInstance()
    {
        return new self();
    }

    /**
     * @return int
     */
    public function InlineCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && $oAttachment->IsInline();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }

    /**
     * @return int
     */
    public function NonInlineCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && !$oAttachment->IsInline();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }

    /**
     * @return int
     */
    public function ImageCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && $oAttachment->IsImage();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }

    /**
     * @return int
     */
    public function ArchiveCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && $oAttachment->IsArchive();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }

    /**
     * @return int
     */
    public function PdfCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && $oAttachment->IsPdf();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }

    /**
     * @return int
     */
    public function DocCount()
    {
        $aList = $this->FilterList(function ($oAttachment) {
            return $oAttachment && $oAttachment->IsDoc();
        });

        return \is_array($aList) ? \count($aList) : 0;
    }
}
