1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
4
|
|
|
* |
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace ZBateson\MailMimeParser\Header\Consumer; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A minimal implementation of AbstractConsumerService splitting tokens by |
12
|
|
|
* whitespace. |
13
|
|
|
* |
14
|
|
|
* Although the class doesn't have any abstract methods, it's defined as |
15
|
|
|
* abstract because it doesn't define specific sub-consumers as constructor |
16
|
|
|
* dependencies, and so is defined as abstract to avoid its direct use (use |
17
|
|
|
* the concrete GenericConsumerService or GenericConsumerMimeLiteralPartService |
18
|
|
|
* classes instead). |
19
|
|
|
* |
20
|
|
|
* @author Zaahid Bateson |
21
|
|
|
*/ |
22
|
|
|
abstract class AbstractGenericConsumerService extends AbstractConsumerService |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Returns the regex '\s+' (whitespace) pattern matcher as a token marker so |
26
|
|
|
* the header value is split along whitespace characters. |
27
|
|
|
* |
28
|
|
|
* @return string[] an array of regex pattern matchers |
29
|
|
|
*/ |
30
|
|
|
protected function getTokenSeparators() : array |
31
|
|
|
{ |
32
|
|
|
return ['\s+']; |
33
|
|
|
} |
34
|
1 |
|
|
35
|
|
|
/** |
36
|
1 |
|
* AbstractGenericConsumerService doesn't have start/end tokens, and so |
37
|
|
|
* always returns false. |
38
|
|
|
*/ |
39
|
|
|
protected function isEndToken(string $token) : bool |
40
|
|
|
{ |
41
|
|
|
return false; |
42
|
|
|
} |
43
|
105 |
|
|
44
|
|
|
/** |
45
|
105 |
|
* AbstractGenericConsumerService doesn't have start/end tokens, and so |
46
|
|
|
* always returns false. |
47
|
|
|
* |
48
|
|
|
* @codeCoverageIgnore |
49
|
|
|
*/ |
50
|
|
|
protected function isStartToken(string $token) : bool |
51
|
|
|
{ |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Overridden to combine all part values into a single string and return it |
57
|
|
|
* as an array with a single element. |
58
|
|
|
* |
59
|
|
|
* The returned IHeaderParts are all LiteralParts. |
60
|
|
|
* |
61
|
|
|
* @param \ZBateson\MailMimeParser\Header\IHeaderPart[] $parts |
62
|
|
|
* @return \ZBateson\MailMimeParser\Header\IHeaderPart[] |
63
|
|
|
*/ |
64
|
74 |
|
protected function processParts(array $parts) : array |
65
|
|
|
{ |
66
|
74 |
|
return [$this->partFactory->newContainerPart($parts)]; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|