MailMimeParser 0.4

ParameterPart extends MimeLiteralPart

Represents a name/value pair part of a header.

Tags
author

Zaahid Bateson

Table of Contents

MIME_PART_PATTERN  = '=\?[A-Za-z\-_0-9]+\?[QBqb]\?[^\?]+\?='
$canIgnoreSpacesAfter  : bool
$canIgnoreSpacesBefore  : bool
$name  : string
$value  : string
__construct()  : mixed
Constructs a ParameterPart out of a name/value pair. The name and value are both mime-decoded if necessary.
__toString()  : string
Returns the value of the part (which is a string).
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

$canIgnoreSpacesBefore

protected bool $canIgnoreSpacesBefore = false

Methods

__construct()

Constructs a ParameterPart out of a name/value pair. The name and value are both mime-decoded if necessary.

public __construct(string $name, string $value) : mixed
Parameters
$name : string
$value : string
Return values
mixed

__toString()

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

public __toString() : string
Return values
string

the value

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
Return values
string

Search results