1 | <?php |
||
30 | class Tree extends ObjectAbstract implements TreeInterface |
||
31 | { |
||
32 | /** |
||
33 | * node splitter |
||
34 | * |
||
35 | * @var string |
||
36 | * @access protected |
||
37 | */ |
||
38 | protected $splitter = '.'; |
||
39 | |||
40 | /** |
||
41 | * the result tree |
||
42 | * |
||
43 | * @var array |
||
44 | * @access protected |
||
45 | */ |
||
46 | protected $tree; |
||
47 | |||
48 | /** |
||
49 | * construct a tree |
||
50 | * |
||
51 | * @param array $data |
||
52 | * @param string $splitter |
||
53 | * @access public |
||
54 | * @api |
||
55 | */ |
||
56 | public function __construct(array $data = [], /*# string */ $splitter = '.') |
||
61 | |||
62 | /** |
||
63 | * {@inheritDoc} |
||
64 | */ |
||
65 | public function getTree()/*# : array */ |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | public function &getNode(/*# string */ $nodeName) |
||
82 | |||
83 | /** |
||
84 | * {@inheritDoc} |
||
85 | */ |
||
86 | public function hasNode(/*# string */ $nodeName)/*# : bool */ |
||
94 | |||
95 | /** |
||
96 | * {@inheritDoc} |
||
97 | */ |
||
98 | public function addNode(/*# string */ $nodeName, $data) |
||
117 | |||
118 | /** |
||
119 | * {@inheritDoc} |
||
120 | */ |
||
121 | public function deleteNode(/*# string */ $nodeName) |
||
136 | |||
137 | /** |
||
138 | * {@inheritDoc} |
||
139 | */ |
||
140 | public function getDelimiter()/*# : string */ |
||
144 | |||
145 | /** |
||
146 | * Fix array, convert flat name to tree node name |
||
147 | * |
||
148 | * @param array $data |
||
149 | * @return array |
||
150 | * @access protected |
||
151 | */ |
||
152 | protected function fixTree(array $data)/*# : array */ |
||
165 | |||
166 | /** |
||
167 | * Search a node in the $data |
||
168 | * |
||
169 | * @param string $path |
||
170 | * @param array &$data |
||
171 | * @param bool $create |
||
172 | * @return mixed null for not found |
||
173 | * @access protected |
||
174 | * @since 2.0.6 bug fix |
||
175 | */ |
||
176 | protected function &searchNode( |
||
190 | |||
191 | /** |
||
192 | * get or create the next/child node, return NULL if not found |
||
193 | * |
||
194 | * @param string $key |
||
195 | * @param mixed $data |
||
196 | * @param bool $create create the node if not exist |
||
197 | * @return mixed |
||
198 | * @access protected |
||
199 | */ |
||
200 | protected function &childNode( |
||
216 | } |
||
217 |