lithium\data\Collection::reduce PHP Method

reduce() public method

Overridden to load any data that has not yet been loaded.
public reduce ( callback $filter, mixed $initial = false ) : mixed
$filter callback The filter to apply.
$initial mixed Initial value
return mixed A single reduced value
    public function reduce($filter, $initial = false)
    {
        if (!$this->closed()) {
            while ($this->next()) {
            }
        }
        return parent::reduce($filter, $initial);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Reduce, or fold, a collection down to a single value
  *
  * Overriden to load any data that has not yet been loaded.
  *
  * @param callback $filter The filter to apply.
  * @param mixed $initial Initial value
  * @return mixed A single reduced value
  */
 public function reduce($filter, $initial = false)
 {
     $this->offsetGet(null);
     return parent::reduce($filter, $initial);
 }