1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | /** |
6: | * This file is part of the Nexus framework. |
7: | * |
8: | * (c) John Paul E. Balandan, CPA <paulbalandan@gmail.com> |
9: | * |
10: | * For the full copyright and license information, please view |
11: | * the LICENSE file that was distributed with this source code. |
12: | */ |
13: | |
14: | namespace Nexus\Collection\Operation; |
15: | |
16: | /** |
17: | * @template TKey |
18: | * @template T |
19: | */ |
20: | interface Reduce |
21: | { |
22: | /** |
23: | * Reduce a collection using a `$predicate`. |
24: | * |
25: | * The reduction function is passed an accumulator value and the current |
26: | * iterator value and returns a new accumulator. The accumulator is |
27: | * initialised to `$initial`. |
28: | * |
29: | * @template TAcc |
30: | * |
31: | * @param (\Closure(TAcc, T, TKey): TAcc) $predicate |
32: | * @param TAcc $initial |
33: | * |
34: | * @return TAcc |
35: | */ |
36: | public function reduce(\Closure $predicate, mixed $initial = null): mixed; |
37: | } |
38: |