LctvApiHelpers.inc 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * LiveEdu.tv API helper methods.
  4. *
  5. * @package LctvApi\Credentials
  6. * @since 0.0.3
  7. * @version 0.0.9
  8. */
  9. class LctvApiHelpers {
  10. /**
  11. * Throw execption if these constants are undefined.
  12. *
  13. * @since 0.0.8
  14. * @storage static
  15. * @access public
  16. *
  17. * @throws Exception - If constant undefined.
  18. */
  19. public static function ValidateConstants( $constants ) {
  20. foreach ($constants as $constant) {
  21. if ( ! defined( $constant ) ) {
  22. throw new Exception(CONSTANT_UNDEFINED_MSG . $constant, 1);
  23. }
  24. }
  25. }
  26. /**
  27. * Filter named get param or return a supplied default value.
  28. *
  29. * @since 0.0.8
  30. * @storage static
  31. * @access public
  32. */
  33. public static function SanitizeGetParam( $param_name, $default_value ) {
  34. return ( ! empty( $param_name ) &&
  35. isset( $_GET[$param_name] ) &&
  36. ! empty( $_GET[$param_name] ) ) ?
  37. strtolower( htmlspecialchars( $_GET[$param_name] ) ) :
  38. $default_value;
  39. }
  40. }
  41. ?>