1 | <?php |
||
28 | class Tree extends ObjectAbstract |
||
29 | { |
||
30 | /** |
||
31 | * node splitter |
||
32 | * |
||
33 | * @var string |
||
34 | * @access protected |
||
35 | */ |
||
36 | protected $splitter = '.'; |
||
37 | |||
38 | /** |
||
39 | * the result tree |
||
40 | * |
||
41 | * @var array |
||
42 | * @access protected |
||
43 | */ |
||
44 | protected $tree; |
||
45 | |||
46 | /** |
||
47 | * construct a tree |
||
48 | * |
||
49 | * @param array $data |
||
50 | * @param string $splitter |
||
51 | * @access public |
||
52 | * @api |
||
53 | */ |
||
54 | public function __construct(array $data, /*# string */ $splitter = '.') |
||
59 | |||
60 | /** |
||
61 | * return the whole tree |
||
62 | * |
||
63 | * @return array |
||
64 | * @access public |
||
65 | * @api |
||
66 | */ |
||
67 | public function getTree()/*# : array */ |
||
71 | |||
72 | /** |
||
73 | * Get one node, NULL if not found |
||
74 | * |
||
75 | * @param string $nodeName |
||
76 | * @return mixed |
||
77 | * @access public |
||
78 | * @api |
||
79 | */ |
||
80 | public function &getNode(/*# string */ $nodeName) |
||
89 | |||
90 | /** |
||
91 | * Delete one node if exists |
||
92 | * |
||
93 | * @param string $nodeName |
||
94 | * @return $this |
||
95 | * @access public |
||
96 | * @since 2.0.5 |
||
97 | * @api |
||
98 | */ |
||
99 | public function deleteNode(/*# string */ $nodeName) |
||
114 | |||
115 | /** |
||
116 | * Fix array, convert flat name to tree node name |
||
117 | * |
||
118 | * @param array $data |
||
119 | * @return array |
||
120 | * @access protected |
||
121 | */ |
||
122 | protected function fixTree(array $data)/*# : array */ |
||
131 | |||
132 | /** |
||
133 | * Search a node in the $data |
||
134 | * |
||
135 | * @param string $key |
||
136 | * @param array &$data |
||
137 | * @param bool $create |
||
138 | * @access protected |
||
139 | */ |
||
140 | protected function &searchNode( |
||
159 | } |
||
160 |