/
node.php
58 lines (44 loc) · 954 Bytes
/
node.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Base\Config;
class Node implements \ArrayAccess {
protected $_data;
public function __construct($data) {
$this->_data = $data;
}
public function __get($name) {
return $this->get($name);
}
public function get($name) {
$val = isset($this->_data[$name]) ? $this->_data[$name] : null;
if ($val == null) return null;
if (is_array($val)) {
if (isset($val[0])) {
return $val;
} else {
return new Node($val);
}
}
return $val;
}
public function has($name) {
return isset($this->_data[$name]);
}
public function __isset($name) {
return $this->has($name);
}
public function getData() {
return $this->_data;
}
public function offsetExists($name) {
return $this->has($name);
}
public function offsetGet($name) {
return $this->get($name);
}
public function offsetSet($name,$value) {
return false;
}
public function offsetUnset($name) {
return false;
}
}