Test Failed
Push — 2.0 ( 0b4092...91a8b2 )
by Zaahid
04:50
created

ParserPartProxy::isMime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
13
/**
14
 * Base bi-directional proxy between a parser and a MessagePart.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
abstract class ParserPartProxy extends PartBuilder
19
{
20
    /**
21
     * @var IMessagePart The part.
22
     */
23
    protected $part;
24
25
    /**
26
     * @var IParser|null The parser.
27
     */
28
    protected $parser;
29
30
    /**
31
     * @var PartBuilder The part's PartBuilder.
32
     */
33
    protected $partBuilder;
34
35
    public function __construct(
36
        PartBuilder $partBuilder,
37
        IParser $parser
38
    ) {
39
        $this->partBuilder = $partBuilder;
40
        $this->parser = $parser;
41
    }
42
43
    /**
44
     * Sets the associated part.
45
     *
46
     * @param IMessagePart $part The part
47
     */
48
    public function setPart(IMessagePart $part)
49
    {
50
        $this->part = $part;
51
    }
52
53
    /**
54
     * Returns the IMessagePart associated with this proxy.
55
     *
56
     * @return IMessagePart the part.
57
     */
58
    public function getPart()
59
    {
60
        return $this->part;
61
    }
62
63
    /**
64
     * Parses this part's content (if not already parsed).
65
     *
66
     * If the part has a parent, parseContent() will use
67
     * $this->parent->childParser, which is the matching type of parser for the
68
     * given part.  Otherwise, if it's the top-level part (Message), then
69
     * $this->childParser is used.
70
     */
71
    public function parseContent()
72
    {
73
        if (!$this->isContentParsed()) {
74
            $this->parser->parseContent($this);
0 ignored issues
show
Bug introduced by
The method parseContent() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
            $this->parser->/** @scrutinizer ignore-call */ 
75
                           parseContent($this);

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.

Loading history...
75
        }
76
    }
77
78
    /**
79
     * Parses the associated part's content and children.
80
     */
81
    public function parseAll()
82
    {
83
        $this->parseContent();
84
    }
85
86
    public function getParent()
87
    {
88
        return $this->partBuilder->getParent();
89
    }
90
91
    public function getHeaderContainer()
92
    {
93
        return $this->partBuilder->getHeaderContainer();
94
    }
95
96
     public function getStream()
97
    {
0 ignored issues
show
Coding Style introduced by
Opening brace indented incorrectly; expected 5 spaces, found 4
Loading history...
98
        return $this->partBuilder->getStream();
99
    }
0 ignored issues
show
Coding Style introduced by
Closing brace indented incorrectly; expected 5 spaces, found 4
Loading history...
100
101
    public function getMessageResourceHandle()
102
    {
103
        return $this->partBuilder->getMessageResourceHandle();
104
    }
105
106
    public function getMessageResourceHandlePos()
107
    {
108
        return $this->partBuilder->getMessageResourceHandlePos();
109
    }
110
111
    public function getStreamPartStartPos()
112
    {
113
        return $this->partBuilder->getStreamPartStartPos();
114
    }
115
116
    public function getStreamPartLength()
117
    {
118
        return $this->partBuilder->getStreamPartLength();
119
    }
120
121
    public function getStreamContentStartPos()
122
    {
123
        return $this->partBuilder->getStreamContentStartPos();
124
    }
125
126
    public function getStreamContentLength()
127
    {
128
        return $this->partBuilder->getStreamContentLength();
129
    }
130
131
    public function setStreamPartStartPos($streamPartStartPos)
132
    {
133
        $this->partBuilder->setStreamPartStartPos($streamPartStartPos);
134
    }
135
136
    public function setStreamPartEndPos($streamPartEndPos)
137
    {
138
        $this->partBuilder->setStreamPartEndPos($streamPartEndPos);
139
    }
140
141
    public function setStreamContentStartPos($streamContentStartPos)
142
    {
143
        $this->partBuilder->setStreamContentStartPos($streamContentStartPos);
144
    }
145
146
    public function setStreamPartAndContentEndPos($streamContentEndPos)
147
    {
148
        $this->partBuilder->setStreamPartAndContentEndPos($streamContentEndPos);
149
    }
150
151
    public function isContentParsed()
152
    {
153
        return $this->partBuilder->isContentParsed();
154
    }
155
156
    public function isMime()
157
    {
158
        return $this->partBuilder->isMime();
159
    }
160
}
161