Copied!

Parses a single group of addresses (as a named-group part of an address header).

Finds addresses using its AddressConsumerService sub-consumer separated by commas, and ends processing once a semi-colon is found.

Prior to returning to its calling client, AddressGroupConsumerService constructs a single Part\AddressGroupPart object filling it with all located addresses, and returns it.

The AddressGroupConsumerService extends AddressBaseConsumerService to define start/end tokens, token separators, and construct a Part\AddressGroupPart to return.

CloneableInstantiable
Methods
public __construct(Psr\Log\LoggerInterface $logger, ZBateson\MailMimeParser\Header\Part\HeaderPartFactory $partFactory)
public ZBateson\MailMimeParser\Header\Consumer\AbstractConsumerService::__invoke(string $value) : array
public getTokenSeparators() : array
 

Overridden to return patterns matching the beginning and end markers of a group address: colon and semi-colon (":" and ";") characters.

  • return string[] the patterns
public setAddressConsumerService(ZBateson\MailMimeParser\Header\Consumer\AddressConsumerService $subConsumer) : void
 

Needs to be called in AddressConsumerService's constructor to avoid a circular dependency.

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\AddressBaseConsumerService::advanceToNextToken(Iterator $tokens, bool $isStartToken) : static
 

Disables advancing for start tokens.

The start token for AddressBaseConsumerService is part of an {@see \AddressPart} (or a sub-consumer) and so must be passed on.

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 ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumerService::getPartForToken(string $token, bool $isLiteral) : ?ZBateson\MailMimeParser\Header\IHeaderPart
 

Never reached by AddressBaseConsumerService. Overridden to satisfy AbstractConsumerService.

  • codeCoverageIgnore
protected ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumerService::getTokenParts(Iterator $tokens) : array
 

Overridden so tokens aren't handled at this level, and instead are passed on to AddressConsumerService.

  • return \ZBateson\MailMimeParser\Header\IHeaderPart[]|array
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 passed token is a semi-colon.

protected isStartToken(string $token) : bool
 

Returns true if the passed token is a colon.

protected parseTokensIntoParts(Iterator $tokens) : array
 

Overridden to always call processParts even for an empty set of addresses, since a group could be empty.

  • param \Iterator $tokens
  • return \IHeaderPart[]
protected processParts(array $parts) : array
 

Performs post-processing on parsed parts.

Returns an array with a single {@see \AddressGroupPart} element with all email addresses from this and any sub-groups.

  • param \ZBateson\MailMimeParser\Header\IHeaderPart[] $parts
  • return \AddressGroupPart[]|array
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