1 | <?php |
||
20 | abstract class AbstractNode implements NodeInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $name; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $path; |
||
31 | |||
32 | /** |
||
33 | * @var NodeInterface |
||
34 | */ |
||
35 | protected $parent; |
||
36 | |||
37 | /** |
||
38 | * @var mixed |
||
39 | */ |
||
40 | protected $defaultValue; |
||
41 | |||
42 | /** |
||
43 | * @var bool |
||
44 | */ |
||
45 | protected $defaultValueSet; |
||
46 | |||
47 | /** |
||
48 | * @var bool |
||
49 | */ |
||
50 | protected $required; |
||
51 | |||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $allowOverwrite; |
||
56 | |||
57 | /** |
||
58 | * Constructor. |
||
59 | * |
||
60 | * @param string $name |
||
61 | * @param NodeInterface|null $parent |
||
62 | */ |
||
63 | public function __construct($name, NodeInterface $parent = null) |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | public function getName() |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function setPath($path) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function getPath() |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function setParent(NodeInterface $parent) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getParent() |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function setAllowOverwrite($allowOverwrite) |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | public function setDefaultValue($value) |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function getDefaultValue() |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function setRequired($required) |
||
149 | |||
150 | /** |
||
151 | * {@inheritdoc} |
||
152 | */ |
||
153 | public function isRequired() |
||
157 | |||
158 | /** |
||
159 | * {@inheritdoc} |
||
160 | */ |
||
161 | public function hasDefaultValue() |
||
165 | |||
166 | /** |
||
167 | * {@inheritdoc} |
||
168 | */ |
||
169 | final public function normalize($value) |
||
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | final public function merge($left, $right) |
||
193 | |||
194 | /** |
||
195 | * Finalize and validate type and value. |
||
196 | * |
||
197 | * @param mixed $value |
||
198 | * |
||
199 | * @return mixed |
||
200 | */ |
||
201 | final public function finalize($value) |
||
207 | |||
208 | /** |
||
209 | * Validate type of a Node. |
||
210 | * |
||
211 | * @param mixed $value |
||
212 | * |
||
213 | * @throws InvalidTypeException |
||
214 | */ |
||
215 | abstract protected function validateType($value); |
||
216 | |||
217 | /** |
||
218 | * Normalize value. |
||
219 | * |
||
220 | * @param mixed $value |
||
221 | * |
||
222 | * @return mixed |
||
223 | */ |
||
224 | abstract protected function normalizeValue($value); |
||
225 | |||
226 | /** |
||
227 | * Merge between two elements. |
||
228 | * |
||
229 | * @param mixed $left |
||
230 | * @param mixed $right |
||
231 | * |
||
232 | * @return mixed |
||
233 | */ |
||
234 | abstract protected function mergeValues($left, $right); |
||
235 | |||
236 | /** |
||
237 | * Finalize and validate value. |
||
238 | * |
||
239 | * @param mixed $value |
||
240 | */ |
||
241 | abstract protected function finalizeValue($value); |
||
242 | } |
||
243 |