1 | <?php |
||
52 | class TokenizerRegistry implements Iterator, Countable |
||
53 | { |
||
54 | /** |
||
55 | * Storage for the Tokenizers. |
||
56 | * |
||
57 | * @var Tokenizer[] $_registry |
||
58 | */ |
||
59 | private $registry = array(); |
||
60 | |||
61 | /** |
||
62 | * Add an item to the registry |
||
63 | * |
||
64 | * @param Tokenizer $tokenizer The tokeniter to be added |
||
65 | * |
||
66 | * @return TokenizerRegistry |
||
67 | */ |
||
68 | public function add(Tokenizer $tokenizer) |
||
76 | |||
77 | /** |
||
78 | * Get a dictionary entry by its key |
||
79 | * |
||
80 | * @param mixed $key The key to get the tokenizer for. |
||
81 | * |
||
82 | * @return Tokenizer|null |
||
83 | */ |
||
84 | public function getTokenizerWithKey($key) |
||
92 | |||
93 | /** |
||
94 | * Cleanup the registry |
||
95 | * |
||
96 | * @return TokenizerRegistry |
||
97 | */ |
||
98 | public function cleanup() |
||
104 | |||
105 | /** |
||
106 | * Pass the given string through the given tokenizers |
||
107 | * |
||
108 | * @param string|TokenRegistry $string The String to be tokenized |
||
109 | * |
||
110 | * @return TokenRegistry |
||
111 | */ |
||
112 | public function tokenize($string) |
||
125 | |||
126 | /** |
||
127 | * Implementation of Iterator |
||
128 | * |
||
129 | * @see Iterator::rewind() |
||
130 | * |
||
131 | * @return void |
||
132 | */ |
||
133 | public function rewind() |
||
137 | |||
138 | /** |
||
139 | * Get the current object |
||
140 | * |
||
141 | * @see Iterator::current() |
||
142 | * |
||
143 | * @return Tokenizer |
||
144 | */ |
||
145 | public function current() |
||
149 | |||
150 | /** |
||
151 | * Get the current key |
||
152 | * |
||
153 | * @see Iterator::key() |
||
154 | * |
||
155 | * @return mixed |
||
156 | */ |
||
157 | public function key() |
||
161 | |||
162 | /** |
||
163 | * Get the number of items in the registry |
||
164 | * |
||
165 | * @see Countable::count() |
||
166 | * |
||
167 | * @return int |
||
168 | */ |
||
169 | public function count() |
||
173 | |||
174 | /** |
||
175 | * Push the internal pointer forward one step |
||
176 | * |
||
177 | * @see Iterator::next() |
||
178 | * |
||
179 | * @return void |
||
180 | */ |
||
181 | public function next() |
||
185 | |||
186 | /** |
||
187 | * Check whether the current pointer is in a valid place |
||
188 | * |
||
189 | * @see Iterator::valid() |
||
190 | * |
||
191 | * @return boolean |
||
192 | */ |
||
193 | public function valid() |
||
201 | } |
||
202 |