1 | <?php |
||
22 | class GenericConsumer extends AbstractConsumer |
||
23 | { |
||
24 | /** |
||
25 | * Returns \ZBateson\MailMimeParser\Header\Consumer\CommentConsumer and |
||
26 | * \ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumer as |
||
27 | * sub-consumers. |
||
28 | * |
||
29 | * @return AbstractConsumer[] the sub-consumers |
||
30 | */ |
||
31 | protected function getSubConsumers() |
||
38 | |||
39 | /** |
||
40 | * Returns the regex '\s+' (whitespace) pattern matcher as a token marker so |
||
41 | * the header value is split along whitespace characters. GenericConsumer |
||
42 | * filters out whitespace-only tokens from getPartForToken. |
||
43 | * |
||
44 | * The whitespace character delimits mime-encoded parts for decoding. |
||
45 | * |
||
46 | * @return string[] an array of regex pattern matchers |
||
47 | */ |
||
48 | protected function getTokenSeparators() |
||
52 | |||
53 | /** |
||
54 | * GenericConsumer doesn't have start/end tokens, and so always returns |
||
55 | * false. |
||
56 | * |
||
57 | * @param string $token |
||
58 | * @return boolean false |
||
59 | */ |
||
60 | protected function isEndToken($token) |
||
64 | |||
65 | /** |
||
66 | * GenericConsumer doesn't have start/end tokens, and so always returns |
||
67 | * false. |
||
68 | * |
||
69 | * @param string $token |
||
70 | * @return boolean false |
||
71 | */ |
||
72 | protected function isStartToken($token) |
||
76 | |||
77 | /** |
||
78 | * Returns true if a space should be added based on the passed last and next |
||
79 | * parts. |
||
80 | * |
||
81 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $nextPart |
||
82 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $lastPart |
||
83 | * @return bool |
||
84 | */ |
||
85 | private function shouldAddSpace(HeaderPart $nextPart, HeaderPart $lastPart) |
||
89 | |||
90 | /** |
||
91 | * Loops over the $parts array from the current position, checks if the |
||
92 | * space should be added, then adds it to $retParts and returns. |
||
93 | * |
||
94 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
95 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $retParts |
||
96 | * @param int $curIndex |
||
97 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $spacePart |
||
98 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $lastPart |
||
99 | */ |
||
100 | private function addSpaceToRetParts( |
||
117 | |||
118 | /** |
||
119 | * Checks if the passed space part should be added to the returned parts and |
||
120 | * adds it. |
||
121 | * |
||
122 | * Never adds a space if it's the first part, otherwise only add it if |
||
123 | * either part isn't set to ignore the space |
||
124 | * |
||
125 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
126 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $retParts |
||
127 | * @param int $curIndex |
||
128 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $spacePart |
||
129 | */ |
||
130 | private function addSpaces(array $parts, array &$retParts, $curIndex, HeaderPart &$spacePart = null) |
||
137 | |||
138 | /** |
||
139 | * Returns true if the passed HeaderPart is a Token instance and a space. |
||
140 | * |
||
141 | * @param HeaderPart $part |
||
142 | * @return bool |
||
143 | */ |
||
144 | private function isSpaceToken(HeaderPart $part) |
||
148 | |||
149 | /** |
||
150 | * Filters out ignorable spaces between parts in the passed array. |
||
151 | * |
||
152 | * Spaces with parts on either side of it that specify they can be ignored |
||
153 | * are filtered out. filterIgnoredSpaces is called from within |
||
154 | * processParts, and if needed by an implementing class that overrides |
||
155 | * processParts, must be specifically called. |
||
156 | * |
||
157 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
158 | * @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[] |
||
159 | */ |
||
160 | protected function filterIgnoredSpaces(array $parts) |
||
177 | |||
178 | /** |
||
179 | * Overridden to combine all part values into a single string and return it |
||
180 | * as an array with a single element. |
||
181 | * |
||
182 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
183 | * @return \ZBateson\MailMimeParser\Header\Part\LiteralPart[]|array |
||
184 | */ |
||
185 | protected function processParts(array $parts) |
||
194 | } |
||
195 |