scienide/tuple

A fixed-length immutable list data structure for PHP.

dev-master 2022-04-18 00:09 UTC

This package is auto-updated.

Last update: 2024-12-18 05:46:12 UTC


README

An immutable list with a fixed-length whose elements are indexed by their offset in the list.

Installation

Install into your project using Composer:

$ composer require scienide/tuple

Requirements

  • PHP 7.4 or above

Example

use Tuple;

$tuple = new Tuple(5.0, 3, 'foo');

[$first, $second, $third] = $tuple->list();

foreach ($tuple as $offset => $value) {
    //
}

echo count($tuple);

echo $tuple[2];
3

foo

Testing

To run the unit tests:

$ composer test

Static Analysis

To run static code analysis:

$ composer analyze