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