colindev/php-object-chain

v0.0.2 2015-07-13 03:09 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:03 UTC


README

php 对象/数组 索引链

安装

设置依赖包并更新

    composer require colin/object-chain
    composer update

测试

运行单元测试

    
    phpunit

示例

use Colin\ObjectChain;

$data = new ObjectChain(json_decode('{"key":"hello","vary":{"depth":{"key":"found"}}}'));

$data->{'key'}->value();// return 'hello'
$data['key']->value();// return 'hello'

$data['vary']['depth']['key']->value();// return 'found'
$data['vary']['depth']['depth']['key']->value();// return null