Search by

xenira / iter-tools

Xenira

Library to make iterator pattern less cumbersome in php

Package info

github.com/Xenira/php-iter-tools

pkg:composer/xenira/iter-tools

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 3

Open Issues: 8

v0.1.0 2023-09-09 03:51 UTC

This package is auto-updated.

Last update: 2026-09-07 22:38:04 UTC


README

Table of Contents

Simple PHP library for making working with iterators more fun.

Heavily inspired by rust’s iterators.

Currently not all methods are implemented, but the most important ones are. Use with caution.

1. Usage

$iterator = new ArrayIterator([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
$iterator = $iterator
    ->filter(fn ($value) => $value % 2 === 0)
    ->map(fn ($value) => $value * 2)
    ->take(4);

assert($iterator->collect() === [4, 8, 12, 16]);