Mark V
1: <?php
2: namespace MOC\V\Component\Document\Vendor\UniversalXml\Source;
3:
4: /**
5: * Class Token
6: *
7: * @package MOC\V\Component\Document\Vendor\UniversalXml\Source
8: */
9: class Token extends TokenPattern
10: {
11:
12: private $Name = '';
13: private $AttributeList = array();
14: private $Position = 0;
15:
16: /**
17: * @param array $Content
18: */
19: function __construct($Content)
20: {
21:
22: $this->Position = $Content[1];
23: $this->Name = preg_replace('!\s.*?$!is', '', $Content[0]);
24: preg_match_all('![\w:]+="[^"]*?"!is', $Content[0], $Matches);
25: $Token = $Matches[0];
26:
27: $Attribute = array();
28: while (null !== ( $AttributeString = array_pop($Token) )) {
29: if ($AttributeString != '/') {
30: preg_match('!(.*?)="(.*?)(?=")!is', $AttributeString, $Attribute);
31: if (count($Attribute) == 3) {
32: $this->AttributeList[$Attribute[1]] = $Attribute[2];
33: }
34: }
35: }
36: $this->determineType($Content[0]);
37: }
38:
39: /**
40: * @return string
41: */
42: public function getName()
43: {
44:
45: return $this->Name;
46: }
47:
48: /**
49: * @return int
50: */
51: public function getPosition()
52: {
53:
54: return $this->Position;
55: }
56:
57: /**
58: * @return array
59: */
60: public function getAttributeList()
61: {
62:
63: return $this->AttributeList;
64: }
65: }
66: