PHPackages                             hguenot/data-tree - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hguenot/data-tree

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hguenot/data-tree
=================

v1.1.2(7y ago)0421AGPL-3.0PHPPHP &gt;=7.1

Since Oct 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/hguenot/data-tree)[ Packagist](https://packagist.org/packages/hguenot/data-tree)[ RSS](/packages/hguenot-data-tree/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (1)Versions (5)Used By (1)

PHP Tree data structure
=======================

[](#php-tree-data-structure)

This library provides a tree structure via discrete Traits.

It is intended to be used by other libraries.

(Fork of  - PHP 7 support and releases)

Continuous integration
----------------------

[](#continuous-integration)

[![Build Status](https://camo.githubusercontent.com/f7af8a59343baa5280b346cb2c65a52dd189b4e44739a93fe8b8f022ac86d42b/68747470733a2f2f7472617669732d63692e6f72672f686775656e6f742f646174612d747265652e737667)](https://travis-ci.org/hguenot/data-tree)[![Code coverage](https://camo.githubusercontent.com/049a3ad943b52d7b0369e01f13e2a7be662fe7fc3cd119bc19c9822d6ef523a7/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f686775656e6f742f646174612d747265652e737667)](https://codecov.io/github/hguenot/data-tree)[![GitHub version](https://camo.githubusercontent.com/3e84b28003c11996d61ddb130d59dce1e396f4aec5a54d521a144a33d0d28510/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f686775656e6f742f646174612d747265652e737667)](https://github.com/hguenot/data-tree/releases)[![Packagist version](https://camo.githubusercontent.com/76162414d4727656c5e2be57c53ff398812fb4bdc444c2c56a92d837c97a81a2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686775656e6f742f646174612d747265652e737667)](https://packagist.org/packages/hguenot/data-tree)

### ChildrenTrait

[](#childrentrait)

Add, acces and remove child nodes using this trait.

### LookupTrait

[](#lookuptrait)

Optional methods to inspect the tree.

### AttributesTrait

[](#attributestrait)

Optional attributes per node.

### ToStringTrait

[](#tostringtrait)

Optional `__toString()` implementation that outputs the nodes class name and its attributes.

### NodeTrait

[](#nodetrait)

Combines all of the above traits

### Protected Access

[](#protected-access)

The sub-namespace `ProtectedAccess` contains versions of `ChildrenTrait`, `LookupTrait` and `AttributesTrait` where all methods are protected. This allows fine control over the public API when using the Traits in a library.

Example
-------

[](#example)

```
// Create a simple tree.
$root = new Node();
$root->setAttribute('name', 'root');

$a = new Node();
$a->setAttribute('name', 'a');
$root->addChild($a);

$b = new Node();
$b->setAttribute('name', 'b');
$root->addChild($b);

$c = new Node();
$c->setAttribute('name', 'c');
$root->addChild($c);

// Find a descendant with the name=b
$bAgain = $root->descendant(function ($node) {
	return $node->getAttribute('name') === 'b';
});

// Get the root node of any node
$rootAgain = $bAgain->findRootNode();

// Remove a node
$bAgain->remove();
$root->removeChild($a);
$root->removeChildAt(0);
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

2808d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f980dc7f653be656d2725f6457567a666e792e4173ba57536de674b6f3e291e?d=identicon)[hguenot](/maintainers/hguenot)

---

Top Contributors

[![hguenot](https://avatars.githubusercontent.com/u/2578010?v=4)](https://github.com/hguenot "hguenot (14 commits)")[![timostamm](https://avatars.githubusercontent.com/u/4289451?v=4)](https://github.com/timostamm "timostamm (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hguenot-data-tree/health.svg)

```
[![Health](https://phpackages.com/badges/hguenot-data-tree/health.svg)](https://phpackages.com/packages/hguenot-data-tree)
```

###  Alternatives

[aimeos/macro

Customize classes using closures

2.4k140.2k7](/packages/aimeos-macro)[xefi/faker-php-locales-fr-fr

Faker extension to include fr\_FR locale

2313.1k](/packages/xefi-faker-php-locales-fr-fr)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
