Passed
Push — master ( ec5d4d...d68b8d )
by Siad
11:29
created

FilterChain::addPrefixLines()   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
 * FilterChain may contain a chained set of filter readers.
22
 *
23
 * @author  Yannick Lecaillez <[email protected]>
24
 * @package phing.types
25
 */
26
class FilterChain extends DataType
27
{
28
    private $filterReaders = [];
29
30
    /**
31
     * @param null $project
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $project is correct as it would always require null to be passed?
Loading history...
32
     */
33 30
    public function __construct($project = null)
34
    {
35 30
        parent::__construct();
36
37 30
        if ($project) {
0 ignored issues
show
introduced by
$project is of type null, thus it always evaluated to false.
Loading history...
38
            $this->project = $project;
39
        }
40 30
    }
41
42
    /**
43
     * @return array
44
     */
45 30
    public function getFilterReaders()
46
    {
47 30
        return $this->filterReaders;
48
    }
49
50
    /**
51
     * @param ConcatFilter $o
52
     */
53 1
    public function addConcatFilter(ConcatFilter $o)
54
    {
55 1
        $this->add($o);
56 1
    }
57
58
    /**
59
     * @param ExpandProperties $o
60
     */
61 3
    public function addExpandProperties(ExpandProperties $o)
62
    {
63 3
        $this->add($o);
64 3
    }
65
66
    /**
67
     * @param TranslateGettext $o
68
     */
69
    public function addGettext(TranslateGettext $o)
70
    {
71
        $this->add($o);
72
    }
73
74
    /**
75
     * @param HeadFilter $o
76
     */
77 2
    public function addHeadFilter(HeadFilter $o)
78
    {
79 2
        $this->add($o);
80 2
    }
81
82
    /**
83
     * @param IconvFilter $o
84
     */
85
    public function addIconvFilter(IconvFilter $o)
86
    {
87
        $this->add($o);
88
    }
89
90
    /**
91
     * @param TailFilter $o
92
     */
93 2
    public function addTailFilter(TailFilter $o)
94
    {
95 2
        $this->add($o);
96 2
    }
97
98
    /**
99
     * @param LineContains $o
100
     */
101 1
    public function addLineContains(LineContains $o)
102
    {
103 1
        $this->add($o);
104 1
    }
105
106
    /**
107
     * @param LineContainsRegexp $o
108
     */
109
    public function addLineContainsRegExp(LineContainsRegexp $o)
110
    {
111
        $this->add($o);
112
    }
113
114
    /**
115
     * @param PrefixLines $o
116
     */
117
    public function addPrefixLines(PrefixLines $o)
118
    {
119
        $this->add($o);
120
    }
121
122
    /**
123
     * @param SuffixLines $o
124
     */
125
    public function addSuffixLines(SuffixLines $o)
126
    {
127
        $this->add($o);
128
    }
129
130
    /**
131
     * @param PrefixLines $o
132
     */
133
    public function addEscapeUnicode(EscapeUnicode $o)
134
    {
135
        $this->add($o);
136
    }
137
138
    /**
139
     * @param PhpArrayMapLines $o
140
     */
141
    public function addPhpArrayMapLines(PhpArrayMapLines $o)
142
    {
143
        $this->add($o);
144
    }
145
146
    /**
147
     * @param ReplaceTokens $o
148
     */
149 5
    public function addReplaceTokens(ReplaceTokens $o)
150
    {
151 5
        $this->add($o);
152 5
    }
153
154
    /**
155
     * @param ReplaceTokensWithFile $o
156
     */
157 2
    public function addReplaceTokensWithFile(ReplaceTokensWithFile $o)
158
    {
159 2
        $this->add($o);
160 2
    }
161
162
    /**
163
     * @param ReplaceRegexp $o
164
     */
165 2
    public function addReplaceRegexp(ReplaceRegexp $o)
166
    {
167 2
        $this->add($o);
168 2
    }
169
170
    /**
171
     * @param StripPhpComments $o
172
     */
173 1
    public function addStripPhpComments(StripPhpComments $o)
174
    {
175 1
        $this->add($o);
176 1
    }
177
178
    /**
179
     * @param StripLineBreaks $o
180
     */
181 5
    public function addStripLineBreaks(StripLineBreaks $o)
182
    {
183 5
        $this->add($o);
184 5
    }
185
186
    /**
187
     * @param StripLineComments $o
188
     */
189
    public function addStripLineComments(StripLineComments $o)
190
    {
191
        $this->add($o);
192
    }
193
194
    /**
195
     * @param StripWhitespace $o
196
     */
197 1
    public function addStripWhitespace(StripWhitespace $o)
198
    {
199 1
        $this->add($o);
200 1
    }
201
202
    /**
203
     * @param TidyFilter $o
204
     */
205
    public function addTidyFilter(TidyFilter $o)
206
    {
207
        $this->add($o);
208
    }
209
210
    /**
211
     * @param TabToSpaces $o
212
     */
213
    public function addTabToSpaces(TabToSpaces $o)
214
    {
215
        $this->add($o);
216
    }
217
218
    /**
219
     * @param XincludeFilter $o
220
     */
221
    public function addXincludeFilter(XincludeFilter $o)
222
    {
223
        $this->add($o);
224
    }
225
226
    /**
227
     * @param XsltFilter $o
228
     */
229
    public function addXsltFilter(XsltFilter $o)
230
    {
231
        $this->add($o);
232
    }
233
234
    /**
235
     * @param PhingFilterReader $o
236
     */
237 8
    public function addFilterReader(PhingFilterReader $o)
238
    {
239 8
        $o->setProject($this->project);
240 8
        $this->filterReaders[] = $o;
241 8
    }
242
243
    /**
244
     * @param SortFilter $o
245
     */
246 1
    public function addSortFilter(SortFilter $o)
247
    {
248 1
        $this->add($o);
249 1
    }
250
251
    /**
252
     * @param ClassConstants $o
253
     */
254 1
    public function addClassConstants(ClassConstants $o)
255
    {
256 1
        $this->add($o);
257 1
    }
258
259 24
    private function add(BaseFilterReader $o)
260
    {
261 24
        $o->setProject($this->project);
262 24
        $this->filterReaders[] = $o;
263 24
    }
264
265
    /*
266
     * Makes this instance in effect a reference to another FilterChain
267
     * instance.
268
     *
269
     * <p>You must not set another attribute or nest elements inside
270
     * this element if you make it a reference.</p>
271
     *
272
     * @param  $r the reference to which this instance is associated
273
     * @throws BuildException if this instance already has been configured.
274
    */
275
    /**
276
     * @param Reference $r
277
     * @throws BuildException
278
     */
279
    public function setRefid(Reference $r)
280
    {
281
        if (count($this->filterReaders) !== 0) {
282
            throw $this->tooManyAttributes();
283
        }
284
285
        // change this to get the objects from the other reference
286
        $o = $r->getReferencedObject($this->getProject());
287
        if ($o instanceof FilterChain) {
288
            $this->filterReaders = $o->getFilterReaders();
289
        } else {
290
            throw new BuildException($r->getRefId() . " doesn't refer to a FilterChain");
291
        }
292
        parent::setRefid($r);
293
    }
294
}
295