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

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

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

fiv/collection

最新稳定版本:0.0.1

Composer 安装命令:

composer require fiv/collection

包简介

Easy way to iterate over your data

关键字:

README 文档

README

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Manipulate array of items in OOP style. ObjectCollection - contain/manipulate objects only with specific class TypedCollection - contain/manipulate items with defined validation rule BaseCollection - contain/manipulate any items

ObjectCollection it the most useful collection. You can specify class of object and add only this objects. All validations perform ObjectCollection Other data types restricted. This class guarantee strict type data.

Install

Via Composer

$ composer require fiv/collection

Base collection usage

$collection = new \Fiv\Collection\BaseCollection();
$collection[] = 1;
$collection[] = 2;
echo $skeleton->getFirst()

Example : ObjectCollection

In java there ara features like ArrayList<UserModel> in php you can extend ObjectCollection to UserModelCollection and define class name.

class UserModel {
  public function getName(){
  
  }
}

class UsersCollection extend  ObjectCollection {
  public function objectsClassName(){
    return 'UserModel';
  }
}

# .... 
$users = new UserCollection();

foreach($users as $user){
  # at this point you can drop out all you validations
  # ObjectCollection guarantee that all items are UserModel
  $user->getName(); 
}


$users->append(123); // Fail. 123 is not instance of UserModel  

Testing

$ ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-07