Download the PHP package takuya/php-genetator-array-access without Composer
On this page you can find all versions of the php package takuya/php-genetator-array-access. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download takuya/php-genetator-array-access
More information about takuya/php-genetator-array-access
Files in takuya/php-genetator-array-access
Package php-genetator-array-access
Short Description make yield into an Array / ArrayAccess.
License GPL-3.0-or-later
Informations about the package php-genetator-array-access
php / GeneratorArrayAccess
Make generator(yield) into ArrayAccess.
Example
Why use.
Generator can foreach itself. but, cannot access as Array. This characteristic is against developers's intention. Like this.
Generator cannot be a array.
CachingIterator is not enough
Using \CachingIterator
is a common way, but make a problem
\CachingIterator cannot be a array.
This behaviour is very confusing.
With FullCache option, cached at initializing.
If generator is API call, It can spend a lot of time, caching time inevitable.
CachingIterator is useless. Everyone uses iterator_to_array()
instead.
iterator_to_array()
function has same problem ( load all, mess up Generator concept, get data when using ).
Dynamically get, make Unnecessary api call avoidable.
To solve that problem ,GeneratorArrayAccess cache dynamically.
Cache is able to reuse.
When use this.
Reduce WebAPI Call. without re-arrange code.
Current exists code.
Use Generator.
Use GeneratorArrayAccess
This class supports to make use of Generator(yield), Less code changed.
Limitations.
Infinite generator will be no response.
Installation
from github
from composer