Source for file AlwaysTrueValidatorRule.class.php

Documentation is available at AlwaysTrueValidatorRule.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."utilities/FieldSetValidator/rules/ValidatorRule.interface.php");
  4.  
  5. /**
  6. * an AlwaysTrueValidatorRule will always return valid for a given value
  7. *
  8. * @package harmoni.utilities.fieldsetvalidator.rules
  9. *
  10. * @copyright Copyright &copy; 2005, Middlebury College
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  12. *
  13. * @version $Id: AlwaysTrueValidatorRule.class.php,v 1.5 2007/09/04 20:25:55 adamfranco Exp $
  14. */
  15. class AlwaysTrueValidatorRule
  16. extends ValidatorRuleInterface
  17. {
  18. /**
  19. * returns true no matter what
  20. * @param mixed $val the value to check against the regex
  21. * @access public
  22. * @return boolean true if the check succeeds, false if it (guess...) fails.
  23. ***/
  24. function check( $val ) {
  25. return true;
  26. }
  27. /**
  28. * This is a static method to return an already-created instance of a validator
  29. * rule. There are at most about a hundred unique rule objects in use durring
  30. * any given execution cycle, but rule objects are instantiated hundreds of
  31. * thousands of times.
  32. *
  33. * This method follows a modified Singleton pattern
  34. *
  35. * @return object ValidatorRule
  36. * @access public
  37. * @static
  38. * @since 3/28/05
  39. */
  40. function getRule () {
  41. // Because there is no way in PHP to get the class name of the descendent
  42. // class on which this method is called, this method must be implemented
  43. // in each descendent class.
  44.  
  45. if (!isset($GLOBALS['validator_rules']) || !is_array($GLOBALS['validator_rules']))
  46. $GLOBALS['validator_rules'] = array();
  47. $class = __CLASS__;
  48. if (!isset($GLOBALS['validator_rules'][$class]))
  49. $GLOBALS['validator_rules'][$class] = new $class;
  50. return $GLOBALS['validator_rules'][$class];
  51. }
  52. }
  53.  
  54. ?>

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