APPLICATION_Helper.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * App helper file.
  4. *
  5. * Provides a helper to perform app related operations.
  6. *
  7. * @category Helper.
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::HELPER . "Helper.php");
  13. /**
  14. * Application helper.
  15. *
  16. * Contains app-related utilities.
  17. *
  18. * @category Helper.
  19. */
  20. final class APPLICATION extends Helper{
  21. /**
  22. * Checks if a value is a valid one in a constant class.
  23. *
  24. * It will intentionally fail when used for a non constant class.
  25. *
  26. * @param string $class Name of the class.
  27. * @param int $value Value to check.
  28. * @return bool True if the value is defined, false otherwise.
  29. */
  30. public static function valid_id($class, $value){
  31. if (strtoupper($class) != $class){
  32. return false;
  33. }
  34. if (!class_exists($class, false)){
  35. return false;
  36. }
  37. $reflect = new ReflectionClass($class);
  38. if (in_array($value, $reflect->getConstants())){
  39. return true;
  40. }
  41. else{
  42. return false;
  43. }
  44. }
  45. }
  46. ?>