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 selector has a collection of other selectors, any of which have to
22
 * select a file in order for this selector to select it.
23
 *
24
 * @author  Hans Lellelid <hans@xmpl.org> (Phing)
25
 * @author  Bruce Atherton <bruce@callenish.com> (Ant)
26
 * @package phing.types.selectors
27
 */
28
class OrSelector extends BaseSelectorContainer
29
{
30

31
    /**
32
     * @return string
33
     */
34 0
    public function __toString()
35
    {
36 0
        $buf = "";
37 0
        if ($this->hasSelectors()) {
38 0
            $buf .= "{orselect: ";
39 0
            $buf .= parent::__toString();
40 0
            $buf .= "}";
41
        }
42

43 0
        return $buf;
44
    }
45

46
    /**
47
     * Returns true (the file is selected) if any of the other selectors
48
     * agree that the file should be selected.
49
     *
50
     * @param  PhingFile $basedir the base directory the scan is being done from
51
     * @param  string filename the name of the file to check
52
     * @param  PhingFile $file a PhingFile object for the filename that the selector
53
     *                                                                can use
54
     * @return boolean Whether the file should be selected or not
55
     */
56 0
    public function isSelected(PhingFile $basedir, $filename, PhingFile $file)
57
    {
58 0
        $this->validate();
59

60 0
        $selectors = $this->selectorElements();
61

62
        // First, check that all elements are correctly configured
63

64 0
        for ($i = 0, $size = count($selectors); $i < $size; $i++) {
65 0
            $result = $selectors[$i]->isSelected($basedir, $filename, $file);
66 0
            if ($result) {
67 0
                return true;
68
            }
69
        }
70

71 0
        return false;
72
    }
73
}

Read our documentation on viewing source code .

Loading