MailMimeParser 1.1

SplitParameterToken extends HeaderPart

Holds a running value for an RFC-2231 split header parameter.

ParameterConsumer creates SplitParameterTokens when a split header parameter is first found, and adds subsequent split parts to an already created one if the parameter name matches.

Tags
author

Zaahid Bateson

Table of Contents

$charset  : string
$charsetConverter  : MbWrapper
$encodedParts  : array<string|int, string>
$language  : string
$literalParts  : array<string|int, string>
$name  : string
$value  : string
__construct()  : mixed
Initializes a SplitParameterToken.
__toString()  : string
Returns the value of the part (which is a string).
addPart()  : mixed
Adds the passed part to the running array of values.
getLanguage()  : string
Returns the language of the parameter if set, or null if not.
getName()  : string
Returns the name of the parameter.
getValue()  : string
Reconstructs the value of the split parameter into a single UTF-8 string and returns it.
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.
extractMetaInformationAndValue()  : mixed
Extracts charset and language from an encoded value, setting them on the current object if $index is 0 and adds the value part to the encodedParts array.
getNextEncodedValue()  : string
Traverses $this->encodedParts until a non-sequential key is found, or the end of the array is found.

Properties

$charsetConverter

protected MbWrapper $charsetConverter

Methods

__construct()

Initializes a SplitParameterToken.

public __construct(MbWrapper $charsetConverter, string $name) : mixed
Parameters
$charsetConverter : MbWrapper
$name : string

the parameter's name

Return values
mixed

__toString()

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

public __toString() : string
Return values
string

the value

addPart()

Adds the passed part to the running array of values.

public addPart(string $value, bool $isEncoded, int $index) : mixed

If $isEncoded is true, language and charset info is extracted from the value, and the value is decoded before returning in getValue.

The value of the parameter is sorted based on the passed $index arguments when adding before concatenating when re-constructing the value.

Parameters
$value : string
$isEncoded : bool
$index : int
Return values
mixed

getLanguage()

Returns the language of the parameter if set, or null if not.

public getLanguage() : string
Return values
string

getName()

Returns the name of the parameter.

public getName() : string
Return values
string

getValue()

Reconstructs the value of the split parameter into a single UTF-8 string and returns it.

public getValue() : string
Return values
string

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 $from = 'ISO-8859-1' ][, bool $force = false ]) : string

The method does nothing if the passed $from charset is UTF-8 already, or if $force is set to false and mb_check_encoding for $str returns true for 'UTF-8'.

Parameters
$str : string
$from : string = 'ISO-8859-1'
$force : bool = false
Return values
string

utf-8 string

extractMetaInformationAndValue()

Extracts charset and language from an encoded value, setting them on the current object if $index is 0 and adds the value part to the encodedParts array.

protected extractMetaInformationAndValue(string $value, int $index) : mixed
Parameters
$value : string
$index : int
Return values
mixed

getNextEncodedValue()

Traverses $this->encodedParts until a non-sequential key is found, or the end of the array is found.

private getNextEncodedValue() : string

This allows encoded parts of a split parameter to be split anywhere and reconstructed.

The returned string is converted to UTF-8 before being returned.

Return values
string

Search results