2017 © Pedro Peláez
 

library tree

A PHP tree data structure. Allows for referencing nodes by unique key.

image

tebru/tree

A PHP tree data structure. Allows for referencing nodes by unique key.

  • Monday, September 29, 2014
  • by natebrunette
  • Repository
  • 1 Watchers
  • 2 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Tree Data Structure

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)

Installing the project

Run composer require tebru/tree:1.0.*, (*3)

Creating the tree

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)

Create a node

There are many options for creating a node., (*5)

  • Creating a node appended to the root node can be done like $tree->createNode('node');
  • If you want to add this node to a different node you can do so like $tree->createNode('node2', 'node');
  • You have the option to add arbitrary data to a node by doing $tree->createNode('a_category', null, 'Foo Category');
  • Finally, you can specify the position your node should appear in the parent's children like $tree->createNode('node', null, null, 10);
    • You may not specify an position for an index that does not already exist
    • Setting the position will bump all existing nodes back 1 space starting with the node at the specified index

Remove a node

Just pass in the node id: $tree->removeNode('node'); This will remove that node and all of its children from the tree., (*6)

Move a node

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)

Testing

Run tests by running phpunit from the root directory., (*8)

Versioning

This project uses semantic versioning [http://semver.org] for versioning., (*9)

The Versions

29/09 2014

dev-master

9999999-dev

A PHP tree data structure. Allows for referencing nodes by unique key.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Nate Brunette

22/05 2014

v0.1.0

0.1.0.0

A PHP tree data structure. Allows for referencing nodes by unique key.

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

by Nate Brunette