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) |
||
104 | |||
105 | /** |
||
106 | * {@inheritDoc} |
||
107 | */ |
||
108 | public function deleteNode(/*# string */ $nodeName) |
||
123 | |||
124 | /** |
||
125 | * {@inheritDoc} |
||
126 | */ |
||
127 | public function getDelimiter()/*# : string */ |
||
131 | |||
132 | /** |
||
133 | * Fix array, convert flat name to tree node name |
||
134 | * |
||
135 | * @param array $data |
||
136 | * @return array |
||
137 | * @access protected |
||
138 | */ |
||
139 | protected function fixTree(array $data)/*# : array */ |
||
148 | |||
149 | /** |
||
150 | * Search a node in the $data |
||
151 | * |
||
152 | * @param string $key |
||
153 | * @param array &$data |
||
154 | * @param bool $create |
||
155 | * @access protected |
||
156 | */ |
||
157 | protected function &searchNode( |
||
176 | } |
||
177 |