jakub-frajt/typed-list

The array data types that contains only specific type of values. Substitution of missing generic types in PHP.

0.2 2022-03-17 10:27 UTC

This package is auto-updated.

Last update: 2024-05-17 14:56:34 UTC


README

Build Status

Integer list

use Frajt\IntegerList;

// create IntegerList from array
$integerList = new IntegerList([1, 2, 30]);

// numeric string values are automatically casted to integer
$integerList = new IntegerList(['1', 2, 30]);

$integerList->getValues(); // get values as array [1, 2, 30]

// support \Iterator interface
foreach ($integerList as $intValue) {
    echo $intValue.PHP_EOL;
}