rde/data-chain

结构化数据

v0.1 2015-07-09 08:26 UTC

This package is not auto-updated.

Last update: 2024-09-18 09:15:51 UTC


README

目的

使数据结构化且易于使用。

用法

首先使用您的数据作为参数实例化DataChain。您的数据可以是数组、对象、字符串等。

use Rde\DataChain;

$yourData = array(
    'a' => 'test',
    'b' => array(
        'c' => 'end'
    )
);

$dataChain = new DataChain($yourData);

// get dataChain object
$dataChain->a;

// get value of a, this will get 'test'
$dataChain->a->value();

// get multi layer value, this will get 'end'
$dataChain->b->c->value();

// When the key is not set, it will return dataChain object
$dataChain->a->d;

// When get the value of non-existent key will return null
$dataChain->a->d->value();