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
 * "Inner" class for IfTask.
22
 * This class has same basic structure as the IfTask, although of course it doesn't support <else> tags.
23
 *
24
 * @package phing.tasks.system
25
 */
26
class ElseIfTask extends ConditionBase
27
{
28
    private $thenTasks = null;
29

30
    /**
31
     * @param SequentialTask $t
32
     * @throws BuildException
33
     */
34 1
    public function addThen(SequentialTask $t)
35
    {
36 1
        if ($this->thenTasks != null) {
37 0
            throw new BuildException("You must not nest more than one <then> into <elseif>");
38
        }
39 1
        $this->thenTasks = $t;
40
    }
41

42
    /**
43
     * @throws BuildException
44
     * @return boolean
45
     */
46 1
    public function evaluate()
47
    {
48 1
        if ($this->countConditions() > 1) {
49 1
            throw new BuildException("You must not nest more than one condition into <elseif>");
50
        }
51 1
        if ($this->countConditions() < 1) {
52 1
            throw new BuildException("You must nest a condition into <elseif>");
53
        }
54

55 1
        $conditions = $this->getConditions();
56 1
        $c = $conditions[0];
57

58 1
        return $c->evaluate();
59
    }
60

61
    /**
62
     *
63
     */
64 1
    public function main()
65
    {
66 1
        if ($this->thenTasks != null) {
67 1
            $this->thenTasks->main();
68
        }
69
    }
70
}

Read our documentation on viewing source code .

Loading