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\Message\Part\Factory; |
8
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Stream\StreamFactory; |
10
|
|
|
use ZBateson\MailMimeParser\Header\HeaderFactory; |
11
|
|
|
use ZBateson\MailMimeParser\Message\Helper\MessageHelperService; |
12
|
|
|
use ZBateson\MailMimeParser\Message\MessageFactory; |
13
|
|
|
use ZBateson\MailMimeParser\Message\PartFilterFactory; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Responsible for creating singleton instances of MessagePartFactory and its |
17
|
|
|
* subclasses. |
18
|
|
|
* |
19
|
|
|
* @author Zaahid Bateson |
20
|
|
|
*/ |
21
|
|
|
class PartFactoryService |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var HeaderFactory the HeaderFactory object used for created headers |
25
|
|
|
*/ |
26
|
|
|
protected $headerFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var PartFilterFactory the PartFilterFactory instance |
30
|
|
|
*/ |
31
|
|
|
protected $partFilterFactory; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var PartStreamFilterManagerFactory the PartStreamFilterManagerFactory |
35
|
|
|
* instance |
36
|
|
|
*/ |
37
|
|
|
protected $partStreamFilterManagerFactory; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var StreamFactory the StreamFactory instance |
41
|
|
|
*/ |
42
|
|
|
protected $streamFactory; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var MessageHelperService the MessageHelperService instance |
46
|
|
|
*/ |
47
|
|
|
protected $messageHelperService; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param HeaderFactory $headerFactory |
51
|
|
|
* @param PartFilterFactory $partFilterFactory |
52
|
|
|
* @param StreamFactory $streamFactory |
53
|
|
|
* @param PartStreamFilterManagerFactory $partStreamFilterManagerFactory |
54
|
|
|
* @param MessageHelperService $messageHelperService |
55
|
|
|
*/ |
56
|
|
|
public function __construct( |
57
|
|
|
HeaderFactory $headerFactory, |
58
|
|
|
PartFilterFactory $partFilterFactory, |
59
|
|
|
StreamFactory $streamFactory, |
60
|
|
|
PartStreamFilterManagerFactory $partStreamFilterManagerFactory, |
61
|
|
|
MessageHelperService $messageHelperService |
62
|
|
|
) { |
63
|
|
|
$this->headerFactory = $headerFactory; |
64
|
|
|
$this->partFilterFactory = $partFilterFactory; |
65
|
|
|
$this->streamFactory = $streamFactory; |
66
|
|
|
$this->partStreamFilterManagerFactory = $partStreamFilterManagerFactory; |
67
|
|
|
$this->messageHelperService = $messageHelperService; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Returns the MessageFactory singleton instance. |
72
|
|
|
* |
73
|
|
|
* @return MessageFactory |
74
|
|
|
*/ |
75
|
1 |
|
public function getMessageFactory() |
76
|
|
|
{ |
77
|
1 |
|
return MessageFactory::getInstance( |
78
|
1 |
|
$this->streamFactory, |
79
|
1 |
|
$this->partStreamFilterManagerFactory, |
80
|
1 |
|
$this->headerFactory, |
81
|
1 |
|
$this->partFilterFactory, |
82
|
1 |
|
$this->messageHelperService |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Returns the MimePartFactory singleton instance. |
88
|
|
|
* |
89
|
|
|
* @return MimePartFactory |
90
|
|
|
*/ |
91
|
1 |
|
public function getMimePartFactory() |
92
|
|
|
{ |
93
|
1 |
|
return MimePartFactory::getInstance( |
94
|
1 |
|
$this->streamFactory, |
95
|
1 |
|
$this->partStreamFilterManagerFactory, |
96
|
1 |
|
$this->headerFactory, |
97
|
1 |
|
$this->partFilterFactory |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns the NonMimePartFactory singleton instance. |
103
|
|
|
* |
104
|
|
|
* @return NonMimePartFactory |
105
|
|
|
*/ |
106
|
1 |
|
public function getNonMimePartFactory() |
107
|
|
|
{ |
108
|
1 |
|
return NonMimePartFactory::getInstance( |
109
|
1 |
|
$this->streamFactory, |
110
|
1 |
|
$this->partStreamFilterManagerFactory |
111
|
|
|
); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Returns the UUEncodedPartFactory singleton instance. |
116
|
|
|
* |
117
|
|
|
* @return UUEncodedPartFactory |
118
|
|
|
*/ |
119
|
1 |
|
public function getUUEncodedPartFactory() |
120
|
|
|
{ |
121
|
1 |
|
return UUEncodedPartFactory::getInstance( |
122
|
1 |
|
$this->streamFactory, |
123
|
1 |
|
$this->partStreamFilterManagerFactory |
124
|
|
|
); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|