Passed
Push — master ( e5c614...6595be )
by Siad
13:10
created

PhingXMLContext::setCurrentProjectName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19
20
/**
21
 * Track the current state of the Xml parse operation.
22
 *
23
 * @author  Bryan Davis <[email protected]>
24
 * @package phing.parser
25
 */
26
class PhingXMLContext
27
{
28
29
    /**
30
     * Target that will hold all tasks/types placed outside of targets
31
     *
32
     * @var Target
33
     */
34
    private $implicitTarget;
35
36
    /**
37
     * Current target
38
     *
39
     * @var Target
40
     */
41
    private $currentTarget = null;
42
43
    /**
44
     * List of current targets
45
     *
46
     * @var Target[]
47
     */
48
    private $currentTargets = null;
49
50
    /** @var string */
51
    private $currentProjectName;
52
53
    /**
54
     * Constructor
55
     *
56
     * @param Project $project the project to which this antxml context belongs to
57
     */
58 792
    public function __construct(Project $project)
59
    {
60 792
        $this->project = $project;
61 792
        $this->implicitTarget = new Target();
62 792
        $this->implicitTarget->setName('');
63 792
        $this->implicitTarget->setHidden(true);
64 792
    }
65
66
    /**
67
     * The project to configure.
68
     */
69
    private $project;
70
71
    private $configurators = [];
72
73
    /**
74
     * @param $cfg
75
     */
76 792
    public function startConfigure($cfg)
77
    {
78 792
        $this->configurators[] = $cfg;
79 792
    }
80
81 792
    public function endConfigure()
82
    {
83 792
        array_pop($this->configurators);
84 792
    }
85
86
    /**
87
     * @return null
88
     */
89 100
    public function getConfigurator()
90
    {
91 100
        $l = count($this->configurators);
92 100
        if (0 == $l) {
93 100
            return null;
94
        }
95
96
        return $this->configurators[$l - 1];
97
    }
98
99
    /**
100
     * Impoerted files
101
     */
102
    private $importStack = [];
103
104
    /**
105
     * @param $file
106
     */
107 792
    public function addImport($file)
108
    {
109 792
        $this->importStack[] = $file;
110 792
    }
111
112
    /**
113
     * @return array
114
     */
115 792
    public function &getImportStack()
116
    {
117 792
        return $this->importStack;
118
    }
119
120
    /** Impoerted files */
121
    private $extensionPointStack = [];
122
123
    /**
124
     * @param $file
125
     */
126 7
    public function addExtensionPoint($elem)
127
    {
128 7
        $this->extensionPointStack[] = $elem;
129 7
    }
130
131
    /**
132
     * @return array
133
     */
134 792
    public function &getExtensionPointStack()
135
    {
136 792
        return $this->extensionPointStack;
137
    }
138
139
    /**
140
     * find out the project to which this context belongs
141
     *
142
     * @return project
143
     */
144
    public function getProject()
145
    {
146
        return $this->project;
147
    }
148
149
    /**
150
     * find out the current project name
151
     * @return string current project name
152
     */
153
    public function getCurrentProjectName()
154
    {
155
        return $this->currentProjectName;
156
    }
157
158
    /**
159
     * set the name of the current project
160
     * @param string $name name of the current project
161
     */
162
    public function setCurrentProjectName(string $name)
163
    {
164
        $this->currentProjectName = $name;
165
    }
166
167
    /**
168
     * @return Target
169
     */
170 792
    public function getImplicitTarget()
171
    {
172 792
        return $this->implicitTarget;
173
    }
174
175
    /**
176
     * @param Target $target
177
     */
178 100
    public function setImplicitTarget(Target $target)
179
    {
180 100
        $this->implicitTarget = $target;
181 100
    }
182
183
    /**
184
     * @return Target
185
     */
186
    public function getCurrentTarget()
187
    {
188
        return $this->currentTarget;
189
    }
190
191
    /**
192
     * @param Target $target
193
     */
194
    public function setCurrentTarget(Target $target)
195
    {
196
        $this->currentTarget = $target;
197
    }
198
199
    /**
200
     * @return Target[]
201
     */
202 792
    public function &getCurrentTargets()
203
    {
204 792
        return $this->currentTargets;
205
    }
206
207
    /**
208
     * @param Target[] $currentTargets
209
     */
210 792
    public function setCurrentTargets(array $currentTargets)
211
    {
212 792
        $this->currentTargets = $currentTargets;
213 792
    }
214
}
215