roquie/collection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

roquie/collection

最新稳定版本:0.1.11

Composer 安装命令:

composer require roquie/collection

包简介

Simple PHP Collection based on Laravel 5 Collection

README 文档

README

DEPRECATED. Please, use original laravel collection. This package no longer maintained.

Simple PHP Collection based on Laravel 5 Collection.

Install

composer require roquie/collection

Usage (in progress ...)

Five minutes example:

$array = [
    'foo' => [
        'one',
        'two',
        'three',
        'bar' => [
            1, 2, 3
        ],
        'clean' => '',
        'test1' => 'val2qq',
        'test2' => 'val2ww'
    ]
];

$collection = Collection::make($array);
//1
foreach($collection as $collect) {
    echo $collect['undefined_index']; // null
}

//2 

$result = $collection->each(function($collect) {
    echo $collect['undefined_index']; // null
});

//3

$result = $collection->filter(function($collect) {
    return $collect->has('key'); 
});


//4. get items using "dot" notation
$collection->get('foo.0', <default>);
$collection->getArray('foo.0'); // return [] if empty
$collection->getInteger('foo.0'); // return 0 if empty
$collection->getBoolean('foo.0'); // return false if empty
$collection->getString('foo.0'); // return '' if empty


//5. remove item using "dot" notation
$collection->rm('foo.bar'); // delete an item


//6. has item using "dot" notation
$collection->rm('foo.bar'); // true (if not delete :) )
$collection->forgot('foo.bar'); //alias

//7. clean array

$collection->clean(); // key foo.clean deleted.
$collection->clean('val'); // keys foo.test1 and 2 will be removed

//8. set an item using "dot" notation

$collection->set('baz', ['key' => 'is awesome']);
$collection->put($key, $value); //alias

License

MIT

统计信息

  • 总下载量: 1.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-20