承接 ama-team/tree-access 相关项目开发

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

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

ama-team/tree-access

Composer 安装命令:

composer require ama-team/tree-access

包简介

Symfony-Property-Access-like tree manipulation helper

README 文档

README

Packagist CircleCI/master Coveralls/master Scrutinizer/master

This tiny project allows to read, enumerate and write properties / elements in a nested tree consisting of arrays and objects.

It is very close to symfony/property-access, but have two differences:

  • This library treats array elements and object properties the same way, providing a unified tree access. This may be both desirable and not, depending on real application, so property-access may be more useful for you.
  • This library allows to enumerate properties of a specific node.

Installation

composer require ama-team/tree-access

Usage

<?php

$object = new stdClass();
$object->values = ['apples' => 'green'];
$root = [$object];

$accessor = AmaTeam\TreeAccess\TreeAccess::createAccessor();

// 'green'
$color = $accessor->read($root, '0.values.apples');
// List of AmaTeam\TreeAccess\API\NodeInterface
$values = $accessor->enumerate($root, '0.values');
// NodeInterface that got updated
$accessor->write($root, '0.values.melon', 'yellow');
// false
$accessor->exists($root, '0.values.watermelon');

Setters / getters support is already bundled in, and accessing missing nodes will throw an exception (except when setting leaf of existing node).

ActiveNode

Accessor already provides additional method that allows alternative manipulation interface:

<?php

$object = new stdClass();
$object->values = ['apples' => 'green'];
$root = [$object];

$accessor = AmaTeam\TreeAccess\TreeAccess::createAccessor();

$activeNode = $accessor->wrap($object);
foreach ($activeNode->enumerate() as $child) {
    $child->getChild('values')->setChild('lemon', 'yellow');
    $child->setChild('processed', true);
}

Performance

As of 0.1.x, possible performance optimizations are sacrificed for ease of use. This library doesn't promote performance (at least for now) at all.

Contributing

Feel free to send PR to dev branch

Dev branch state

CircleCI/dev Coveralls/dev Scrutinizer/dev

Licensing

MIT License / AMA Team, 2018

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固