AddressGroupConsumerService
        
        extends AddressBaseConsumerService
    
    
            
            in package
            
        
    
    
    
        
            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.
Tags
Table of Contents
- $logger : LoggerInterface
- $partFactory : HeaderPartFactory
- $subConsumers : array<string|int, mixed>
- $tokenSplitPattern : string|null
- __construct() : mixed
- __invoke() : array<string|int, IHeaderPart>
- Invokes parsing of a header's value into header parts.
- getTokenSeparators() : array<string|int, string>
- Overridden to return patterns matching the beginning and end markers of a group address: colon and semi-colon (":" and ";") characters.
- setAddressConsumerService() : void
- Needs to be called in AddressConsumerService's constructor to avoid a circular dependency.
- advanceToNextToken() : static
- Determines if the iterator should be advanced to the next token after reading tokens or finding a start token.
- getAllConsumers() : array<string|int, AbstractConsumerService>
- Returns this consumer and all unique sub consumers.
- getAllTokenSeparators() : array<string|int, string>
- Returns a list of regular expression markers for this consumer and all sub-consumers by calling getTokenSeparators().
- getConsumerTokenParts() : array<string|int, IHeaderPart>
- 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().
- getPartForToken() : IHeaderPart|null
- Constructs and returns an IHeaderPart for the passed string token.
- getTokenParts() : array<string|int, IHeaderPart>
- Returns an array of IHeaderPart for the current token on the iterator.
- getTokenSplitPattern() : string
- Returns a regex pattern used to split the input header string.
- isEndToken() : false
- Returns true if the passed token is a semi-colon.
- isStartToken() : false
- Returns true if the passed token is a colon.
- parseTokensIntoParts() : array<string|int, IHeaderPart>
- Overridden to always call processParts even for an empty set of addresses, since a group could be empty.
- processParts() : array<string|int, AddressGroupPart>|array<string|int, mixed>
- Performs post-processing on parsed parts.
- splitRawValue() : array<string|int, string>
- Returns an array of split tokens from the input string.
- parseRawValue() : array<string|int, IHeaderPart>
- Parses the raw header value into header parts.
Properties
$logger
    protected
        LoggerInterface
    $logger
    
        
        
    
$partFactory
    protected
        HeaderPartFactory
    $partFactory
    
    
        used to construct IHeaderPart objects
$subConsumers
    protected
        array<string|int, mixed>
    $subConsumers
     = []
    
        array of sub-consumers used by this consumer if any, or an empty array if none exist.
$tokenSplitPattern
    private
        string|null
    $tokenSplitPattern
     = null
    
        the generated token split pattern on first run, so it doesn't need to be regenerated every time.
Methods
__construct()
    public
                    __construct(LoggerInterface $logger, HeaderPartFactory $partFactory) : mixed
    
        Parameters
- $logger : LoggerInterface
- $partFactory : HeaderPartFactory
Return values
mixed —__invoke()
Invokes parsing of a header's value into header parts.
    public
                    __invoke(string $value) : array<string|int, IHeaderPart>
    
        Parameters
- $value : string
- 
                    the raw header value 
Return values
array<string|int, IHeaderPart> —the array of parsed parts
getTokenSeparators()
Overridden to return patterns matching the beginning and end markers of a group address: colon and semi-colon (":" and ";") characters.
    public
                    getTokenSeparators() : array<string|int, string>
    
    
    
        Return values
array<string|int, string> —the patterns
setAddressConsumerService()
Needs to be called in AddressConsumerService's constructor to avoid a circular dependency.
    public
                    setAddressConsumerService(AddressConsumerService $subConsumer) : void
    
        Parameters
- $subConsumer : AddressConsumerService
Return values
void —advanceToNextToken()
Determines if the iterator should be advanced to the next token after reading tokens or finding a start token.
    protected
                    advanceToNextToken(Iterator $tokens, bool $isStartToken) : static
        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.
Parameters
- $tokens : Iterator
- 
                    The token iterator. 
- $isStartToken : bool
- 
                    true for the start token. 
