Id.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Represents a directive ID in the interchange format.
  4. */
  5. class HTMLPurifier_ConfigSchema_Interchange_Id
  6. {
  7. /**
  8. * @type string
  9. */
  10. public $key;
  11. /**
  12. * @param string $key
  13. */
  14. public function __construct($key)
  15. {
  16. $this->key = $key;
  17. }
  18. /**
  19. * @return string
  20. * @warning This is NOT magic, to ensure that people don't abuse SPL and
  21. * cause problems for PHP 5.0 support.
  22. */
  23. public function toString()
  24. {
  25. return $this->key;
  26. }
  27. /**
  28. * @return string
  29. */
  30. public function getRootNamespace()
  31. {
  32. return substr($this->key, 0, strpos($this->key, "."));
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getDirective()
  38. {
  39. return substr($this->key, strpos($this->key, ".") + 1);
  40. }
  41. /**
  42. * @param string $id
  43. * @return HTMLPurifier_ConfigSchema_Interchange_Id
  44. */
  45. public static function make($id)
  46. {
  47. return new HTMLPurifier_ConfigSchema_Interchange_Id($id);
  48. }
  49. }
  50. // vim: et sw=4 sts=4