Skip to content

Collection

The Collection package provides the list and map primitives used across the rest of Raxos. It ships an ordered, chainable ArrayList with a full set of functional operations, a set of typed list variants that validate their items, string keyed Map dictionaries, and a small Paginated value object for API responses. Every type is iterable, countable and JSON serializable, so it drops straight into HTTP responses and ORM relations.

Highlights

Explore by category

  • Array lists: ArrayList and ReadonlyArrayList, construction, array access, iteration and the full set of chainable operations.
  • Typed lists: StringArrayList, IntArrayList and NumberArrayList and how item validation works.
  • Maps: Map, CacheMap and ReadonlyMap string keyed dictionaries.
  • Pagination: the Paginated value object and its JSON shape.

Quick example

php
<?php
declare(strict_types=1);

use Raxos\Collection\ArrayList;

$numbers = ArrayList::of([1, 2, 3, 4, 5]);

$result = $numbers
    ->filter(static fn(int $number): bool => $number % 2 === 1)
    ->map(static fn(int $number): int => $number * 10);

$result->toArray(); // [10, 30, 50]

Installation

Install the package with Composer and check the requirements on the installation page.

shell
composer require raxos/collection