Return values
static —getAllConsumers()
Returns this consumer and all unique sub consumers.
    protected
                    getAllConsumers() : array<string|int, AbstractConsumerService>
        Loops into the sub-consumers (and their sub-consumers, etc...) finding all unique consumers, and returns them in an array.
Return values
array<string|int, AbstractConsumerService> —Array of unique consumers.
getAllTokenSeparators()
Returns a list of regular expression markers for this consumer and all sub-consumers by calling getTokenSeparators().
    protected
                    getAllTokenSeparators() : array<string|int, string>
    
    
    
        Return values
array<string|int, string> —Array of regular expression markers.
getConsumerTokenParts()
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().
    protected
                    getConsumerTokenParts(Iterator<string|int, string> $tokens) : array<string|int, IHeaderPart>
        If no sub-consumer is responsible for the current token, calls AbstractConsumerService::getPartForToken() and returns it in an array.
Parameters
- $tokens : Iterator<string|int, string>
Return values
array<string|int, IHeaderPart> —getPartForToken()
Constructs and returns an IHeaderPart for the passed string token.
    protected
                    getPartForToken(string $token, bool $isLiteral) : IHeaderPart|null
        If the token should be ignored, the function must return null.
The default created part uses the instance's partFactory->newInstance method.
Parameters
- $token : string
- 
                    the token 
- $isLiteral : bool
- 
                    set to true if the token represents a literal - e.g. an escaped token 
Return values
IHeaderPart|null —The constructed header part or null if the token should be ignored.
getTokenParts()
Returns an array of IHeaderPart for the current token on the iterator.
    protected
                    getTokenParts(Iterator<string|int, string> $tokens) : array<string|int, IHeaderPart>
        If the current token is a start token from a sub-consumer, the sub- consumer's AbstractConsumerService::parseTokensIntoParts() method is called.
Parameters
- $tokens : Iterator<string|int, string>
- 
                    The token iterator. 
Return values
array<string|int, IHeaderPart> —getTokenSplitPattern()
Returns a regex pattern used to split the input header string.
    protected
                    getTokenSplitPattern() : string
        The default implementation calls AbstractConsumerService::getAllTokenSeparators() and implodes the returned array with the regex OR '|' character as its glue.
Return values
string —the regex pattern
isEndToken()
Returns true if the passed token is a semi-colon.
    protected
                    isEndToken(string $token) : false
    
        Parameters
- $token : string
- 
                    The current token 
Return values
false —isStartToken()
Returns true if the passed token is a colon.
    protected
                    isStartToken(string $token) : false
    
        Parameters
- $token : string
- 
                    The current token 
Return values
false —parseTokensIntoParts()
Overridden to always call processParts even for an empty set of addresses, since a group could be empty.
    protected
                    parseTokensIntoParts(Iterator $tokens) : array<string|int, IHeaderPart>
    
        Parameters
- $tokens : Iterator
Return values
array<string|int, IHeaderPart> —processParts()
Performs post-processing on parsed parts.
    protected
                    processParts(array<string|int, IHeaderPart> $parts) : array<string|int, AddressGroupPart>|array<string|int, mixed>
        Returns an array with a single AddressGroupPart element with all email addresses from this and any sub-groups.
Parameters
- $parts : array<string|int, IHeaderPart>
Return values
array<string|int, AddressGroupPart>|array<string|int, mixed> —splitRawValue()
Returns an array of split tokens from the input string.
    protected
                    splitRawValue(string $rawValue) : array<string|int, string>
        The method calls preg_split using AbstractConsumerService::getTokenSplitPattern(). The split array will not contain any empty parts and will contain the markers.
Parameters
- $rawValue : string
- 
                    the raw string 
Return values
array<string|int, string> —the array of tokens
parseRawValue()
Parses the raw header value into header parts.
    private
                    parseRawValue(string $value) : array<string|int, IHeaderPart>
        Calls splitTokens to split the value into token part strings, then calls parseParts to parse the returned array.
Parameters
- $value : string
Return values
array<string|int, IHeaderPart> —the array of parsed parts