dschoenbauer/dot-notation
最新稳定版本:1.2.1
Composer 安装命令:
composer require dschoenbauer/dot-notation
包简介
Given a complicated data structure, this library allows easy and safe access to data via dot notation. This library is a compilation of other Dot Notation libraries, taking the best feature from each.
关键字:
README 文档
README
Purpose
Simplifies access to large array structures
Installation
composer require dschoenbauer/dot-notation
Testing
./vendor/bin/phpunit tests
Example
use DSchoenbauer\DotNotation\ArrayDotNotation;
$mongoConnection = [
'mongo' => [
'default' => [ 'user' => 'username', 'password' => 's3cr3t' ]
]
];
$config = new ArrayDotNotation($mongoConnection);
--- or ---
$config = ArrayDotNotation::with($mongoConnection);
GET
// Get plain value
$user = $config->get('mongo.default.user');
/*
$user = 'username';
*/
// Get array value
$mongoDefault = $config->get('mongo.default');
/*
$mongoDefault = ['user' => 'username', 'password' => 's3cr3t'];
*/
SET
$configDump = $config->set('mongo.numbers', [2, 3, 5, 7, 11])->getData();
/*
$configDump = [
'mongo' => [
'default' => [ 'user' => 'username', 'password' => 's3cr3t' ],
'numbers' => [2, 3, 5, 7, 11]
],
'title' => 'Dot Notation'
];
*/
MERGE
$configDump = $config->merge('mongo.default', ['user' => 'otherUser','active' => true])->getData();
/*
$configDump = [
'mongo' => [
'default' => [ 'user' => 'otherUser', 'password' => 's3cr3t','active' => true ]
],
'title' => 'Dot Notation'
];
*/
REMOVE
$configDump = $config->remove('mongo.default.user')->getData();
/*
$configDump = [
'mongo' => [
'default' => [ 'password' => 's3cr3t' ]
],
'title' => 'Dot Notation'
];
*/
NOTATION TYPE
// Tired of dots? Change it.
$user = $config->setNotationType(',')->get('mongo,default,user');
/*
$user = 'username';
*/
WITH
//Functional fluent fun
$user = ArrayDotNotation::with($mongoConnection)->get('mongo.default.user');
/*
$user = 'username';
*/
HAS
// Validates that the dot notation path is present in the data.
$isPresent = $config->has('mongo,default,user');
/*
$isPresent = true;
*/
统计信息
- 总下载量: 988
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-11-26