|
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
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Simple service provider for consumer singletons. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Zaahid Bateson |
|
16
|
|
|
*/ |
|
17
|
|
|
class ConsumerService |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var \ZBateson\MailMimeParser\Header\Part\HeaderPartFactory the |
|
21
|
|
|
* HeaderPartFactory instance used to create HeaderParts. |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $partFactory; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var \ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory used for |
|
27
|
|
|
* GenericConsumer instances. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $mimeLiteralPartFactory; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Sets up the HeaderPartFactory member variable. |
|
33
|
|
|
* |
|
34
|
|
|
* @param HeaderPartFactory $partFactory |
|
35
|
|
|
*/ |
|
36
|
8 |
|
public function __construct(HeaderPartFactory $partFactory, MimeLiteralPartFactory $mimeLiteralPartFactory) |
|
37
|
|
|
{ |
|
38
|
8 |
|
$this->partFactory = $partFactory; |
|
39
|
8 |
|
$this->mimeLiteralPartFactory = $mimeLiteralPartFactory; |
|
40
|
8 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns the AddressBaseConsumer singleton instance. |
|
44
|
|
|
* |
|
45
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressBaseConsumer |
|
46
|
|
|
*/ |
|
47
|
1 |
|
public function getAddressBaseConsumer() |
|
48
|
|
|
{ |
|
49
|
1 |
|
return AddressBaseConsumer::getInstance($this, $this->partFactory); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Returns the AddressConsumer singleton instance. |
|
54
|
|
|
* |
|
55
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressConsumer |
|
56
|
|
|
*/ |
|
57
|
1 |
|
public function getAddressConsumer() |
|
58
|
|
|
{ |
|
59
|
1 |
|
return AddressConsumer::getInstance($this, $this->partFactory); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns the AddressGroupConsumer singleton instance. |
|
64
|
|
|
* |
|
65
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\AddressGroupConsumer |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function getAddressGroupConsumer() |
|
68
|
|
|
{ |
|
69
|
1 |
|
return AddressGroupConsumer::getInstance($this, $this->partFactory); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Returns the CommentConsumer singleton instance. |
|
74
|
|
|
* |
|
75
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\CommentConsumer |
|
76
|
|
|
*/ |
|
77
|
1 |
|
public function getCommentConsumer() |
|
78
|
|
|
{ |
|
79
|
1 |
|
return CommentConsumer::getInstance($this, $this->partFactory); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Returns the GenericConsumer singleton instance. |
|
84
|
|
|
* |
|
85
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\GenericConsumer |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function getGenericConsumer() |
|
88
|
|
|
{ |
|
89
|
1 |
|
return GenericConsumer::getInstance($this, $this->mimeLiteralPartFactory); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Returns the SubjectConsumer singleton instance. |
|
94
|
|
|
* |
|
95
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\SubjectConsumer |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getSubjectConsumer() |
|
98
|
|
|
{ |
|
99
|
|
|
return SubjectConsumer::getInstance($this, $this->mimeLiteralPartFactory); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Returns the QuotedStringConsumer singleton instance. |
|
104
|
|
|
* |
|
105
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\QuotedStringConsumer |
|
106
|
|
|
*/ |
|
107
|
1 |
|
public function getQuotedStringConsumer() |
|
108
|
|
|
{ |
|
109
|
1 |
|
return QuotedStringConsumer::getInstance($this, $this->partFactory); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Returns the DateConsumer singleton instance. |
|
114
|
|
|
* |
|
115
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\DateConsumer |
|
116
|
|
|
*/ |
|
117
|
1 |
|
public function getDateConsumer() |
|
118
|
|
|
{ |
|
119
|
1 |
|
return DateConsumer::getInstance($this, $this->partFactory); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Returns the ParameterConsumer singleton instance. |
|
124
|
|
|
* |
|
125
|
|
|
* @return \ZBateson\MailMimeParser\Header\Consumer\ParameterConsumer |
|
126
|
|
|
*/ |
|
127
|
1 |
|
public function getParameterConsumer() |
|
128
|
|
|
{ |
|
129
|
1 |
|
return ParameterConsumer::getInstance($this, $this->partFactory); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|