1: <?php
2: class Horde_Date_Parser_Result
3: {
4: public $span;
5: public $tokens = array();
6:
7: public function __construct($span, $tokens)
8: {
9: $this->span = $span;
10: $this->tokens = $tokens;
11: }
12:
13: 14: 15:
16: public function guess()
17: {
18: if (! $this->span instanceof Horde_Date_Span) {
19: return null;
20: }
21:
22: if ($this->span->width() > 1) {
23: return $this->span->begin->add($this->span->width() / 2);
24: } else {
25: return $this->span->begin;
26: }
27: }
28:
29: public function taggedText()
30: {
31: $taggedTokens = array_values(array_filter($this->tokens, create_function('$t', 'return $t->tagged();')));
32: return implode(' ', array_map(create_function('$t', 'return $t->word;'), $taggedTokens));
33: }
34:
35: public function untaggedText()
36: {
37: $untaggedTokens = array_values(array_filter($this->tokens, create_function('$t', 'return ! $t->tagged();')));
38: return implode(' ', array_map(create_function('$t', 'return $t->word;'), $untaggedTokens));
39: }
40:
41: }
42: