Copied!

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.

CloneableInstantiable
Methods
public __construct(ZBateson\MbWrapper\MbWrapper $charsetConverter, $name)
 

Initializes a SplitParameterToken.

  • param string $name the parameter's name
public ZBateson\MailMimeParser\Header\Part\HeaderPart::__toString() : string
 

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

  • return string the value
public addPart( $value, $isEncoded, $index)
 

Adds the passed part to the running array of values.

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.

  • param string $value
  • param bool $isEncoded
  • param int $index
public getLanguage()
 

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

  • return string
public getName()
 

Returns the name of the parameter.

  • return string
public getValue() : ?string
 

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

public ZBateson\MailMimeParser\Header\Part\HeaderPart::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.

public ZBateson\MailMimeParser\Header\Part\HeaderPart::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.

Properties
protected $charset = 'ISO-8859-1'
 
  • var string charset of content in $encodedParts.
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::$charsetConverter = NULL
 
  • var \MbWrapper $charsetConverter the charset converter used for converting strings in HeaderPart::convertEncoding
protected $encodedParts = []
 
  • var string[] 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.
protected $language = NULL
 
  • var string RFC-1766 (or subset) language code with optional subtags, regions, etc...
protected $literalParts = []
 
  • var string[] 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).
protected $name = NULL
 
  • var string name of the parameter.
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::$value = NULL
 
  • var string the value of the part
Methods
protected ZBateson\MailMimeParser\Header\Part\HeaderPart::convertEncoding(string $str, string $from = 'ISO-8859-1', bool $force = false) : string
 

Ensures the encoding of the passed string is set to UTF-8.

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'.

  • return string utf-8 string
protected extractMetaInformationAndValue(string $value, int $index) : 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.

Methods
private getNextEncodedValue() : string
 

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

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.

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration