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

Source for file Numeric.php

Documentation is available at Numeric.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      Marc Schrader
  18.  * @author      Florian Sonnenburg
  19.  * @copyright   Copyright (c) 2007 Florian Sonnenburg
  20.  * @license     http://formagic.weasle.de/licence.txt     New BSD License
  21.  * @revision    $Revision: 17 $
  22.  */
  23.  
  24. require_once('Rule.php');
  25.  
  26. /**
  27.  * Checks if value is numeric
  28.  *
  29.  * @category    Formagic
  30.  * @package     Rule
  31.  * @author      Marc Schrader
  32.  * @author      Florian Sonnenburg
  33.  * @copyright   Copyright (c) 2007 Marc Schrader
  34.  * @version     $Id: Numeric.php 17 2007-08-19 20:40:10Z meweasle $
  35.  ***/
  36. {
  37.  
  38.     /**
  39.      * Default error message
  40.      * @var string 
  41.      ***/
  42.     protected $_errorMessage = 'Bitte einen numerischen Wert eingeben';
  43.  
  44.     /**
  45.      * Default error code
  46.      * @var integer 
  47.      ***/
  48.     protected $_errorCode = 1;
  49.  
  50.     /**
  51.      * Performs rule check
  52.      *
  53.      * Numeric rule checks if value is numeric.
  54.      *
  55.      * @param Formagic_Item $itemObj 
  56.      * @return boolean 
  57.      ***/
  58.     public function check($item)
  59.     {
  60.         $value $item->getValue();
  61.         if (!$value && !$item->hasRule('mandatory')) {
  62.             return true;
  63.         }
  64.         if (is_numeric($value)) {
  65.             return true;
  66.         }
  67.         return false;
  68.     }
  69. }

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