colindev / php-object-chain
物件索引鍊
v0.0.2
2015-07-13 03:09 UTC
Requires
- php: >= 5.3
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-11-09 20:12:19 UTC
README
php 物件/陣列 索引鍊
install
設定依賴套件,並更新
composer require colin/object-chain composer update
test
執行單元測試
phpunit
sample
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