Skip to content

Instantly share code, notes, and snippets.

@juice49
Created August 14, 2018 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juice49/36c79961f17054d0ac86c03dee71c11e to your computer and use it in GitHub Desktop.
Save juice49/36c79961f17054d0ac86c03dee71c11e to your computer and use it in GitHub Desktop.
IterableUtils
<?php
abstract class IterableUtils
{
public static function reduce(Iterable $collection, Callable $accumulator, $result = null)
{
foreach ($collection as $item) {
$result = $accumulator($result, $item);
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment