Skip to content

Instantly share code, notes, and snippets.

View funkatron82's full-sized avatar

Manny Fleurmond funkatron82

View GitHub Profile
@funkatron82
funkatron82 / LazyGeneratorCollection.php
Created September 25, 2021 02:01 — forked from andrerom/LazyGeneratorCollection.php
Lazy Collection using Generator in PHP (Example, script in bottom of file to test it)
<?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).
*/