1 | <?php |
||
7 | abstract class AbstractToken implements Token |
||
8 | { |
||
9 | /** @var int */ |
||
10 | private $depth; |
||
11 | |||
12 | /** @var null|boolean */ |
||
13 | protected $isValid; |
||
14 | |||
15 | /** @var null|Token */ |
||
16 | private $parent; |
||
17 | |||
18 | /** @var string */ |
||
19 | private $type; |
||
20 | |||
21 | /** |
||
22 | * Constructor |
||
23 | */ |
||
24 | 11 | public function __construct($type, $parent = null) |
|
25 | { |
||
26 | 11 | if (!$this->isValidType($type)) { |
|
27 | throw new \InvalidArgumentException('Invalid type: ' . $type); |
||
28 | } |
||
29 | |||
30 | 11 | $this->isValid = null; |
|
31 | 11 | $this->setParent($parent); |
|
32 | 11 | $this->type = $type; |
|
33 | 11 | } |
|
34 | |||
35 | public function getDepth() |
||
39 | |||
40 | /** |
||
41 | * Getter for 'isValid'. |
||
42 | */ |
||
43 | public function getIsValid() |
||
47 | |||
48 | /** |
||
49 | * Chainable setter for 'isValid'. |
||
50 | */ |
||
51 | 2 | public function setIsValid($isValid) |
|
57 | |||
58 | /** |
||
59 | 11 | * Getter for 'parent'. |
|
60 | */ |
||
61 | 11 | public function getParent() |
|
65 | |||
66 | 11 | /** |
|
67 | * Chainable setter for 'parent'. |
||
68 | 11 | */ |
|
69 | public function setParent($parent = null) |
||
86 | 7 | ||
87 | 11 | public function getType() |
|
91 | |||
92 | public function validate(Configuration $configuration) |
||
101 | |||
102 | protected function isValidType($type) |
||
110 | } |
||
111 |