1: <?php
2: class Horde_Date_Parser_Token
3: {
4: public $word;
5: public $tags;
6:
7: public function __construct($word)
8: {
9: $this->word = $word;
10: $this->tags = array();
11: }
12:
13: 14: 15:
16: public function tag($tagClass, $tag)
17: {
18: $this->tags[] = array($tagClass, $tag);
19: }
20:
21: 22: 23:
24: public function untag($tagClass)
25: {
26: $this->tags = array_filter($this->tags, create_function('$t', 'return substr($t[0], 0, ' . strlen($tagClass) . ') != "' . $tagClass . '";'));
27: }
28:
29: 30: 31:
32: public function tagged()
33: {
34: return count($this->tags) > 0;
35: }
36:
37: 38: 39:
40: public function getTag($tagClass)
41: {
42: $matches = array_filter($this->tags, create_function('$t', 'return substr($t[0], 0, ' . strlen($tagClass) . ') == "' . $tagClass . '";'));
43: $match = array_shift($matches);
44: return $match[1];
45: }
46:
47: 48: 49:
50: public function __toString()
51: {
52: return '(' . implode(', ', $this->tags) . ') ';
53: }
54:
55: }
56: