Source for file ValidatorRule.interface.php

Documentation is available at ValidatorRule.interface.php

  1. <?php
  2.  
  3. /**
  4. * the ValidatorRuleInterface defines the methods required by any ValidatorRule
  5. *
  6. * @package harmoni.utilities.fieldsetvalidator.rules
  7. *
  8. * @copyright Copyright &copy; 2005, Middlebury College
  9. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  10. *
  11. * @version $Id: ValidatorRule.interface.php,v 1.6 2007/09/04 20:25:55 adamfranco Exp $
  12. */
  13. class ValidatorRuleInterface{
  14. /**
  15. * checks a given value against the rule contained within the class
  16. * @param mixed $val the value to check against the rule
  17. * @access public
  18. * @return boolean true if the check succeeds, false if it (guess...) fails.
  19. ***/
  20. function check( $val ) {
  21. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  22. }
  23. /**
  24. * This is a static method to return an already-created instance of a validator
  25. * rule. There are at most about a hundred unique rule objects in use durring
  26. * any given execution cycle, but rule objects are instantiated hundreds of
  27. * thousands of times.
  28. *
  29. * This method follows a modified Singleton pattern
  30. *
  31. * @return object ValidatorRule
  32. * @access public
  33. * @static
  34. * @since 3/28/05
  35. */
  36. function getRule () {
  37. // Because there is no way in PHP to get the class name of the descendent
  38. // class on which this method is called, this method must be implemented
  39. // in each descendent class.
  40. die ("Method <b>".__FUNCTION__."()</b> declared in interface<b> ".__CLASS__."</b> has not been overloaded in a child class.");
  41.  
  42. if (!isset($GLOBALS['validator_rules']) || !is_array($GLOBALS['validator_rules']))
  43. $GLOBALS['validator_rules'] = array();
  44. $class = __CLASS__;
  45. if (!isset($GLOBALS['validator_rules'][$class]))
  46. $GLOBALS['validator_rules'][$class] = new $class;
  47. return $GLOBALS['validator_rules'][$class];
  48. }
  49. /**
  50. * Return a key that can be used to identify this Rule for caching purposes.
  51. * If this rule takes no arguments, the class name should be sufficient.
  52. * otherwise, append the arguments.
  53. *
  54. * This method should only be called by ValidatorRules.
  55. *
  56. * @return string
  57. * @access protected
  58. * @since 3/29/05
  59. */
  60. function getRuleKey () {
  61. return get_class($this);
  62. }
  63. }
  64.  
  65. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:41 -0400 by phpDocumentor 1.3.0RC3