easyframework/collections

此包已被弃用且不再维护。未建议替代包。

PHP的集合抽象库

v7.0.0 2016-12-13 14:14 UTC

README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Downloads

PHP的集合抽象库

集合库是许多现代语言中最有用的事物之一,但不知何故,PHP没有内置的集合层。

因此我们创建了Collections,这是一个集成了.NET和Java集合模式的精华,并与PHP数组功能统一的卓越库。

看看我们到底在说什么吧!!

安装

composer require easyframework/collections

使用

集合类

集合代表.NET语言中的List或简而言之是PHP中的非关联数组

  $person1 = new \stdClass();
  $person1->name = 'John';
  $person1->age = 25;
  
  $person2 = new \stdClass();
  $person2->name = 'Maria';
  $person2->age = 30;
  
  $person3 = new \stdClass();
  $person3->name = 'Anderson';
  $person3->age = 15;
     
  $collection = new Collections\Vector();
  $collection->add($person1);
  $collection->add($person2);
  $collection->add($person3);
  
  $collection->filter(function($person){
        return $person->age > 18;
  })->each(function($item){
        echo $item->name; //John and Maria
  });

贡献

请参阅CONTRIBUTING以获取详细信息。

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件

文档

更多信息可以在https://italolelis.gitbooks.io/collections上的在线文档中找到。