for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sergiors\Functional;
/**
* @author Sérgio Rafael Siqueira <[email protected]>
*
* @return mixed
*/
function each()
{
$args = func_get_args();
$each = function (\Closure $fn, $ls) {
if ($ls instanceof \Iterator) {
iterator_apply($ls, function () use ($fn, $ls) {
$args = [
$ls->current(),
$ls->key()
];
call_user_func_array($fn, $args);
return true;
});
return $ls;
}
array_walk($ls, $fn);
};
return call_user_func_array(curry($each), $args);