mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-02 10:28:50 +03:00
abstract class ResponseStatus to BackedEnum
This commit is contained in:
parent
bcd9657ce4
commit
75303886d3
4 changed files with 14 additions and 10 deletions
|
|
@ -16,11 +16,11 @@ namespace MailSo\Imap\Enumerations;
|
|||
* @package Imap
|
||||
* @subpackage Enumerations
|
||||
*/
|
||||
abstract class ResponseStatus
|
||||
enum ResponseStatus: string
|
||||
{
|
||||
const OK = 'OK';
|
||||
const NO = 'NO';
|
||||
const BAD = 'BAD';
|
||||
const BYE = 'BYE';
|
||||
const PREAUTH = 'PREAUTH';
|
||||
case OK = 'OK';
|
||||
case NO = 'NO';
|
||||
case BAD = 'BAD';
|
||||
case BYE = 'BYE';
|
||||
case PREAUTH = 'PREAUTH';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -503,8 +503,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
|
||||
if ($oResponse->IsStatusResponse
|
||||
&& ResponseType::UNTAGGED === $oResponse->ResponseType
|
||||
&& Enumerations\ResponseStatus::PREAUTH === $oResponse->StatusOrIndex
|
||||
// && (Enumerations\ResponseStatus::PREAUTH === $oResponse->StatusOrIndex || Enumerations\ResponseStatus::BYE === $oResponse->StatusOrIndex)
|
||||
&& Enumerations\ResponseStatus::PREAUTH === $oResponse->ResponseStatus
|
||||
// && (Enumerations\ResponseStatus::PREAUTH === $oResponse->ResponseStatus || Enumerations\ResponseStatus::BYE === $oResponse->ResponseStatus)
|
||||
) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace MailSo\Imap;
|
||||
|
||||
use MailSo\Imap\Enumerations\ResponseStatus;
|
||||
use MailSo\Imap\Enumerations\ResponseType;
|
||||
|
||||
/**
|
||||
|
|
@ -29,6 +30,8 @@ class Response
|
|||
|
||||
public bool $IsStatusResponse = false;
|
||||
|
||||
public ?ResponseStatus $ResponseStatus = null;
|
||||
|
||||
public ResponseType $ResponseType = ResponseType::UNKNOWN;
|
||||
|
||||
public ?string $Tag = null;
|
||||
|
|
@ -46,7 +49,8 @@ class Response
|
|||
{
|
||||
$value = \strtoupper($value);
|
||||
$this->StatusOrIndex = $value;
|
||||
$this->IsStatusResponse = \defined("\\MailSo\\Imap\\Enumerations\\ResponseStatus::{$value}");
|
||||
$this->ResponseStatus = ResponseStatus::tryFrom($value);
|
||||
$this->IsStatusResponse = !!$this->ResponseStatus;
|
||||
}
|
||||
|
||||
public function setTag(string $value) : void
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ResponseCollection extends \MailSo\Base\Collection
|
|||
throw new Exceptions\InvalidResponseException($this);
|
||||
}
|
||||
|
||||
if (Enumerations\ResponseStatus::OK !== $oItem->StatusOrIndex) {
|
||||
if (Enumerations\ResponseStatus::OK !== $oItem->ResponseStatus) {
|
||||
throw new Exceptions\NegativeResponseException($this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue