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
|
|
|
namespace ZBateson\MailMimeParser\Header\Consumer; |
8
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Header\Part\HeaderPartFactory; |
10
|
|
|
use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory; |
11
|
|
|
use ZBateson\MailMimeParser\Header\Consumer\Received\DomainConsumer; |
12
|
|
|
use ZBateson\MailMimeParser\Header\Consumer\Received\GenericReceivedConsumer; |
13
|
|
|
use ZBateson\MailMimeParser\Header\Consumer\Received\ReceivedDateConsumer; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Simple service provider for consumer singletons. |
17
|
|
|
* |
18
|
|
|
* @author Zaahid Bateson |
19
|
|
|
*/ |
20
|
|
|
class ConsumerService |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \ZBateson\MailMimeParser\Header\Part\HeaderPartFactory the |
24
|
|
|
* HeaderPartFactory instance used to create HeaderParts. |
25
|
|
|
*/ |
26
|
|
|
protected $partFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var \ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory used for |
30
|
|
|
* GenericConsumer instances. |
31
|
|
|
*/ |
32
|
|
|
protected $mimeLiteralPartFactory; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var Received\DomainConsumer[]| |
36
|
|
|
* Received\GenericReceivedConsumer[]| |
37
|
|
|
* Received\ReceivedDateConsumer[] an array of sub-received header |
38
|
|
|
* consumer instances. |
39
|
|
|
*/ |
40
|
|
|
protected $receivedConsumers = [ |
41
|
|
|
'from' => null, |
42
|
|
|
'by' => null, |
43
|
|
|
'via' => null, |
44
|
|
|
'with' => null, |
45
|
|
|
'id' => null, |
46
|
|
|
'for' => null, |
47
|
|
|
'date' => null |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Sets up the HeaderPartFactory member variable. |
52
|
|
|
* |
53
|
|
|
* @param HeaderPartFactory $partFactory |
54
|
|
|
* @param MimeLiteralPartFactory $mimeLiteralPartFactory |
55
|
|
|
*/ |
56
|
8 |
|
public function __construct(HeaderPartFactory $partFactory, MimeLiteralPartFactory $mimeLiteralPartFactory) |
57
|
|
|
{ |
58
|
8 |
|
$this->partFactory = $partFactory; |
59
|
8 |
|
$this->mimeLiteralPartFactory = $mimeLiteralPartFactory; |
60
|
8 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Returns the AddressBaseConsumer singleton instance. |
64
|
|
|
* |
65
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumer |
66
|
|
|
*/ |
67
|
1 |
|
public function getAddressBaseConsumer() |
68
|
|
|
{ |
69
|
1 |
|
return AddressBaseConsumer::getInstance($this, $this->partFactory); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the AddressConsumer singleton instance. |
74
|
|
|
* |
75
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressConsumer |
76
|
|
|
*/ |
77
|
1 |
|
public function getAddressConsumer() |
78
|
|
|
{ |
79
|
1 |
|
return AddressConsumer::getInstance($this, $this->partFactory); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns the AddressGroupConsumer singleton instance. |
84
|
|
|
* |
85
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressGroupConsumer |
86
|
|
|
*/ |
87
|
1 |
|
public function getAddressGroupConsumer() |
88
|
|
|
{ |
89
|
1 |
|
return AddressGroupConsumer::getInstance($this, $this->partFactory); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the CommentConsumer singleton instance. |
94
|
|
|
* |
95
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\CommentConsumer |
96
|
|
|
*/ |
97
|
1 |
|
public function getCommentConsumer() |
98
|
|
|
{ |
99
|
1 |
|
return CommentConsumer::getInstance($this, $this->partFactory); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns the GenericConsumer singleton instance. |
104
|
|
|
* |
105
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\GenericConsumer |
106
|
|
|
*/ |
107
|
1 |
|
public function getGenericConsumer() |
108
|
|
|
{ |
109
|
1 |
|
return GenericConsumer::getInstance($this, $this->mimeLiteralPartFactory); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Returns the SubjectConsumer singleton instance. |
114
|
|
|
* |
115
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\SubjectConsumer |
116
|
|
|
*/ |
117
|
|
|
public function getSubjectConsumer() |
118
|
|
|
{ |
119
|
|
|
return SubjectConsumer::getInstance($this, $this->mimeLiteralPartFactory); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Returns the QuotedStringConsumer singleton instance. |
124
|
|
|
* |
125
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumer |
126
|
|
|
*/ |
127
|
1 |
|
public function getQuotedStringConsumer() |
128
|
|
|
{ |
129
|
1 |
|
return QuotedStringConsumer::getInstance($this, $this->partFactory); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Returns the DateConsumer singleton instance. |
134
|
|
|
* |
135
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\DateConsumer |
136
|
|
|
*/ |
137
|
1 |
|
public function getDateConsumer() |
138
|
|
|
{ |
139
|
1 |
|
return DateConsumer::getInstance($this, $this->partFactory); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Returns the ParameterConsumer singleton instance. |
144
|
|
|
* |
145
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\ParameterConsumer |
146
|
|
|
*/ |
147
|
1 |
|
public function getParameterConsumer() |
148
|
|
|
{ |
149
|
1 |
|
return ParameterConsumer::getInstance($this, $this->partFactory); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns the consumer instance corresponding to the passed part name of a |
154
|
|
|
* Received header. |
155
|
|
|
* |
156
|
|
|
* @param string $partName |
157
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\Received\FromConsumer |
|
|
|
|
158
|
|
|
*/ |
159
|
|
|
public function getSubReceivedConsumer($partName) |
160
|
|
|
{ |
161
|
|
|
if (empty($this->receivedConsumers[$partName])) { |
162
|
|
|
$consumer = null; |
163
|
|
|
if ($partName === 'from' || $partName === 'by') { |
164
|
|
|
$consumer = new DomainConsumer($this, $this->partFactory, $partName); |
165
|
|
|
} else if ($partName === 'date') { |
166
|
|
|
$consumer = new ReceivedDateConsumer($this, $this->partFactory); |
167
|
|
|
} else { |
168
|
|
|
$consumer = new GenericReceivedConsumer($this, $this->partFactory, $partName); |
169
|
|
|
} |
170
|
|
|
$this->receivedConsumers[$partName] = $consumer; |
171
|
|
|
} |
172
|
|
|
return $this->receivedConsumers[$partName]; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Returns the ReceivedConsumer singleton instance. |
177
|
|
|
* |
178
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\ReceivedConsumer |
179
|
|
|
*/ |
180
|
|
|
public function getReceivedConsumer() |
181
|
|
|
{ |
182
|
|
|
return ReceivedConsumer::getInstance($this, $this->partFactory); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Returns the IdConsumer singleton instance. |
187
|
|
|
* |
188
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\IdConsumer |
189
|
|
|
*/ |
190
|
|
|
public function getIdConsumer() |
191
|
|
|
{ |
192
|
|
|
return IdConsumer::getInstance($this, $this->partFactory); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Returns the IdBaseConsumer singleton instance. |
197
|
|
|
* |
198
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumer |
199
|
|
|
*/ |
200
|
|
|
public function getIdBaseConsumer() |
201
|
|
|
{ |
202
|
|
|
return IdBaseConsumer::getInstance($this, $this->partFactory); |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths