Skip to content

Instantly share code, notes, and snippets.

Avatar

Manny Fleurmond funkatron82

View GitHub Profile
@funkatron82
funkatron82 / LazyGeneratorCollection.php
Created Sep 25, 2021 — forked from andrerom/LazyGeneratorCollection.php
Lazy Collection using Generator in PHP (Example, script in bottom of file to test it)
View LazyGeneratorCollection.php
<?php
/**
* Class GeneratorCollection, allows for lazy loaded arrays using Generators withouth it's limitations.
*
* This collection class takes Generator as argument, and allows user to threat it like any kind of array. It will take
* care about storing the values returned from generator so user can iterate over it several times.
*
* NOTE: In current form only works with generators that uses integers as keys (lists).
*/