Make IMAP QUOTA rfc2087 a trait

This commit is contained in:
djmaze 2021-11-03 12:09:43 +01:00
parent 88f603ac3d
commit 6e1cf74908
2 changed files with 50 additions and 32 deletions

View file

@ -0,0 +1,48 @@
<?php
/*
* This file is part of MailSo.
*
* (c) 2014 Usenko Timur
* (c) 2021 DJMaze
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://datatracker.ietf.org/doc/html/rfc2087
*/
namespace MailSo\Imap\Commands;
/**
* @category MailSo
* @package Imap
*/
trait Quota
{
/**
* https://datatracker.ietf.org/doc/html/rfc2087#section-4.2
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Quota(string $sRootName = '') : ?array
{
return $this->IsSupported('QUOTA')
? $this->SendRequestGetResponse("GETQUOTA {$this->EscapeString($sRootName)}")->getQuotaResult()
: null;
}
/**
* https://datatracker.ietf.org/doc/html/rfc2087#section-4.3
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function QuotaRoot(string $sFolderName = 'INBOX') : ?array
{
return $this->IsSupported('QUOTA')
? $this->SendRequestGetResponse("GETQUOTAROOT {$this->EscapeString($sFolderName)}")->getQuotaResult()
: null;
}
}

View file

@ -20,6 +20,7 @@ class ImapClient extends \MailSo\Net\NetClient
use Traits\ResponseParser;
// use Commands\ACL;
use Commands\Metadata;
use Commands\Quota;
const
TAG_PREFIX = 'TAG';
@ -739,38 +740,6 @@ class ImapClient extends \MailSo\Net\NetClient
return $oResult->getFetchResult($this->oLogger);
}
/**
* https://datatracker.ietf.org/doc/html/rfc2087#section-4.2
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function Quota(string $sRootName = '') : ?array
{
if ($this->IsSupported('QUOTA'))
{
return $this->SendRequestGetResponse("GETQUOTA {$this->EscapeString($sRootName)}")->getQuotaResult();
}
return null;
}
/**
* https://datatracker.ietf.org/doc/html/rfc2087#section-4.3
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function QuotaRoot(string $sFolderName = 'INBOX') : ?array
{
if ($this->IsSupported('QUOTA'))
{
return $this->SendRequestGetResponse("GETQUOTAROOT {$this->EscapeString($sFolderName)}")->getQuotaResult();
}
return null;
}
/**
* See https://tools.ietf.org/html/rfc5256
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
@ -1200,6 +1169,7 @@ class ImapClient extends \MailSo\Net\NetClient
}
/**
* RFC 2971
* Don't have to be logged in to call this command
*/
public function ServerID() : string