graze/array-filter
Composer 安装命令:
composer require graze/array-filter
包简介
File manipulation
关键字:
README 文档
README
Array Filtering
Install
Via Composer
$ composer require graze/array-filter
Usage
Filter Factory
There is a factory which takes in a set of string definitions and creates filters based on each one
$config = [ 'name ~' => '/test.*/i', 'ctime >' => '{date:yesterday:U}', 'status in' => [1, 2], ]; $input = [[ 'name' => 'test1234', 'ctime' => 142353782, 'status' => 2, ]]; $factory = new FilterFactory(new ValueFactory()); $filter = $factory->createFilters($config); $filtered = array_filter($input, $filter);
Respect/Validator and other callable functions Compatible
$filter = new AllOfFilter();
$filter->addFilter(new ClosureFilter('name', v::regex('/test.*/i')))
->addFilter(v::key('ctime', v::date()->between('yesterday', 'today'))
->addFilter(function (array $data) {
return isset($data['status']) && in_array($data['status'], [1, 2]);
});
$filtered = array_filter($input, $filter);
Testing
$ make
$ make test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email security@graze.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 438
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-19