Skip to content

Instantly share code, notes, and snippets.

View mohamed-samir907's full-sized avatar
🏠
Working from home

Mohamed Samir mohamed-samir907

🏠
Working from home
View GitHub Profile
@andrerom
andrerom / LazyGeneratorCollection.php
Last active November 10, 2023 14:52
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).
*/