承接 small/collection 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

small/collection

最新稳定版本:3.2.2

Composer 安装命令:

composer require small/collection

包简介

Provide PHP collection classes, with a selector to make complex queries on collections.

README 文档

README


            



Provide PHP collection classes, with a selector to make complex queries on collections.

Beware : there is a break in compatibilty with version 1.x

Be careful to set your all packages composer.json to avoid breaking your code

Collection

Collections are classes that you can use as array.

Use it as array

The Small\Collection\Collection class is the base collection class.

You can create an empty collection :

$collection = new \Small\Collection\Collection\Collection();

Or initialize it with an array :

$collection = new \Small\Collection\Collection\Collection([1, 2, 3, 4]);

The collection has the behaviour of an array but is also an object :

$collection = new \Small\Collection\Collection\Collection([1, 2, 3, 4]);
foreach ($collection as $value) {
    echo $value;
}

Use it as an object

You can set a value for a specific key :

$collection = new \Small\Collection\Collection\Collection();
$key = 101;
$value = 'test';
$collection->set($key, $value);

And use it :

echo $collection[$key];

Check you're collection items via attributes

You can easily create your own collection with items restrictions

use Small\Collection\Collection\Attribute\CheckItemClass;

#[(CheckItemClass(CustomerEntity::class))]
class CustomerEntityCollection 
{}

or

use Small\Collection\Collection\Attribute\CheckItemInterface;

#[CheckItemInterface(CustomerInterface::class)]
class multiCustomerTypeCollection
{}

Collection classes

Selector

You can select arrays like it was a database table.

See Small\Collection\Selector\CollectionSelector.

small-collection is a part of small-project
Copyright (c) 2023,2024 Sébastien Kus
under GNU GPL V3 Licence

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2023-03-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固