1 | <?php |
||
15 | class EnumMap extends SplObjectStorage |
||
16 | { |
||
17 | /** |
||
18 | * The classname of the enumeration type |
||
19 | * @var string |
||
20 | */ |
||
21 | private $enumeration; |
||
22 | |||
23 | /** |
||
24 | * Constructor |
||
25 | * @param string $enumeration The classname of the enumeration type |
||
26 | * @throws InvalidArgumentException |
||
27 | */ |
||
28 | 8 | public function __construct($enumeration) |
|
38 | |||
39 | /** |
||
40 | * Get the classname of the enumeration |
||
41 | * @return string |
||
42 | */ |
||
43 | 1 | public function getEnumeration() |
|
47 | |||
48 | /** |
||
49 | * Attach a new enumerator or overwrite an existing one |
||
50 | * @param Enum|null|boolean|int|float|string $enumerator |
||
51 | * @param mixed $data |
||
52 | * @return void |
||
53 | * @throws InvalidArgumentException On an invalid given enumerator |
||
54 | */ |
||
55 | 3 | public function attach($enumerator, $data = null) |
|
60 | |||
61 | /** |
||
62 | * Test if the given enumerator exists |
||
63 | * @param Enum|null|boolean|int|float|string $enumerator |
||
64 | * @return boolean |
||
65 | */ |
||
66 | 5 | public function contains($enumerator) |
|
76 | |||
77 | /** |
||
78 | * Detach an enumerator |
||
79 | * @param Enum|null|boolean|int|float|string $enumerator |
||
80 | * @return void |
||
81 | * @throws InvalidArgumentException On an invalid given enumerator |
||
82 | */ |
||
83 | 2 | public function detach($enumerator) |
|
88 | |||
89 | /** |
||
90 | * Get a unique identifier for the given enumerator |
||
91 | * @param Enum|null|boolean|int|float|string $enumerator |
||
92 | * @return string |
||
93 | * @throws InvalidArgumentException On an invalid given enumerator |
||
94 | */ |
||
95 | 5 | public function getHash($enumerator) |
|
100 | |||
101 | /** |
||
102 | * Test if the given enumerator exists |
||
103 | * @param Enum|null|boolean|int|float|string $enumerator |
||
104 | * @return boolean |
||
105 | * @see contains() |
||
106 | */ |
||
107 | 3 | public function offsetExists($enumerator) |
|
111 | |||
112 | /** |
||
113 | * Get mapped data for the given enumerator |
||
114 | * @param Enum|null|boolean|int|float|string $enumerator |
||
115 | * @return mixed |
||
116 | * @throws InvalidArgumentException On an invalid given enumerator |
||
117 | */ |
||
118 | 4 | public function offsetGet($enumerator) |
|
123 | |||
124 | /** |
||
125 | * Attach a new enumerator or overwrite an existing one |
||
126 | * @param Enum|null|boolean|int|float|string $enumerator |
||
127 | * @param mixed $data |
||
128 | * @return void |
||
129 | * @throws InvalidArgumentException On an invalid given enumerator |
||
130 | * @see attach() |
||
131 | */ |
||
132 | 3 | public function offsetSet($enumerator, $data = null) |
|
137 | |||
138 | /** |
||
139 | * Detach an existing enumerator |
||
140 | * @param Enum|null|boolean|int|float|string $enumerator |
||
141 | * @return void |
||
142 | * @throws InvalidArgumentException On an invalid given enumerator |
||
143 | * @see detach() |
||
144 | */ |
||
145 | 2 | public function offsetUnset($enumerator) |
|
150 | |||
151 | /** |
||
152 | * Get the current value |
||
153 | * @return mixed |
||
154 | */ |
||
155 | 1 | public function current() |
|
159 | |||
160 | /** |
||
161 | * Get the current key |
||
162 | * @return Enum|null |
||
163 | */ |
||
164 | 1 | public function key() |
|
168 | } |
||
169 |