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 $lastPart |
||
82 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $nextPart |
||
83 | * @return bool |
||
84 | */ |
||
85 | private function shouldAddSpace(HeaderPart $nextPart, HeaderPart $lastPart = null) |
||
89 | |||
90 | /** |
||
91 | * Adds the passed $spacePart to the $retParts array if it should be added. |
||
92 | * |
||
93 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $spacePart |
||
94 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $retParts |
||
95 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $nextPart |
||
96 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $lastPart |
||
97 | * @return bool |
||
98 | */ |
||
99 | private function addSpaceToRetParts(HeaderPart &$spacePart, array &$retParts, HeaderPart $nextPart, HeaderPart $lastPart = null) |
||
108 | |||
109 | /** |
||
110 | * Checks if the passed space part should be added to the returned parts and |
||
111 | * adds it. |
||
112 | * |
||
113 | * Never adds a space if it's the first part, otherwise only add it if |
||
114 | * either part isn't set to ignore the space |
||
115 | * |
||
116 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
117 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $retParts |
||
118 | * @param int $curIndex |
||
119 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart $spacePart |
||
120 | */ |
||
121 | private function addSpaces(array $parts, array &$retParts, $curIndex, HeaderPart &$spacePart = null) |
||
135 | |||
136 | /** |
||
137 | * Returns true if the passed HeaderPart is a Token instance and a space. |
||
138 | * |
||
139 | * @param HeaderPart $part |
||
140 | * @return bool |
||
141 | */ |
||
142 | private function isSpaceToken(HeaderPart $part) |
||
146 | |||
147 | /** |
||
148 | * Filters out ignorable spaces between parts in the passed array. |
||
149 | * |
||
150 | * Spaces with parts on either side of it that specify they can be ignored |
||
151 | * are filtered out. filterIgnoredSpaces is called from within |
||
152 | * processParts, and if needed by an implementing class that overrides |
||
153 | * processParts, must be specifically called. |
||
154 | * |
||
155 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
156 | * @return \ZBateson\MailMimeParser\Header\Part\HeaderPart[] |
||
157 | */ |
||
158 | protected function filterIgnoredSpaces(array $parts) |
||
175 | |||
176 | /** |
||
177 | * Overridden to combine all part values into a single string and return it |
||
178 | * as an array with a single element. |
||
179 | * |
||
180 | * @param \ZBateson\MailMimeParser\Header\Part\HeaderPart[] $parts |
||
181 | * @return \ZBateson\MailMimeParser\Header\Part\LiteralPart[]|array |
||
182 | */ |
||
183 | protected function processParts(array $parts) |
||
192 | } |
||
193 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.