Mark V
1: <?php
2: namespace MOC\V\Component\Document\Vendor\UniversalXml\Source;
3:
4: /**
5: * Class Tokenizer
6: *
7: * @package MOC\V\Component\Document\Vendor\UniversalXml\Source
8: */
9: class Tokenizer extends Mask
10: {
11:
12: private $Content = '';
13: private $PatternToken = '!(?<=<)[^?][^<>]*?(?=>)!is';
14: private $Result = array();
15:
16: /**
17: * @param string $Content
18: */
19: function __construct($Content)
20: {
21:
22: $this->Content = $Content;
23: $this->Content = $this->encodePayload($this->Content, self::PATTERN_COMMENT);
24: $this->Content = $this->encodePayload($this->Content, self::PATTERN_CDATA);
25: preg_match_all($this->PatternToken, $this->Content, $this->Result, PREG_OFFSET_CAPTURE);
26:
27: $this->Result = array_map(array($this, 'buildToken'), $this->Result[0]);
28: }
29:
30: /**
31: * @return array
32: */
33: public function getResult()
34: {
35:
36: return $this->Result;
37: }
38:
39: /**
40: * @return string
41: */
42: public function getContent()
43: {
44:
45: return $this->Content;
46: }
47:
48: /**
49: * @param array $Content
50: *
51: * @return Token
52: */
53: private function buildToken($Content)
54: {
55:
56: return new Token($Content);
57: }
58:
59: }
60: