generated from Nodarx/template
ad6b7c5eba
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace KTXM\ProviderImap\Smtp\Protocol;
|
|
|
|
/**
|
|
* A parsed SMTP reply: a 3-digit status code plus one or more text lines.
|
|
*/
|
|
final class Reply
|
|
{
|
|
/**
|
|
* @param int $code 3-digit SMTP status code
|
|
* @param list<string> $lines text portion of each reply line (code/separator stripped)
|
|
* @param string $raw the raw wire text (for diagnostics)
|
|
*/
|
|
public function __construct(
|
|
private readonly int $code,
|
|
private readonly array $lines,
|
|
private readonly string $raw,
|
|
) {}
|
|
|
|
public function code(): int
|
|
{
|
|
return $this->code;
|
|
}
|
|
|
|
/**
|
|
* @return list<string>
|
|
*/
|
|
public function lines(): array
|
|
{
|
|
return $this->lines;
|
|
}
|
|
|
|
public function text(): string
|
|
{
|
|
return implode(' ', $this->lines);
|
|
}
|
|
|
|
public function raw(): string
|
|
{
|
|
return $this->raw;
|
|
}
|
|
|
|
/** 2xx — requested action completed. */
|
|
public function isPositiveCompletion(): bool
|
|
{
|
|
return $this->code >= 200 && $this->code < 300;
|
|
}
|
|
|
|
/** 3xx — more input required (e.g. DATA, AUTH challenge). */
|
|
public function isPositiveIntermediate(): bool
|
|
{
|
|
return $this->code >= 300 && $this->code < 400;
|
|
}
|
|
|
|
/** 4xx — transient negative completion (try again later). */
|
|
public function isTransientError(): bool
|
|
{
|
|
return $this->code >= 400 && $this->code < 500;
|
|
}
|
|
|
|
/** 5xx — permanent negative completion. */
|
|
public function isPermanentError(): bool
|
|
{
|
|
return $this->code >= 500;
|
|
}
|
|
}
|