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

Source for file Equal.php

Documentation is available at Equal.php

  1. <?php
  2. /**
  3.  * Formagic
  4.  *
  5.  * LICENCE
  6.  *
  7.  * This source file is subject to the new BSD license that is bundled
  8.  * with this package in the file LICENSE.txt.
  9.  * It is also available through the world-wide-web at
  10.  * http://formagic.weasle.de/licence.txt
  11.  * If you did not receive a copy of the license and are unable to
  12.  * obtain it through the world-wide-web, please send an email
  13.  * to licence@weasle.de so we can send you a copy immediately.
  14.  *
  15.  * @category    Formagic
  16.  * @package     Rule
  17.  * @author      Florian Sonnenburg
  18.  * @copyright   Copyright (c) 2007 Florian Sonnenburg
  19.  * @license     http://formagic.weasle.de/licence.txt     New BSD License
  20.  * @version     $Id: Equal.php 14 2007-08-13 20:33:26Z meweasle $
  21.  */
  22.  
  23. require_once('Rule.php');
  24.  
  25. /**
  26.  * Checks if value is given
  27.  *
  28.  * @category    Formagic
  29.  * @package     Rule
  30.  * @author      Florian Sonnenburg
  31.  * @copyright   Copyright (c) 2007 Florian Sonnenburg
  32.  * @license     http://formagic.weasle.de/licence.txt     New BSD License
  33.  * @version     $Id: Equal.php 14 2007-08-13 20:33:26Z meweasle $
  34.  ***/
  35. {
  36.  
  37.     /**
  38.      * Default error message
  39.      * @var     string 
  40.      ***/
  41.     protected $_errorMessage = 'Values do not match';
  42.  
  43.     /**
  44.      * Default error code
  45.      * @var     integer 
  46.      ***/
  47.     protected $_errorCode = 2;
  48.  
  49.     /**
  50.      * Performs rule check
  51.      *
  52.      * Mandatory rule checks if value is given. Throws formagicRuleException if not.
  53.      *
  54.      * @param   mixed $value Value to be checked
  55.      * @return  boolean 
  56.      ***/
  57.     public function check($itemObj{
  58.         if ($this->_args instanceOf Formagic_Item{
  59.             $compVal $this->_args->getValue();
  60.         elseif(is_string($this->_args)) {
  61.             $compVal $itemObj->getCaller()->getValue($this->_args);
  62.         else {
  63.             throw new Formagic_Exception('Rule can only be applied on another item');
  64.         }
  65.         if ((string)$itemObj->getValue(!== (string)$compVal{
  66.             return false;
  67.         }
  68.         return true;
  69.     }
  70.  
  71. }

Documentation generated on Thu, 23 Aug 2007 00:29:36 +0200 by phpDocumentor 1.4.0