Copied!

Represents a quoted part of a header value starting at a double quote, and ending at the next double quote.

A quoted-pair part in a header is a literal. There are no sub-consumers for it and a Part\LiteralPart is returned.

Newline characters (CR and LF) are stripped entirely from the quoted part. This is based on the example at:

https://tools.ietf.org/html/rfc822#section-3.1.1

And https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html in section 7.2.1 splitting the boundary.

CloneableInstantiable
Methods
public ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::__construct(Psr\Log\LoggerInterface $logger, ZBateson\MailMimeParser\Header\Part\HeaderPartFactory $partFactory, array $subConsumers = [])
 
  • param \AbstractConsumerService[] $subConsumers
public ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::__invoke(string $value) : array
Properties
protected Psr\Log\LoggerInterface ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::$logger
protected ZBateson\MailMimeParser\Header\Part\HeaderPartFactory ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::$partFactory
 
  • var \HeaderPartFactory used to construct IHeaderPart objects
protected array ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::$subConsumers = []
 
  • var \AbstractConsumerService[] array of sub-consumers used by this consumer if any, or an empty array if none exist.
Methods
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::advanceToNextToken(Iterator $tokens, bool $isStartToken) : static
 

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.

  • param \Iterator $tokens The token iterator.
  • param bool $isStartToken true for the start token.
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::getAllConsumers() : array
 

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.

  • return \AbstractConsumerService[] Array of unique consumers.
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::getAllTokenSeparators() : array
 

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

  • return string[] Array of regular expression markers.
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::getConsumerTokenParts(Iterator $tokens) : array
 

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 \AbstractConsumerService::getPartForToken()} and returns it in an array.

  • param \Iterator<string> $tokens
  • return \IHeaderPart[]
protected getPartForToken(string $token, bool $isLiteral) : ?ZBateson\MailMimeParser\Header\IHeaderPart
 

Constructs a LiteralPart and returns it.

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

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 \AbstractConsumerService::parseTokensIntoParts()} method is called.

  • param \Iterator<string> $tokens The token iterator.
  • return \IHeaderPart[]
protected getTokenSeparators() : array
 

Returns a single regex pattern for a double quote.

  • return string[]
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::getTokenSplitPattern() : string
 

Returns a regex pattern used to split the input header string.

The default implementation calls {@see \AbstractConsumerService::getAllTokenSeparators()} and implodes the returned array with the regex OR '|' character as its glue.

  • return string the regex pattern
protected isEndToken(string $token) : bool
 

Returns true if the token is a double quote.

protected isStartToken(string $token) : bool
 

Returns true if the token is a double quote.

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

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 {@see \AbstractConsumerService::processParts} for any final processing if there are any parts.

  • param \Iterator<string> $tokens An iterator over a string of tokens
  • return \IHeaderPart[] An array of parsed parts
protected processParts(array $parts) : array
 

Overridden to combine all part values into a single string and return it as an array with a single element.

The returned IHeaderParts is an array containing a single QuotedLiteralPart.

  • param \IHeaderPart[] $parts
  • return \IHeaderPart[]
protected ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::splitRawValue( $rawValue) : array
 

Returns an array of split tokens from the input string.

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

  • param string $rawValue the raw string
  • return string[] the array of tokens
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration