AddressList
in package
RFC 5322 address-list - a comma-separated collection of Address objects.
No group support - a group-shaped segment is treated as one opaque Address rather than parsed structurally.
Tags
Table of Contents
Properties
- $addresses : array<string|int, Address>
Methods
- __construct() : mixed
- __toString() : string
- addAddress() : AddressList
- count() : int
- getAddresses() : array<string|int, Address>
- parse() : AddressList
- Parse a comma-separated address list. Splits only on top-level commas - a comma inside a quoted display name is part of a QUOTED_STRING token, never a top-level delimiter, so it doesn't split the list. Never throws.
- render() : string
- isGroupShaped() : bool
- A group ("display-name: mailbox-list;") is out of scope for this class - detected by a top-level ":" appearing before any top-level "<", AND a top-level ";" appearing somewhere after it (the group's closing terminator), and treated as one opaque, unparsed Address rather than being split on its internal commas. Both conditions are required - a bare unquoted ":" alone (e.g. a display name like "IT: Support" or "Ratio 3:1") is common in real-world addresses and must not be misdetected as a group.
- spliceTokens() : string
Properties
$addresses
protected
array<string|int, Address>
$addresses
= []
Methods
__construct()
public
__construct([array<string|int, Address> $addresses = [] ]) : mixed
Parameters
- $addresses : array<string|int, Address> = []
__toString()
public
__toString() : string
Return values
stringaddAddress()
public
addAddress(Address|string $address[, string|null $name = null ]) : AddressList
Parameters
- $address : Address|string
- $name : string|null = null
Return values
AddressListcount()
public
count() : int
Return values
intgetAddresses()
public
getAddresses() : array<string|int, Address>
Return values
array<string|int, Address>parse()
Parse a comma-separated address list. Splits only on top-level commas - a comma inside a quoted display name is part of a QUOTED_STRING token, never a top-level delimiter, so it doesn't split the list. Never throws.
public
static parse(string $text) : AddressList
Parameters
- $text : string
Return values
AddressListrender()
public
render() : string
Return values
stringisGroupShaped()
A group ("display-name: mailbox-list;") is out of scope for this class - detected by a top-level ":" appearing before any top-level "<", AND a top-level ";" appearing somewhere after it (the group's closing terminator), and treated as one opaque, unparsed Address rather than being split on its internal commas. Both conditions are required - a bare unquoted ":" alone (e.g. a display name like "IT: Support" or "Ratio 3:1") is common in real-world addresses and must not be misdetected as a group.
protected
static isGroupShaped(array<string|int, Token> $tokens) : bool
Parameters
- $tokens : array<string|int, Token>
Return values
boolspliceTokens()
protected
static spliceTokens(string $source, array<string|int, Token> $tokens) : string
Parameters
- $source : string
- $tokens : array<string|int, Token>