Source for file ResourceValidatorRule.class.php

Documentation is available at ResourceValidatorRule.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."utilities/FieldSetValidator/rules/ValidatorRule.interface.php");
  4.  
  5. /**
  6. * the ResourceValidatorRule checks a given value to make sure it's resource
  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: ResourceValidatorRule.class.php,v 1.5 2007/09/04 20:25:55 adamfranco Exp $
  14. */
  15. class ResourceValidatorRule
  16. extends ValidatorRuleInterface
  17. {
  18. /**
  19. * Checks a given value to make sure it's an resource.
  20. * Checks a given value to make sure it's an resource.
  21. * @param mixed $val The value to check.
  22. * @access public
  23. * @return boolean TRUE, if the value is a resource; FALSE if it is not.
  24. ***/
  25. function check( $val ) {
  26. return is_resource($val);
  27. }
  28. /**
  29. * This is a static method to return an already-created instance of a validator
  30. * rule. There are at most about a hundred unique rule objects in use durring
  31. * any given execution cycle, but rule objects are instantiated hundreds of
  32. * thousands of times.
  33. *
  34. * This method follows a modified Singleton pattern
  35. *
  36. * @return object ValidatorRule
  37. * @access public
  38. * @static
  39. * @since 3/28/05
  40. */
  41. function getRule () {
  42. // Because there is no way in PHP to get the class name of the descendent
  43. // class on which this method is called, this method must be implemented
  44. // in each descendent class.
  45.  
  46. if (!isset($GLOBALS['validator_rules']) || !is_array($GLOBALS['validator_rules']))
  47. $GLOBALS['validator_rules'] = array();
  48. $class = __CLASS__;
  49. if (!isset($GLOBALS['validator_rules'][$class]))
  50. $GLOBALS['validator_rules'][$class] = new $class;
  51. return $GLOBALS['validator_rules'][$class];
  52. }
  53. }
  54.  
  55. ?>

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