1 | <?php |
||
5 | abstract class AbstractToken implements Token |
||
6 | { |
||
7 | /** @var null|Token */ |
||
8 | private $parent; |
||
9 | |||
10 | /** @var boolean */ |
||
11 | private $throwOnError; |
||
12 | |||
13 | /** @var string */ |
||
14 | private $type; |
||
15 | |||
16 | /** |
||
17 | * Constructor |
||
18 | */ |
||
19 | 85 | public function __construct($type, Token $parent = null, $throwOnError = false) |
|
20 | { |
||
21 | 85 | if (!$this->isValidType($type)) { |
|
22 | 1 | throw new \InvalidArgumentException('Invalid type: ' . $type); |
|
23 | } |
||
24 | |||
25 | 84 | $this->parent = $parent; |
|
26 | 84 | $this->throwOnError = (boolean) $throwOnError; |
|
27 | 84 | $this->type = $type; |
|
28 | 84 | } |
|
29 | |||
30 | 6 | public function isClosingElementImplied($html) |
|
31 | { |
||
32 | 6 | return false; |
|
33 | } |
||
34 | |||
35 | 23 | public function getParent() |
|
36 | { |
||
37 | 23 | return $this->parent; |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Getter for 'throwOnError'. |
||
42 | * |
||
43 | * @return boolean |
||
44 | */ |
||
45 | 19 | protected function getThrowOnError() |
|
49 | |||
50 | /** |
||
51 | * Getter for 'type'. |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | 1 | public function getType() |
|
59 | |||
60 | 1 | public function isCDATA() |
|
64 | |||
65 | 1 | public function isComment() |
|
69 | |||
70 | 1 | public function isDocType() |
|
74 | |||
75 | 1 | public function isElement() |
|
79 | |||
80 | 1 | public function isText() |
|
84 | |||
85 | 85 | protected function isValidType($type) |
|
93 | } |
||
94 |