File_Archive
[ class tree: File_Archive ] [ index: File_Archive ] [ all elements ]

Source for file Or.php

Documentation is available at Or.php

  1. <?
  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.4 2005/02/18 21:00:49 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 arguments
  51.      *
  52.      * Example:
  53.      *   new File_Archive_Predicate_And($pred1, $pred2, $pred3)
  54.      */
  55.     function File_Archive_Predicate_And()
  56.     {
  57.         $this->preds = func_get_args();
  58.     }
  59.  
  60.     /**
  61.      * Add a new predicate to the list
  62.      *
  63.      * @param File_Archive_Predicate The predicate to add
  64.      */
  65.     function addPredicate($pred)
  66.     {
  67.         $this->preds[] = $pred;
  68.     }
  69.  
  70.     /**
  71.      * @see File_Archive_Predicate::isTrue
  72.      */
  73.     function isTrue(&$source)
  74.     {
  75.         foreach($this->preds as $p)
  76.         {
  77.             if($p->isTrue($source)) {
  78.                 return true;
  79.             }
  80.         }
  81.         return false;
  82.     }
  83. }
  84.  
  85. ?>

Documentation generated on Mon, 11 Mar 2019 14:24:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.