aeviiq/tree-node 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aeviiq/tree-node

最新稳定版本:v1.0

Composer 安装命令:

composer require aeviiq/tree-node

包简介

A library that provides the tree node functionality.

README 文档

README

A library that provides the tree node functionality.

Installation

composer require aeviiq/tree-node

Declaration

// ...
use Aeviiq\TreeNode\TreeNodeTrait;

final class Foo implements FooBarInterface
{
    use TreeNodeTrait;
    
    // ...
}

Will provide the Foo class with the functionality to support the tree node structure:

Image description

Usage

$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

Notable mentions

*There is no 'protection' against the case where a node can become it's own grand parent|child. When this is the case, it could cause infinite recursion errors in methods such as getRoot(). Making a node its own grand parent or grand child is just a plain wrong usage of this tree node component, therefor it is not worth the performance decrease to recursively validate against.

统计信息

  • 总下载量: 16.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-22