承接 mrsuh/tree-printer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mrsuh/tree-printer

最新稳定版本:1.0.0

Composer 安装命令:

composer require mrsuh/tree-printer

包简介

README 文档

README

Installation

composer require mrsuh/tree-printer

Usage

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Mrsuh\Tree\NodeInterface;
use Mrsuh\Tree\Printer;

class Node implements NodeInterface
{
    private string $name;
    private array  $children;

    public function __construct(string $name, array $children = [])
    {
        $this->name     = $name;
        $this->children = $children;
    }

    public function getChildren(): array
    {
        return $this->children;
    }

    public function __toString(): string
    {
        return $this->name;
    }
}

$tree = new Node('/etc', [
    new Node('adduser.conf'),
    new Node('apt', [
        new Node('apt.conf.d', [
            new Node('01autoremove'),
            new Node('70debconf')
        ]),
        new Node('auth.conf.d'),
        new Node('preferences.d'),
        new Node('trusted.gpg.d', [
            new Node('debian-archive-bullseye-automatic.gpg'),
            new Node('debian-archive-bullseye-security-automatic.gpg'),
            new Node('debian-archive-bullseye-stable.gpg'),
        ]),
    ]),
    new Node('bash.bashrc'),
    new Node('cron.d', [
        new Node('e2scrub_all'),
    ]),
    new Node('cron.daily', [
        new Node('apt-compat'),
        new Node('dpkg'),
    ])
]);

$printer = new Printer();
$printer->print($ast);
.
├── /etc
    ├── adduser.conf
    ├── apt
    │   ├── apt.conf.d
    │   │   ├── 01autoremove
    │   │   └── 70debconf
    │   ├── auth.conf.d
    │   ├── preferences.d
    │   └── trusted.gpg.d
    │       ├── debian-archive-bullseye-automatic.gpg
    │       ├── debian-archive-bullseye-security-automatic.gpg
    │       └── debian-archive-bullseye-stable.gpg
    ├── bash.bashrc
    ├── cron.d
    │   └── e2scrub_all
    └── cron.daily
        ├── apt-compat
        └── dpkg

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-13