MailMimeParser 2.3

SplitParameterToken extends HeaderPart
in package

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|null
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()  : self
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

$charset

protected string $charset = 'ISO-8859-1'

charset of content in $encodedParts.

$charsetConverter

protected MbWrapper $charsetConverter

the charset converter used for converting strings in HeaderPart::convertEncoding

$encodedParts

protected array<string|int, string> $encodedParts = []

keeps encoded parts values that need to be decoded. Keys are set to the index part of the split parameter and used for sorting before decoding/concatenating.

$language

protected string $language

RFC-1766 (or subset) language code with optional subtags, regions, etc...

$literalParts

protected array<string|int, string> $literalParts = []

contains literal parts that don't require any decoding (and are therefore ISO-8859-1 (technically should be 7bit US-ASCII but allowing 8bit shouldn't be an issue as elsewhere in MMP).

$value

protected string $value

the value of the part

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

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 $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) : self
Parameters
$value : string
$index : int
Return values
self

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