Consumes all tokens within parentheses as comments.
Parenthetical comments in mime-headers can be nested within one another. The outer-level continues after an inner-comment ends. Additionally, quoted-literals may exist with comments as well meaning a parenthesis inside a quoted string would not begin or end a comment section.
In order to satisfy these specifications, CommentConsumerService inherits from GenericConsumerService which defines CommentConsumerService and QuotedStringConsumerService as sub-consumers.
Examples: X-Mime-Header: Some value (comment) X-Mime-Header: Some value (comment (nested comment) still in comment) X-Mime-Header: Some value (comment "and part of original ) comment" - still a comment)
- author Zaahid Bateson
Methods |
public __construct(Psr\Log\LoggerInterface $logger, ZBateson |
Properties |
Methods |
protected advanceToNextToken(Iterator $tokens, bool $isStartToken) : static Calls $tokens->next() and returns. The default implementation checks if the current token is an end token, and will not advance past it. Because a comment part of a header can be nested, its implementation must advance past its own 'end' token. |
protected getPartForToken(string $token, bool $isLiteral) : ?ZBateson Instantiates and returns Part\Token objects. Tokens from this and sub-consumers are combined into a Part\CommentPart in processParts. |
protected getTokenSeparators() : array Returns patterns matching open and close parenthesis characters as separators.
|
protected isEndToken(string $token) : bool Returns true if the token is a close parenthesis character, ')'. |
protected isStartToken(string $token) : bool Returns true if the token is an open parenthesis character, '('. |
protected processParts(array $parts) : array Post processing involves creating a single Part\CommentPart out of generated parts from tokens. The Part\CommentPart is returned in an array.
|