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

Source for file Rule.php

Documentation is available at Rule.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.  * @revision    $Revision: 17 $
  21.  */
  22.  
  23. /**
  24.  * FormagicRule abstract superclass
  25.  *
  26.  * @category    Formagic
  27.  * @package     Rule
  28.  * @author      Florian Sonnenburg
  29.  * @copyright   Copyright (c) 2007
  30.  * @version     $Id: Rule.php 17 2007-08-19 20:40:10Z meweasle $
  31.  ***/
  32. abstract class Formagic_Rule
  33. {
  34.  
  35.     /**
  36.      * Rule type
  37.      * @var string 
  38.      */
  39.     protected $_type;
  40.  
  41.     /**
  42.      * Arguments passed to to rule object
  43.      * @var array 
  44.      */
  45.     protected $_args;
  46.  
  47.     /**
  48.      * Error message
  49.      * @var mixed 
  50.      */
  51.     protected $_errorMessage = '';
  52.  
  53.     /**
  54.      * Error code
  55.      * @var integer 
  56.      ***/
  57.     protected $_errorCode;
  58.  
  59.     /**
  60.      * Level of error occured in rule. Can be Formagic::DEBUG, Formagic::NOTICE
  61.      * or Formagic::ERROR
  62.      *
  63.      * @var integer 
  64.      ***/
  65.     protected $_errorLevel = Formagic::ERROR;
  66.  
  67.     /**
  68.      * Constructor
  69.      *
  70.      * @param string $type 
  71.      * @param mixed $errorMessage 
  72.      * @param array $args 
  73.      * @return void 
  74.      ***/
  75.     public function __construct($type$errorMessage=null$args=null)
  76.     {
  77.         $this->_type = $type;
  78.         if ($errorMessage{
  79.             $this->_errorMessage = $errorMessage;
  80.         }
  81.         $this->_args = $args;
  82.     }
  83.  
  84.     /**
  85.      * Returns error message of rule
  86.      *
  87.      * @return string 
  88.      */
  89.     public function getMessage()
  90.     {
  91.         return $this->_errorMessage;
  92.     }
  93.  
  94.     /**
  95.      * Returns error code of rule
  96.      *
  97.      * @return 
  98.      */
  99.     public function getCode()
  100.     {
  101.         return $this->_errorCode;
  102.     }
  103.  
  104.     /**
  105.      * Returns error level of rule. Default is Formagic::ERROR
  106.      *
  107.      * @return integer 
  108.      */
  109.     public function getLevel()
  110.     {
  111.         return $this->_errorLevel;
  112.     }
  113.  
  114.     /**
  115.      * Returns rule type identification string
  116.      *
  117.      * @return string 
  118.      */
  119.     public function getType()
  120.     {
  121.         return $this->_type;
  122.     }
  123.  
  124.  
  125.     /**
  126.      * Abstract of main check method. Returns boolean value of check success.
  127.      *
  128.      * Subclasses have to implement their behaviour here.
  129.      *
  130.      * @param Formagic_Item $itemObj 
  131.      * @return boolean 
  132.      ***/
  133.     abstract protected function check($itemObj);
  134.  
  135. }

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