Search by

raxos / collection

basmilius

Collection primitives.

3.2.0 2026-10-02 17:09 UTC

This package is auto-updated.

Last update: 2026-10-03 12:06:06 UTC


README

Bas Milius

Raxos Collection

Ordered lists, keyed maps and pagination objects with iterable, array-access and JSON support.

Documentation | Packagist | Raxos

  • Mutable and read-only lists and maps.
  • Validated string, integer and number lists.
  • Filtering, projections, grouping, sorting, slicing and reductions.
  • Paginated results with item and page metadata.

Installation

Requires PHP 8.5 or later. Composer checks the remaining package and extension dependencies declared in composer.json.

composer require "raxos/collection:^3.2"

Usage

<?php
declare(strict_types=1);

use Raxos\Collection\ArrayList;

require __DIR__ . '/vendor/autoload.php';

$products = ArrayList::of([
    ['name' => 'Keyboard', 'stock' => 5],
    ['name' => 'Mouse', 'stock' => 0],
]);

$names = $products
    ->filter(static fn(array $product): bool => $product['stock'] > 0)
    ->map(static fn(array $product): string => $product['name']);

echo json_encode($names);

Transformations leave the original collection intact. In 3.2, projections such as map(), column() and keys() return generic list interfaces rather than the original typed list. Read-only inputs keep read-only results.

Documentation

Testing

Run this library's Pest suite from the Raxos workspace:

git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=collection

See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.

License

MIT. Copyright (c) 2017 - present Bas Milius.