|
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\Parser\Proxy; |
|
8
|
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Message\IMessagePart; |
|
10
|
|
|
use ZBateson\MailMimeParser\Parser\IParser; |
|
11
|
|
|
use ZBateson\MailMimeParser\Parser\PartBuilder; |
|
12
|
|
|
use ZBateson\MailMimeParser\Parser\Part\ParserPartStreamContainer; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Base bi-directional proxy between a parser and a MessagePart. |
|
16
|
|
|
* |
|
17
|
|
|
* @author Zaahid Bateson |
|
18
|
|
|
*/ |
|
19
|
|
|
class ParserPartProxy |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var IMessagePart The part. |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $part; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var IParser|null The parser. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $childParser; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var PartBuilder The part's PartBuilder. |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $partBuilder; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var ParserPartProxy The parent parser proxy for this part. |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $parent; |
|
40
|
|
|
|
|
41
|
|
|
public function __construct( |
|
42
|
|
|
PartBuilder $partBuilder, |
|
43
|
|
|
IParser $childParser = null, |
|
44
|
|
|
ParserMimePartProxy $parent = null |
|
45
|
|
|
) { |
|
46
|
|
|
$this->partBuilder = $partBuilder; |
|
47
|
|
|
$this->childParser = $childParser; |
|
48
|
|
|
$this->parent = $parent; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Sets the associated part. |
|
53
|
|
|
* |
|
54
|
|
|
* @param IMessagePart $part The part |
|
55
|
|
|
*/ |
|
56
|
|
|
public function setPart(IMessagePart $part) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->part = $part; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the IMessagePart associated with this proxy. |
|
63
|
|
|
* |
|
64
|
|
|
* @return IMessagePart the part. |
|
65
|
|
|
*/ |
|
66
|
|
|
public function getPart() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->part; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Parses this part's content (if not already parsed). |
|
73
|
|
|
* |
|
74
|
|
|
* If the part has a parent, parseContent() will use |
|
75
|
|
|
* $this->parent->childParser, which is the matching type of parser for the |
|
76
|
|
|
* given part. Otherwise, if it's the top-level part (Message), then |
|
77
|
|
|
* $this->childParser is used. |
|
78
|
|
|
*/ |
|
79
|
|
|
public function parseContent() |
|
80
|
|
|
{ |
|
81
|
|
|
if (!$this->partBuilder->isContentParsed()) { |
|
82
|
|
|
$parser = ($this->parent === null) ? $this->childParser : $this->parent->childParser; |
|
83
|
|
|
$parser->parseContent($this); |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Parses the associated part's content and children. |
|
89
|
|
|
*/ |
|
90
|
|
|
public function parseAll() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->parseContent(); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Returns the PartBuilder for this part. |
|
97
|
|
|
* |
|
98
|
|
|
* @return PartBuilder the associated PartBuilder. |
|
99
|
|
|
*/ |
|
100
|
|
|
public function getPartBuilder() |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->partBuilder; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.