lithium\util\Collection::reduce()

public method

Reduce, or fold, a collection down to a single value

Parameters

  • callable $reducer

    The reduce function, i.e. function($carry, $item) { return ... }

  • mixed $initial

    Initial value passed to the reduce function as $carry, defaults to false.

Returns

mixed

A single reduced value.

Source

	public function reduce($reducer, $initial = false) {
		return array_reduce($this->_data, $reducer, $initial);
	}