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
 * Abstract baseclass for the <condition> task as well as several
22
 * conditions - ensures that the types of conditions inside the task
23
 * and the "container" conditions are in sync.
24
 *
25
 * @author    Hans Lellelid <hans@xmpl.org>
26
 * @author    Andreas Aderhold <andi@binarycloud.com>
27
 * @copyright 2001,2002 THYRELL. All rights reserved
28
 * @package   phing.tasks.system.condition
29
 */
30
abstract class ConditionBase extends ProjectComponent implements IteratorAggregate, CustomChildCreator
31
{
32
    public $conditions = []; // needs to be public for "inner" class access
33

34
    /**
35
     * @var string $taskName
36
     */
37
    private $taskName = 'condition';
38

39 1
    public function __construct($taskName = 'component')
40
    {
41 1
        parent::__construct();
42 1
        $this->taskName = $taskName;
43
    }
44

45
    /**
46
     * Sets the name to use in logging messages.
47
     *
48
     * @param string $name The name to use in logging messages.
49
     *                     Should not be <code>null</code>.
50
     */
51 0
    public function setTaskName($name)
52
    {
53 0
        $this->taskName = $name;
54
    }
55

56
    /**
57
     * Returns the name to use in logging messages.
58
     *
59
     * @return string the name to use in logging messages.
60
     */
61 1
    public function getTaskName()
62
    {
63 1
        return $this->taskName;
64
    }
65

66
    /**
67
     * @return int
68
     */
69 1
    public function countConditions()
70
    {
71 1
        return count($this->conditions);
72
    }
73

74
    /**
75
     * Required for IteratorAggregate
76
     */
77 1
    public function getIterator()
78
    {
79 1
        return new ConditionEnumeration($this);
80
    }
81

82
    /**
83
     * @return Condition[]
84
     */
85 1
    public function getConditions()
86
    {
87 1
        return $this->conditions;
88
    }
89

90
    /**
91
     * @param AvailableTask $a
92
     * @return void
93
     */
94 1
    public function addAvailable(AvailableTask $a)
95
    {
96 1
        $this->conditions[] = $a;
97
    }
98

99
    /**
100
     * @return NotCondition
101
     */
102 1
    public function createNot()
103
    {
104 1
        $num = array_push($this->conditions, new NotCondition());
105

106 1
        return $this->conditions[$num - 1];
107
    }
108

109
    /**
110
     * @return AndCondition
111
     */
112 1
    public function createAnd()
113
    {
114 1
        $num = array_push($this->conditions, new AndCondition());
115

116 1
        return $this->conditions[$num - 1];
117
    }
118

119
    /**
120
     * @return OrCondition
121
     */
122 1
    public function createOr()
123
    {
124 1
        $num = array_push($this->conditions, new OrCondition());
125

126 1
        return $this->conditions[$num - 1];
127
    }
128

129
    /**
130
     * @return XorCondition
131
     */
132 1
    public function createXor()
133
    {
134 1
        $num = array_push($this->conditions, new XorCondition());
135

136 1
        return $this->conditions[$num - 1];
137
    }
138

139
    /**
140
     * @return EqualsCondition
141
     */
142 1
    public function createEquals()
143
    {
144 1
        $num = array_push($this->conditions, new EqualsCondition());
145

146 1
        return $this->conditions[$num - 1];
147
    }
148

149
    /**
150
     * @return OsCondition
151
     */
152 1
    public function createOs()
153
    {
154 1
        $num = array_push($this->conditions, new OsCondition());
155

156 1
        return $this->conditions[$num - 1];
157
    }
158

159
    /**
160
     * @return IsFalseCondition
161
     */
162 0
    public function createIsFalse()
163
    {
164 0
        $num = array_push($this->conditions, new IsFalseCondition());
165

166 0
        return $this->conditions[$num - 1];
167
    }
168

169
    /**
170
     * @return IsTrueCondition
171
     */
172 1
    public function createIsTrue()
173
    {
174 1
        $num = array_push($this->conditions, new IsTrueCondition());
175

176 1
        return $this->conditions[$num - 1];
177
    }
178

179
    /**
180
     * @return IsPropertyFalseCondition
181
     */
182 1
    public function createIsPropertyFalse()
183
    {
184 1
        $num = array_push($this->conditions, new IsPropertyFalseCondition());
185

186 1
        return $this->conditions[$num - 1];
187
    }
188

189
    /**
190
     * @return IsPropertyTrueCondition
191
     */
192 1
    public function createIsPropertyTrue()
193
    {
194 1
        $num = array_push($this->conditions, new IsPropertyTrueCondition());
195

196 1
        return $this->conditions[$num - 1];
197
    }
198

199
    /**
200
     * @return ContainsCondition
201
     */
202 1
    public function createContains()
203
    {
204 1
        $num = array_push($this->conditions, new ContainsCondition());
205

206 1
        return $this->conditions[$num - 1];
207
    }
208

209
    /**
210
     * @return IsSetCondition
211
     */
212 0
    public function createIsSet()
213
    {
214 0
        $num = array_push($this->conditions, new IsSetCondition());
215

216 0
        return $this->conditions[$num - 1];
217
    }
218

219
    /**
220
     * @return ReferenceExistsCondition
221
     */
222 1
    public function createReferenceExists()
223
    {
224 1
        $num = array_push($this->conditions, new ReferenceExistsCondition());
225

226 1
        return $this->conditions[$num - 1];
227
    }
228

229 0
    public function createVersionCompare()
230
    {
231 0
        $num = array_push($this->conditions, new VersionCompareCondition());
232

233 0
        return $this->conditions[$num - 1];
234
    }
235

236 0
    public function createHttp()
237
    {
238 0
        $num = array_push($this->conditions, new HttpCondition());
239

240 0
        return $this->conditions[$num - 1];
241
    }
242

243 1
    public function createPhingVersion()
244
    {
245 1
        $num = array_push($this->conditions, new PhingVersion());
246

247 1
        return $this->conditions[$num - 1];
248
    }
249

250 0
    public function createHasFreeSpace()
251
    {
252 0
        $num = array_push($this->conditions, new HasFreeSpaceCondition());
253

254 0
        return $this->conditions[$num - 1];
255
    }
256

257 1
    public function createFilesMatch()
258
    {
259 1
        $num = array_push($this->conditions, new FilesMatch());
260

261 1
        return $this->conditions[$num - 1];
262
    }
263

264 1
    public function createSocket()
265
    {
266 1
        $num = array_push($this->conditions, new SocketCondition());
267

268 1
        return $this->conditions[$num - 1];
269
    }
270

271 1
    public function createIsFailure()
272
    {
273 1
        $num = array_push($this->conditions, new IsFailure());
274

275 1
        return $this->conditions[$num - 1];
276
    }
277

278 1
    public function createIsFileSelected()
279
    {
280 1
        $num = array_push($this->conditions, new IsFileSelected());
281

282 1
        return $this->conditions[$num - 1];
283
    }
284

285 1
    public function createMatches()
286
    {
287 1
        $num = array_push($this->conditions, new Matches());
288

289 1
        return $this->conditions[$num - 1];
290
    }
291

292 1
    public function createPdoSqlExec()
293
    {
294 1
        $num = array_push($this->conditions, new PDOSQLExecTask());
295

296 1
        return $this->conditions[$num - 1];
297
    }
298

299
    /**
300
     * @param  string $elementName
301
     * @param  Project $project
302
     * @throws BuildException
303
     * @return Condition
304
     */
305 1
    public function customChildCreator($elementName, Project $project)
306
    {
307 1
        $condition = $project->createCondition($elementName);
308 1
        $num = array_push($this->conditions, $condition);
309

310 1
        return $this->conditions[$num - 1];
311
    }
312
}

Read our documentation on viewing source code .

Loading