bcismariu / commons-descendable
该包最新版本(v0.1)没有可用的许可信息。
一个属性访问辅助工具,能够使用点表示法访问数组和对象的组合
v0.1
2017-07-21 13:27 UTC
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is auto-updated.
Last update: 2024-09-13 06:00:19 UTC
README
一个通用的点表示法访问器,能够处理数组和对象的组合
安装
composer require bcismariu/commons-descendable:^0.1
使用
<?php use Bcismariu\Commons\Descendable\Descendable; $array = [ 'eyes' => 'blue', 'age' => '27', 'parents' => [ 'mother' => 'Jane', 'father' => 'Jack' ] ]; $descendable = new Descendable($array); $descendable->get('parents.father', 'John'); // returns 'Jack' $descendable->get('sister', 'Kate'); // returns 'Kate'
测试
php vendor/bin/phpunit