beauty-framework/collection
最新稳定版本:1.0.1
Composer 安装命令:
composer require beauty-framework/collection
包简介
Beauty Collection
关键字:
README 文档
README
A powerful collection abstraction for the Beauty Framework.
Supports both eager and lazy data pipelines, multiple storage strategies, method chaining (map, filter, sortBy, paginate, etc.), strict interfaces, and full compatibility.
Features
Collection (eager)
- Fluent methods:
map,filter,where,sortBy,paginate,each,first,last,values
- Implements:
ArrayAccess,Countable,IteratorAggregate,JsonSerializable
- Smart
last()optimization (iterator or buffered strategy) - Storage strategies:
ArrayStorage(default)DsMapStorage(ifext-dsis available)
LazyCollection
- Based on
Generator - Fluent methods:
map,filter,chunk,flatMap,reduce,take,first,toArray
- Memory efficient for large or infinite datasets
Interfaces
CollectionInterfaceSupportsOperationsSupportsAccessorsLazyCollectionInterface
Installation
composer require beauty-framework/collection
Usage
Eager Collection
$collection = new Collection([ ['name' => 'Kirill'], ['name' => 'Hui'], ['name' => 'Zver'], ]); $filtered = $collection ->where('name', 'Kirill') ->map(fn($x) => strtoupper($x['name'])) ->toArray();
Lazy Collection
$collection = new LazyCollection(fn() => yield from range(1, 1_000_000)); $result = $collection ->filter(fn($x) => $x % 2 === 0) ->take(5) ->flatMap(fn($x) => [$x, $x * 10]) ->toArray();
Tests
vendor/bin/phpunit
Compatibility
- ArrayAccess
- Countable
- IteratorAggregate
- JsonSerializable
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-19