MailMimeParser 0.4

CommentPart extends MimeLiteralPart

Represents a mime header comment -- text in a structured mime header value existing within parentheses.

Tags
author

Zaahid Bateson

Table of Contents

MIME_PART_PATTERN  = '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='
$canIgnoreSpacesAfter  : bool
$canIgnoreSpacesBefore  : bool
$comment  : string
$value  : string
__construct()  : mixed
Constructs a MimeLiteralPart, decoding the value if it's mime-encoded.
__toString()  : string
Returns the value of the part (which is a string).
getComment()  : string
Returns the comment's text.
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

$canIgnoreSpacesBefore

protected bool $canIgnoreSpacesBefore = false

Methods

__construct()

Constructs a MimeLiteralPart, decoding the value if it's mime-encoded.

public __construct(string $token) : mixed
Parameters
$token : string
Return values
mixed —

__toString()

Returns the value of the part (which is a string).

public __toString() : string
Return values
string —

the value

getComment()

Returns the comment's text.

public getComment() : 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
Return values
string —

Search results