Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
 
4
/**
5
 * Evaluates to true iif one at least of the predicates
6
 * given as constructor parameters evaluate to true
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * This library is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU Lesser General Public
12
 * License as published by the Free Software Foundation; either
13
 * version 2.1 of the License, or (at your option) any later version.
14
 *
15
 * This library is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18
 * Lesser General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Lesser General Public
21
 * License along with this library; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
23
 *
24
 * @category   File Formats
25
 * @package    File_Archive
26
 * @author     Vincent Lascaux <vincentlascaux@php.net>
27
 * @copyright  1997-2005 The PHP Group
28
 * @license    http://www.gnu.org/copyleft/lesser.html  LGPL
29
 * @version    CVS: $Id: Or.php,v 1.8 2005/04/21 10:01:47 vincentlascaux Exp $
30
 * @link       http://pear.php.net/package/File_Archive
31
 */
32
 
33
require_once "File/Archive/Predicate.php";
34
 
35
/**
36
 * Evaluates to true iif one at least of the predicates
37
 * given as constructor parameters evaluate to true
38
 *
39
 * @see        File_Archive_Predicate, File_Archive_Reader_Filter
40
 */
41
class File_Archive_Predicate_Or extends File_Archive_Predicate
42
{
43
    /**
44
     * @var Array List of File_Archive_Predicate objects given as an argument
45
     * @access private
46
     */
47
    var $preds;
48
 
49
    /**
50
     * Build the predicate using the optional File_Archive_Predicates given as
51
     * arguments
52
     *
53
     * Example:
54
     *   new File_Archive_Predicate_And($pred1, $pred2, $pred3)
55
     */
56
    function File_Archive_Predicate_And()
57
    {
58
        $this->preds = func_get_args();
59
    }
60
 
61
    /**
62
     * Add a new predicate to the list
63
     *
64
     * @param File_Archive_Predicate The predicate to add
65
     */
66
    function addPredicate($pred)
67
    {
68
        $this->preds[] = $pred;
69
    }
70
 
71
    /**
72
     * @see File_Archive_Predicate::isTrue()
73
     */
74
    function isTrue(&$source)
75
    {
76
        foreach ($this->preds as $p) {
77
            if ($p->isTrue($source)) {
78
                return true;
79
            }
80
        }
81
        return false;
82
    }
83
}
84
 
85
?>