AddressPart extends ParameterPart
Holds a single address or name/address pair.
The name part of the address may be mime-encoded, but the email address part can't be mime-encoded. Any whitespace in the email address part is stripped out.
A convenience method, getEmail, is provided for clarity -- but getValue returns the email address as well.
Tags
Table of Contents
- MIME_PART_PATTERN = '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='
- $canIgnoreSpacesAfter : bool
- $canIgnoreSpacesBefore : bool
- $name : string
- $value : string
- __construct() : mixed
- Performs mime-decoding and initializes the address' name and email.
- __toString() : string
- Returns the value of the part (which is a string).
- getEmail() : string
- Returns the email address.
- getName() : string
- Returns the name of the parameter.
- getValue() : string
- Returns the part's value.
- ignoreSpacesAfter() : bool
- Returns true if spaces after this part should be ignored. True is only returned for MimeLiterals if the part ends with a mime-encoded string Tokens if the Token's value is a single space, and for CommentParts.
- ignoreSpacesBefore() : bool
- Returns true if spaces before this part should be ignored. True is only returned for MimeLiterals if the part begins with a mime-encoded string, Tokens if the Token's value is a single space, and for CommentParts.
- convertEncoding() : string
- Ensures the encoding of the passed string is set to UTF-8.
- decodeMime() : string
- Finds and replaces mime parts with their values.
- decodeMatchedEntity() : string
- Decodes a single mime-encoded entity.
Constants
MIME_PART_PATTERN
public
string
MIME_PART_PATTERN
= '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='
Properties
$canIgnoreSpacesAfter
protected
bool
$canIgnoreSpacesAfter
= false
$canIgnoreSpacesBefore
protected
bool
$canIgnoreSpacesBefore
= false
$name
protected
string
$name
$value
protected
string
$value
Methods
__construct()
Performs mime-decoding and initializes the address' name and email.
public
__construct(string $name, string $email) : mixed
The passed $name may be mime-encoded. $email is stripped of any whitespace.
Parameters
- $name : string
- $email : string
Return values
mixed —__toString()
Returns the value of the part (which is a string).
public
__toString() : string
Return values
string —the value
getEmail()
Returns the email address.
public
getEmail() : string
Return values
string —getName()
Returns the name of the parameter.
public
getName() : string
Return values
string —getValue()
Returns the part's value.
public
getValue() : string
Return values
string —the value of the part
ignoreSpacesAfter()
Returns true if spaces after this part should be ignored. True is only returned for MimeLiterals if the part ends with a mime-encoded string Tokens if the Token's value is a single space, and for CommentParts.
public
ignoreSpacesAfter() : bool
Return values
bool —ignoreSpacesBefore()
Returns true if spaces before this part should be ignored. True is only returned for MimeLiterals if the part begins with a mime-encoded string, Tokens if the Token's value is a single space, and for CommentParts.
public
ignoreSpacesBefore() : bool
Return values
bool —convertEncoding()
Ensures the encoding of the passed string is set to UTF-8.
protected
convertEncoding(string $str) : string
Parameters
- $str : string
Return values
string —utf-8 string
decodeMime()
Finds and replaces mime parts with their values.
protected
decodeMime(string $value) : string
The method splits the token value into an array on mime-part-patterns, either replacing a mime part with its value by calling iconv_mime_decode or converts the encoding on the text part by calling convertEncoding.
Parameters
- $value : string
Return values
string —decodeMatchedEntity()
Decodes a single mime-encoded entity.
private
decodeMatchedEntity(string $entity) : string
Unfortunately, mb_decode_header fails for many charsets on PHP 5.4 and PHP 5.5 (even if they're listed as supported). iconv_mime_decode doesn't support all charsets.
Parsing out the charset and body of the encoded entity seems to be the way to go to support the most charsets.
Parameters
- $entity : string