Copied!

Reads headers separated into parameters consisting of an optional main value,
and subsequent name/value pairs - for example text/html; charset=utf-8.

A ParameterConsumer's parts are separated by a semi-colon. Its name/value
pairs are separated with an '=' character.

Parts may be mime-encoded entities. Additionally, a value can be quoted and
comments may exist.

CloneableInstantiable
Methods
public ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::__construct(ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService, ZBateson\MailMimeParser\Header\Part\HeaderPartFactory $partFactory)
public ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::__invoke( $value)
 

Invokes parsing of a header's value into header parts.

public static ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getInstance(ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService, ZBateson\MailMimeParser\Header\Part\HeaderPartFactory $partFactory)
 

Returns the singleton instance for the class.

Properties
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::$consumerService
 
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::$partFactory
 
Methods
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::advanceToNextToken(Iterator $tokens, $isStartToken)
 

Determines if the iterator should be advanced to the next token after
reading tokens or finding a start token.

The default implementation will advance for a start token, but not
advance on the end token of the current consumer, allowing the end token
to be passed up to a higher-level consumer.

protected ZBateson\MailMimeParser\Header\Consumer\GenericConsumer::filterIgnoredSpaces(array $parts)
 

Filters out ignorable spaces between parts in the passed array.

Spaces with parts on either side of it that specify they can be ignored
are filtered out. filterIgnoredSpaces is called from within
processParts, and if needed by an implementing class that overrides
processParts, must be specifically called.

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getAllConsumers()
 

Returns this consumer and all unique sub consumers.

Loops into the sub-consumers (and their sub-consumers, etc...) finding
all unique consumers, and returns them in an array.

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getAllTokenSeparators()
 

Returns a list of regular expression markers for this consumer and all
sub-consumers by calling getTokenSeparators().

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getConsumerTokenParts(Iterator $tokens)
 

Iterates through this consumer's sub-consumers checking if the current
token triggers a sub-consumer's start token and passes control onto that
sub-consumer's parseTokenIntoParts().

If no sub-consumer is responsible for the current token, calls
{@see \AbstractConsumer::getPartForToken()} and returns it in an array.

protected getPartForToken( $token, $isLiteral)
 

Creates and returns a \ZBateson\MailMimeParser\Header\Part\Token out of
the passed string token and returns it, unless the token is an escaped
literal, in which case a LiteralPart is returned.

protected ZBateson\MailMimeParser\Header\Consumer\GenericConsumer::getSubConsumers()
 

Returns \ZBateson\MailMimeParser\Header\Consumer\CommentConsumer and
\ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumer as
sub-consumers.

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getTokenParts(Iterator $tokens)
 

Returns an array of IHeaderPart for the current token on the iterator.

If the current token is a start token from a sub-consumer, the sub-
consumer's {@see \AbstractConsumer::parseTokensIntoParts()} method is
called.

protected getTokenSeparators()
 

Returns semi-colon and equals char as token separators.

protected getTokenSplitPattern()
 

Overridden to use a specialized regex for finding mime-encoded parts
(RFC 2047).

Some implementations seem to place mime-encoded parts within quoted
parameters, and split the mime-encoded parts across multiple split
parameters. The specialized regex doesn't allow double quotes inside a
mime encoded part, so it can be "continued" in another parameter.

protected ZBateson\MailMimeParser\Header\Consumer\GenericConsumer::isEndToken( $token)
 

GenericConsumer doesn't have start/end tokens, and so always returns
false.

protected ZBateson\MailMimeParser\Header\Consumer\GenericConsumer::isStartToken( $token)
 

GenericConsumer doesn't have start/end tokens, and so always returns
false.

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::parseTokensIntoParts(Iterator $tokens)
 

Iterates over the passed token Iterator and returns an array of parsed
IHeaderPart objects.

The method checks each token to see if the token matches a sub-consumer's
start token, or if it matches the current consumer's end token to stop
processing.

If a sub-consumer's start token is matched, the sub-consumer is invoked
and its returned parts are merged to the current consumer's header parts.

After all tokens are read and an array of Header\Parts are constructed,
the array is passed to AbstractConsumer::processParts for any final
processing.

protected processParts(array $parts)
 

Post processing involves creating Part\LiteralPart or Part\ParameterPart
objects out of created Token and LiteralParts.

protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::splitRawValue( $rawValue)
 

Returns an array of split tokens from the input string.

The method calls preg_split using
{@see \AbstractConsumer::getTokenSplitPattern()}. The split array will
not contain any empty parts and will contain the markers.

Methods
private addToSplitPart(ArrayObject $splitParts, $name, $value, $index, $isEncoded)
 

Adds the passed parameter with the given name and value to a
SplitParameterToken, at the passed index. If one with the given name
doesn't exist, it is created.

private finalizeParameterParts(ArrayObject $combined)
 

Loops over parts in the passed array, creating ParameterParts out of any
parsed SplitParameterTokens, replacing them in the array.

The method then calls filterIgnoreSpaces to filter out empty elements in
the combined array and returns an array.

private getPartFor( $strName, $strValue, ArrayObject $splitParts)
 

Instantiates and returns either a MimeLiteralPart if $strName is empty,
a SplitParameterToken if the parameter is a split parameter and is the
first in a series, null if it's a split parameter but is not the first
part in its series, or a ParameterPart is returned otherwise.

If the part is a SplitParameterToken, it's added to the passed
$splitParts as well with its name as a key.

private processTokenPart( $tokenValue, ArrayObject $combined, ArrayObject $splitParts, $strName, $strCat)
 

Handles parameter separator tokens during final processing.

If the end token is found, a new IHeaderPart is assigned to the passed
$combined array. If an '=' character is found, $strCat is assigned to
$strName and emptied.

Returns true if the token was processed, and false otherwise.

Methods
public static ZBateson\MailMimeParser\Header\Consumer\AbstractConsumer::getInstance(ZBateson\MailMimeParser\Header\Consumer\ConsumerService $consumerService, ZBateson\MailMimeParser\Header\Part\HeaderPartFactory $partFactory)
 

Returns the singleton instance for the class.

© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration