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
 * This is the base class for selectors that can contain other selectors.
22
 *
23
 * @author  <a href="mailto:bruce@callenish.com">Bruce Atherton</a> (Ant)
24
 * @package phing.types.selectors
25
 */
26
abstract class BaseSelectorContainer extends BaseSelector implements SelectorContainer, Countable
27
{
28
    use SelectorAware;
29

30
    /**
31
     * Convert the Selectors within this container to a string. This will
32
     * just be a helper class for the subclasses that put their own name
33
     * around the contents listed here.
34
     *
35
     * @return string comma separated list of Selectors contained in this one
36
     */
37 0
    public function __toString()
38
    {
39 0
        $buf = "";
40 0
        $arr = $this->selectorElements();
41 0
        for ($i = 0, $size = count($arr); $i < $size; $i++) {
42 0
            $buf .= (string) $arr[$i] . (isset($arr[$i + 1]) ? ', ' : '');
43
        }
44

45 0
        return $buf;
46
    }
47

48
    /**
49
     * <p>This implementation validates the container by calling
50
     * verifySettings() and then validates each contained selector
51
     * provided that the selector implements the validate interface.
52
     * </p>
53
     * <p>Ordinarily, this will validate all the elements of a selector
54
     * container even if the isSelected() method of some elements is
55
     * never called. This has two effects:</p>
56
     * <ul>
57
     * <li>Validation will often occur twice.
58
     * <li>Since it is not required that selectors derive from
59
     * BaseSelector, there could be selectors in the container whose
60
     * error conditions are not detected if their isSelected() call
61
     * is never made.
62
     * </ul>
63
     */
64 0
    public function validate()
65
    {
66 0
        $this->verifySettings();
67 0
        $errmsg = $this->getError();
68 0
        if ($errmsg !== null) {
69 0
            throw new BuildException($errmsg);
70
        }
71 0
        foreach ($this->selectorsList as $o) {
72 0
            if ($o instanceof BaseSelector) {
73 0
                $o->validate();
74
            }
75
        }
76
    }
77
}

Read our documentation on viewing source code .

Loading