PHP code example of aeviiq / tree-node
1. Go to this page and download the library: Download aeviiq/tree-node library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aeviiq / tree-node example snippets
// ...
use Aeviiq\TreeNode\TreeNodeTrait;
final class Foo implements FooBarInterface
{
use TreeNodeTrait;
// ...
}
$foo = new Foo();
$foo2 = new Foo();
$foo->addChild($foo2);
$foo->isRoot(); // true
$foo2->isRoot(); // false
$foo->isLeaf(); // false
$foo2->isLeaf(); // true
$foo2->getRoot() === $foo; // true