1 | <?php |
||
16 | class EnvironmentNode |
||
17 | { |
||
18 | /** |
||
19 | * ROOT_KEY |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | public const ROOT_KEY = ''; |
||
24 | |||
25 | /** |
||
26 | * Key |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | private $key; |
||
31 | |||
32 | /** |
||
33 | * Value |
||
34 | * |
||
35 | * @var mixed |
||
36 | */ |
||
37 | private $value; |
||
38 | |||
39 | /** |
||
40 | * Children |
||
41 | * |
||
42 | * @var EnvironmentNode[] |
||
43 | */ |
||
44 | private $children; |
||
45 | |||
46 | /** |
||
47 | * Parent |
||
48 | * |
||
49 | * @var EnvironmentNode |
||
50 | */ |
||
51 | private $parent; |
||
52 | |||
53 | /** |
||
54 | * Create tree node |
||
55 | * |
||
56 | * @param string $key |
||
57 | * @param mixed $value |
||
58 | * @param EnvironmentNode[] $children |
||
59 | * @return void |
||
|
|||
60 | */ |
||
61 | public function __construct(string $key, $value = null, $children = []) |
||
74 | |||
75 | /** |
||
76 | * Add child node to node |
||
77 | * |
||
78 | * @param EnvironmentNode $child |
||
79 | * @return void |
||
80 | */ |
||
81 | public function addChild(EnvironmentNode $child) |
||
87 | |||
88 | /** |
||
89 | * Get entry |
||
90 | * |
||
91 | * @param string $key |
||
92 | * @return mixed |
||
93 | */ |
||
94 | public function __get($name) |
||
111 | |||
112 | /** |
||
113 | * Set value of node |
||
114 | * |
||
115 | * @param mixed $value |
||
116 | * @return void |
||
117 | */ |
||
118 | public function setValue($value) |
||
126 | |||
127 | /** |
||
128 | * Set parent of node |
||
129 | * |
||
130 | * @param EnvironmentNode $parent |
||
131 | * @return void |
||
132 | */ |
||
133 | public function setParent(EnvironmentNode $parent) |
||
137 | |||
138 | /** |
||
139 | * Transform node recursively to a Config object |
||
140 | * |
||
141 | * @return mixed |
||
142 | */ |
||
143 | public function toConfig() |
||
154 | |||
155 | /** |
||
156 | * Gets the fully qualified key of the node |
||
157 | * |
||
158 | * @return string |
||
159 | */ |
||
160 | public function getFullKey(): string |
||
171 | |||
172 | /** |
||
173 | * Ensures that a node has either a value or children, but not both |
||
174 | * |
||
175 | * @throws Exception |
||
176 | * @return void |
||
177 | */ |
||
178 | protected static function ensureValueOrChildren($value, array $children) |
||
184 | } |
||
185 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.