EnhancedStatusCode uses ConstantsTrait
Enhanced mail system status codes — outcome classes (RFC 3463).
An enhanced status code has the form class.subject.detail (e.g. 5.1.1,
4.2.2, 2.0.0). This enum carries the class (the leading digit),
which mirrors the SMTP reply class and is what most callers branch on:
| 2 | Success |
| 4 | Persistent transient failure |
| 5 | Permanent failure |
This is the light tier: only the class is enumerated. The subject digit
(the second field — 0 other, 1 addressing, 2 mailbox, 3 mail system,
4 network, 5 protocol, 6 content, 7 security) and the detail digit
are exposed numerically via self::subjectOf() / self::detailOf()
rather than as constants. A future tier may enumerate subjects and the most
common full codes.
EnhancedStatusCode::classOf ( '5.1.1' ) ; // '5'
EnhancedStatusCode::isPermanent( '5.1.1' ) ; // true
EnhancedStatusCode::subjectOf ( '5.1.1' ) ; // 1 (addressing)
Tags
Table of Contents
Constants
- PERMANENT : string = '5'
- `5` — Permanent failure; the message will not be delivered (bounce).
- SUCCESS : string = '2'
- `2` — Success; the requested action completed.
- TRANSIENT : string = '4'
- `4` — Persistent transient failure; the action may succeed if retried.
Methods
- classOf() : string|null
- Returns the class digit (`2` / `4` / `5`) of an enhanced status code.
- detailOf() : int|null
- Returns the detail digit (third field) of an enhanced status code.
- isPermanent() : bool
- Whether the code denotes a permanent failure (`5.x.x`).
- isSuccess() : bool
- Whether the code denotes success (`2.x.x`).
- isTransient() : bool
- Whether the code denotes a persistent transient failure (`4.x.x`).
- isValid() : bool
- Whether a string is a well-formed enhanced status code: a valid class (`2` / `4` / `5`) followed by a subject and detail field of 1–3 digits.
- subjectOf() : int|null
- Returns the subject digit (second field) of an enhanced status code.
Constants
PERMANENT
`5` — Permanent failure; the message will not be delivered (bounce).
public
string
PERMANENT
= '5'
SUCCESS
`2` — Success; the requested action completed.
public
string
SUCCESS
= '2'
TRANSIENT
`4` — Persistent transient failure; the action may succeed if retried.
public
string
TRANSIENT
= '4'
Methods
classOf()
Returns the class digit (`2` / `4` / `5`) of an enhanced status code.
public
static classOf(string $code) : string|null
Parameters
- $code : string
-
An enhanced status code (
class.subject.detail).
Return values
string|null —The class digit, or null when the code is malformed.
detailOf()
Returns the detail digit (third field) of an enhanced status code.
public
static detailOf(string $code) : int|null
Parameters
- $code : string
-
An enhanced status code (
class.subject.detail).
Return values
int|null —The detail number, or null when the code is malformed.
isPermanent()
Whether the code denotes a permanent failure (`5.x.x`).
public
static isPermanent(string $code) : bool
Parameters
- $code : string
-
An enhanced status code.
Return values
boolisSuccess()
Whether the code denotes success (`2.x.x`).
public
static isSuccess(string $code) : bool
Parameters
- $code : string
-
An enhanced status code.
Return values
boolisTransient()
Whether the code denotes a persistent transient failure (`4.x.x`).
public
static isTransient(string $code) : bool
Parameters
- $code : string
-
An enhanced status code.
Return values
boolisValid()
Whether a string is a well-formed enhanced status code: a valid class (`2` / `4` / `5`) followed by a subject and detail field of 1–3 digits.
public
static isValid(string $code) : bool
Parameters
- $code : string
-
The value to test.
Return values
boolsubjectOf()
Returns the subject digit (second field) of an enhanced status code.
public
static subjectOf(string $code) : int|null
Parameters
- $code : string
-
An enhanced status code (
class.subject.detail).
Return values
int|null —The subject number (0–7 in practice), or null when malformed.