-
-
Notifications
You must be signed in to change notification settings - Fork 0
Quick start
github-actions[bot] edited this page Jul 16, 2026
·
1 revision
composer require cloudcastle/collection<?php
declare(strict_types=1);
use CloudCastle\Collection\Collection;
$orders = Collection::make([
['id' => 1, 'customer' => 'alice', 'status' => 'paid', 'total' => 150],
['id' => 2, 'customer' => 'bob', 'status' => 'pending', 'total' => 70],
['id' => 3, 'customer' => 'alice', 'status' => 'paid', 'total' => 220],
]);
// Фильтр → группировка → агрегат → сортировка
$report = $orders
->where('status', 'paid')
->groupBy('customer')
->map(static fn ($group) => $group->sum('total'))
->sortDesc()
->all(); // ['alice' => 370]
// Статистика по полю
$orders->sum('total'); // 440
$orders->pluck('total')->median(); // 150
// Безопасный JSON-цикл
$restored = Collection::fromJson($orders->toJson());Collection::make([0, '1', null])->contains('admin'); // false (loose дал бы true)
Collection::make([1, '1', true])->unique()->count(); // 3 — типы не схлопываются
Collection::make(['1', '2'])->map('intval'); // [1, 2] — ключ не попал в базу счисления- Возможности — все ~85 методов по группам
- Сравнение — фичи и производительность против 4 аналогов
- Архитектура
- FAQ
CloudCastle Collection · · PHP 8.1+
GitHub · Packagist · Releases · Discussions
Email · Telegram · VK · Сетка · 💜 Поддержать проект
Исходники Wiki — каталог wiki/ в репозитории (синхронизация через GitHub Actions)