hypnotox/pack

PHP package offering immutable collections.

v0.3.2 2022-06-24 19:16 UTC

This package is auto-updated.

Last update: 2024-11-06 16:19:59 UTC


README

CI Status Code Coverage Packagist Version Packagist PHP Version Support GitHub

A collection library offering immutable collections.

Collections implement \HypnoTox\Pack\CollectionInterface which extends \IteratorAggregate, \ArrayAccess and \Countable and adds other chainable methods.

This is just a personal project, but follows semantic versioning and will be stable once reaching its first major release.

PRs are welcome.

Installation

Simply require it using composer: composer require hypnotox/pack

Features

Currently, the only implemented collection is \HypnoTox\Pack\ArrayCollection.

Everything is type-hinted with generic template expressions to allow for full typing using static analysis.

Usage

ArrayCollection

$collection = new \HypnoTox\Pack\ArrayCollection([1, 2, 3]);

$collection->first()->key; // 0
$collection->first()->value; // 1
$collection->set(0, 100)->first()->value; // 100

Collection Methods

// TODO