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