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; |
8
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Header\HeaderFactory; |
10
|
|
|
use ZBateson\MailMimeParser\Message\PartFilterFactory; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Responsible for creating MimePart instances. |
14
|
|
|
* |
15
|
|
|
* @author Zaahid Bateson |
16
|
|
|
*/ |
17
|
|
|
class MimePartFactory extends MessagePartFactory |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory |
21
|
|
|
* instance |
22
|
|
|
*/ |
23
|
|
|
protected $headerFactory; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var \ZBateson\MailMimeParser\Header\HeaderFactory the PartFilterFactory |
27
|
|
|
* instance |
28
|
|
|
*/ |
29
|
|
|
protected $partFilterFactory; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Creates a MimePartFactory instance with its dependencies. |
33
|
|
|
* |
34
|
|
|
* @param PartStreamFilterManagerFactory $psf |
35
|
|
|
* @param HeaderFactory $hf |
36
|
|
|
* @param PartFilterFactory $pf |
37
|
|
|
*/ |
38
|
|
|
public function __construct(PartStreamFilterManagerFactory $psf, HeaderFactory $hf, PartFilterFactory $pf) |
39
|
|
|
{ |
40
|
|
|
parent::__construct($psf); |
41
|
|
|
$this->headerFactory = $hf; |
42
|
|
|
$this->partFilterFactory = $pf; |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Returns the singleton instance for the class. |
47
|
|
|
* |
48
|
|
|
* @param PartStreamFilterManagerFactory $psf |
49
|
|
|
* @param HeaderFactory $hf |
50
|
|
|
* @param PartFilterFactory $pf |
51
|
|
|
* @return MimePartFactory |
52
|
|
|
*/ |
53
|
|
View Code Duplication |
public static function getInstance( |
|
|
|
|
54
|
|
|
PartStreamFilterManagerFactory $psf, |
55
|
|
|
HeaderFactory $hf = null, |
56
|
|
|
PartFilterFactory $pf = null |
57
|
|
|
) { |
58
|
|
|
static $instances = []; |
59
|
|
|
$class = get_called_class(); |
60
|
|
|
if (!isset($instances[$class])) { |
61
|
|
|
$instances[$class] = new static($psf, $hf, $pf); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
return $instances[$class]; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Constructs a new MimePart object and returns it |
68
|
|
|
* |
69
|
|
|
* @param string $messageObjectId |
70
|
|
|
* @param PartBuilder $partBuilder |
71
|
|
|
* @return \ZBateson\MailMimeParser\Message\Part\MimePart |
72
|
|
|
*/ |
73
|
|
|
public function newInstance($messageObjectId, PartBuilder $partBuilder) |
74
|
|
|
{ |
75
|
|
|
return new MimePart( |
76
|
|
|
$this->headerFactory, |
77
|
|
|
$this->partFilterFactory, |
|
|
|
|
78
|
|
|
$messageObjectId, |
79
|
|
|
$partBuilder, |
80
|
|
|
$this->partStreamFilterManagerFactory->newInstance() |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..