1 | <?php |
||
30 | class Node |
||
31 | { |
||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $attributes = []; |
||
36 | |||
37 | /** |
||
38 | * @var Node[] |
||
39 | */ |
||
40 | private $children = []; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $lineNr = 0; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | private $name; |
||
51 | |||
52 | /** |
||
53 | * @var mixed |
||
54 | */ |
||
55 | private $value = ''; |
||
56 | |||
57 | public function __construct(int $lineNr = 0, $value = '') |
||
63 | |||
64 | /** |
||
65 | * Accept a visitor |
||
66 | */ |
||
67 | public function accept(VisitorInterface $visitor): void |
||
77 | |||
78 | /** |
||
79 | * Get line number this node definition started at |
||
80 | */ |
||
81 | public function getLineNr(): int |
||
85 | |||
86 | /** |
||
87 | * Get node name |
||
88 | */ |
||
89 | public function getName(): string |
||
93 | |||
94 | /** |
||
95 | * Set a custom node name |
||
96 | */ |
||
97 | public function setName(string $name): void |
||
101 | |||
102 | /** |
||
103 | * Get node type identifier |
||
104 | */ |
||
105 | public function getType(): string |
||
109 | |||
110 | /** |
||
111 | * Get raw value wrapped by node |
||
112 | * |
||
113 | * @return mixed Loaded node value |
||
114 | */ |
||
115 | public function getValue() |
||
119 | |||
120 | /** |
||
121 | * Check if this is a null object implementation |
||
122 | */ |
||
123 | public function isNull(): bool |
||
127 | |||
128 | /** |
||
129 | * Set a child node |
||
130 | */ |
||
131 | public function addChild(Node $node): void |
||
135 | |||
136 | /** |
||
137 | * Get child node |
||
138 | */ |
||
139 | public function getChild(string $name): Node |
||
149 | |||
150 | /** |
||
151 | * Check if child exists |
||
152 | */ |
||
153 | public function hasChild(string $name): bool |
||
163 | |||
164 | /** |
||
165 | * Get registered child nodes |
||
166 | * |
||
167 | * @return Node[] |
||
168 | */ |
||
169 | public function getChildren(string $name = ''): array |
||
181 | |||
182 | /** |
||
183 | * Get raw value wrapped in child node |
||
184 | * |
||
185 | * @return mixed Loaded node value |
||
186 | */ |
||
187 | public function getValueFrom(string $name) |
||
191 | |||
192 | /** |
||
193 | * Set a custom attribute on node |
||
194 | * |
||
195 | * @param string $name Name of attribute |
||
196 | * @param mixed $value Value of attribute |
||
197 | */ |
||
198 | public function setAttribute(string $name, $value): void |
||
202 | |||
203 | /** |
||
204 | * Get custom attribute |
||
205 | * |
||
206 | * @param string $name Name of attribute |
||
207 | * @return mixed Value of attribute |
||
208 | */ |
||
209 | public function getAttribute(string $name) |
||
213 | |||
214 | /** |
||
215 | * Check if attribute has been set |
||
216 | */ |
||
217 | public function hasAttribute(string $name): bool |
||
221 | |||
222 | /** |
||
223 | * Get all registered attributes |
||
224 | */ |
||
225 | public function getAttributes(): array |
||
229 | } |
||
230 |