Mark V
1: <?php
2: namespace MOC\V\Component\Document\Vendor\UniversalXml\Source;
3:
4: /**
5: * Class TokenPattern
6: *
7: * @package MOC\V\Component\Document\Vendor\UniversalXml\Source
8: */
9: abstract class TokenPattern extends TokenType
10: {
11:
12: private $PatternTagOpen = '!^[^\!/].*?[^/]$!is';
13: private $PatternTagClose = '!^/.*?!is';
14: private $PatternTagShort = '!^[^\!].*?/$!is';
15: private $PatternTagCDATA = '!^\!\[CDATA.*?\]\]$!is';
16: private $PatternTagComment = '!^\![^\[].*?--$!is';
17:
18: /**
19: * @param $Content
20: */
21: protected function determineType($Content)
22: {
23:
24: if (preg_match($this->PatternTagCDATA, $Content)) {
25: $this->Type = self::TYPE_CDATA;
26: } else {
27: if (preg_match($this->PatternTagComment, $Content)) {
28: $this->Type = self::TYPE_COMMENT;
29: } else {
30: if ($Content[0] == '/') {
31: $this->Type = self::TYPE_CLOSE;
32: } else {
33: if ($Content[strlen($Content) - 1] == '/') {
34: $this->Type = self::TYPE_SHORT;
35: } else {
36: if (strpos($Content, '/') !== 0) {
37: $this->Type = self::TYPE_OPEN;
38: }
39: }
40: }
41: }
42: }
43: }
44: }
45: