Wallogit.com
2017 © Pedro Peláez
A PHP tree data structure. Allows for referencing nodes by unique key.
This library aims to provide an object oriented way to create a tree data structure. Each node has a user defined unique id by which it is referenced., (*2)
Run composer require tebru/tree:1.0.*, (*3)
Creating a tree is really easy. All you have to do is instantiate it:
$tree = new Tree();
This will create the tree object and create a root node to act upon., (*4)
There are many options for creating a node., (*5)
$tree->createNode('node');
$tree->createNode('node2', 'node');
$tree->createNode('a_category', null, 'Foo Category');
$tree->createNode('node', null, null, 10);
Just pass in the node id:
$tree->removeNode('node');
This will remove that node and all of its children from the tree., (*6)
This is also easy. Just specify the node id of the node you wish to move and the node id of its new parent:
$tree->moveNode('node', 'newNodeId');, (*7)
Run tests by running phpunit from the root directory., (*8)
This project uses semantic versioning [http://semver.org] for versioning., (*9)