Created
August 14, 2018 13:24
-
-
Save juice49/36c79961f17054d0ac86c03dee71c11e to your computer and use it in GitHub Desktop.
IterableUtils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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