Passed
Push — master ( 28a3ce...b9357e )
by Siad
05:23
created

SelectorAware   A

Complexity

Total Complexity 29

Size/Duplication

Total Lines 239
Duplicated Lines 0 %

Test Coverage

Coverage 40.24%

Importance

Changes 0
Metric Value
eloc 33
c 0
b 0
f 0
dl 0
loc 239
ccs 33
cts 82
cp 0.4024
rs 10
wmc 29

28 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 3 1
A addNot() 0 3 1
A selectorElements() 0 3 1
A addContains() 0 3 1
A addPresent() 0 3 1
A addSelector() 0 3 1
A addSize() 0 3 1
A getSelectors() 0 8 2
A addDifferent() 0 3 1
A addDate() 0 3 1
A hasSelectors() 0 3 1
A addDepend() 0 3 1
A addCustom() 0 3 1
A addContainsRegexp() 0 3 1
A addAnd() 0 3 1
A addNone() 0 3 1
A addOr() 0 3 1
A addDepth() 0 3 1
A addMajority() 0 3 1
A appendSelector() 0 3 1
A addFilename() 0 3 1
A addExecutable() 0 3 1
A addWritable() 0 3 1
A addSymlink() 0 3 1
A addModified() 0 3 1
A addPosixPermissions() 0 3 1
A addType() 0 3 1
A addReadable() 0 3 1
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
trait SelectorAware
21
{
22
    /**
23
     * @var BaseSelectorContainer[]
24
     */
25
    protected $selectorsList = [];
26
27
    /**
28
     * Indicates whether there are any selectors here.
29
     */
30
    public function hasSelectors()
31
    {
32
        return !empty($this->selectorsList);
33
    }
34
35
    /**
36
     * Gives the count of the number of selectors in this container
37
     */
38
    public function count()
39
    {
40
        return count($this->selectorsList);
41
    }
42
43
    /**
44
     * Returns a copy of the selectors as an array.
45
     *
46
     * @param  Project $p
47
     * @return array
48
     */
49
    public function getSelectors(Project $p)
0 ignored issues
show
Unused Code introduced by
The parameter $p is not used and could be removed. ( Ignorable by Annotation )

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

49
    public function getSelectors(/** @scrutinizer ignore-unused */ Project $p)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
    {
51
        $result = [];
52
        for ($i = 0, $size = count($this->selectorsList); $i < $size; $i++) {
53
            $result[] = clone $this->selectorsList[$i];
54
        }
55
56
        return $result;
57
    }
58
59
    /**
60
     * Returns an array for accessing the set of selectors (not a copy).
61
     */
62
    public function selectorElements()
63
    {
64
        return $this->selectorsList;
65
    }
66
67
    /**
68
     * Add a new selector into this container.
69
     *
70
     * @param FileSelector $selector new selector to add
71
     */
72 19
    public function appendSelector(FileSelector $selector)
73
    {
74 19
        $this->selectorsList[] = $selector;
75 19
    }
76
77
    /**
78
     * add a "Select" selector entry on the selector list
79
     */
80
    public function addSelector(SelectSelector $selector)
81
    {
82
        $this->appendSelector($selector);
83
    }
84
85
    /**
86
     * add an "And" selector entry on the selector list
87
     */
88
    public function addAnd(AndSelector $selector)
89
    {
90
        $this->appendSelector($selector);
91
    }
92
93
    /**
94
     * add an "Or" selector entry on the selector list
95
     */
96
    public function addOr(OrSelector $selector)
97
    {
98
        $this->appendSelector($selector);
99
    }
100
101
    /**
102
     * add a "Not" selector entry on the selector list
103
     */
104
    public function addNot(NotSelector $selector)
105
    {
106
        $this->appendSelector($selector);
107
    }
108
109
    /**
110
     * add a "None" selector entry on the selector list
111
     */
112
    public function addNone(NoneSelector $selector)
113
    {
114
        $this->appendSelector($selector);
115
    }
116
117
    /**
118
     * add a majority selector entry on the selector list
119
     */
120
    public function addMajority(MajoritySelector $selector)
121
    {
122
        $this->appendSelector($selector);
123
    }
124
125
    /**
126
     * add a selector date entry on the selector list
127
     */
128 38
    public function addDate(DateSelector $selector)
129
    {
130 38
        $this->appendSelector($selector);
131 38
    }
132
133
    /**
134
     * add a selector size entry on the selector list
135
     */
136
    public function addSize(SizeSelector $selector)
137
    {
138
        $this->appendSelector($selector);
139
    }
140
141
    /**
142
     * add a selector filename entry on the selector list
143
     */
144 1
    public function addFilename(FilenameSelector $selector)
145
    {
146 1
        $this->appendSelector($selector);
147 1
    }
148
149
    /**
150
     * add an extended selector entry on the selector list
151
     */
152
    public function addCustom(ExtendSelector $selector)
153
    {
154
        $this->appendSelector($selector);
155
    }
156
157
    /**
158
     * add a contains selector entry on the selector list
159
     */
160
    public function addContains(ContainsSelector $selector)
161
    {
162
        $this->appendSelector($selector);
163
    }
164
165
    /**
166
     * add a contains selector entry on the selector list
167
     */
168 1
    public function addContainsRegexp(ContainsRegexpSelector $selector)
169
    {
170 1
        $this->appendSelector($selector);
171 1
    }
172
173
    /**
174
     * add a present selector entry on the selector list
175
     */
176
    public function addPresent(PresentSelector $selector)
177
    {
178
        $this->appendSelector($selector);
179
    }
180
181
    /**
182
     * add a depth selector entry on the selector list
183
     */
184
    public function addDepth(DepthSelector $selector)
185
    {
186
        $this->appendSelector($selector);
187
    }
188
189
    /**
190
     * add a depends selector entry on the selector list
191
     */
192
    public function addDepend(DependSelector $selector)
193
    {
194
        $this->appendSelector($selector);
195
    }
196
197
    /**
198
     * add a different selector entry on the selector list
199
     */
200 2
    public function addDifferent(DifferentSelector $selector)
201
    {
202 2
        $this->appendSelector($selector);
203 2
    }
204
205
    /**
206
     * add a modified selector entry on the selector list
207
     */
208 2
    public function addModified(ModifiedSelector $selector)
209
    {
210 2
        $this->appendSelector($selector);
211 2
    }
212
213
    /**
214
     * add a type selector entry on the selector list
215
     */
216 1
    public function addType(TypeSelector $selector)
217
    {
218 1
        $this->appendSelector($selector);
219 1
    }
220
221
    /**
222
     * add a executable selector entry on the selector list
223
     */
224 2
    public function addExecutable(ExecutableSelector $selector)
225
    {
226 2
        $this->appendSelector($selector);
227 2
    }
228
229
    /**
230
     * add a readable selector entry on the selector list
231
     */
232 1
    public function addReadable(ReadableSelector $selector)
233
    {
234 1
        $this->appendSelector($selector);
235 1
    }
236
237
    /**
238
     * add a writable selector entry on the selector list
239
     */
240 2
    public function addWritable(WritableSelector $selector)
241
    {
242 2
        $this->appendSelector($selector);
243 2
    }
244
245
    /**
246
     * add a symlink selector entry on the selector list
247
     */
248 2
    public function addSymlink(SymlinkSelector $selector)
249
    {
250 2
        $this->appendSelector($selector);
251 2
    }
252
253
    /**
254
     * add a symlink selector entry on the selector list
255
     */
256
    public function addPosixPermissions(PosixPermissionsSelector $selector)
257
    {
258
        $this->appendSelector($selector);
259
    }
260
}
261