Reduces the collection to a single value, passing the result of each iteration into the subsequent iteration.
@param callable   $closure  Callback specification: `function ($carry, $value): mixed`
@param mixed|null $carry
@return mixed|null|void
338216
function reduce(callable $closure, $carry = null) {
        foreach($this->data as $val) {
            $carry = $closure($carry, $val);
        }
        
        return $carry;
    }
819166
public function reduce($callable)
	{
		$ret = true;
		$carry = null;
		for( $this->rewind(); $this->valid(); $this->next() )
		{
			$model = $this->current();
			if( $carry !== null && !$callable($carry,$model) )
			{
				$ret = false;
				break;
			}
			$carry = $model;
		}
		return $ret;
	}
1084637
public function each(\Closure $closure): self
    {
        // init
        $array = [];

        foreach ($this->getGenerator() as $key => $value) {
            $array[$key] = $closure($value, $key);
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
652767
public function apply($closure)
    {
        foreach ($this->_data as $key => $val) {
            $this->_data[$key] = $closure($val, $key, $this);
        }
        return $this;
    }
234525
public function transaction($closure, $execute=true)
    {
        $transaction = static::connection()->transaction();
        $transaction->callback($closure, $this);

        if($execute)
            $transaction->execute();

        return $transaction;
    }
1209128
public static function reduce(array $carry, array $match)
    {
        if (!isset($carry[$match['index']]) || $carry[$match['index']]['score'] < $match['score']) {
            $carry[$match['index']] = $match;
        }

        return $carry;
    }
304223
function sortCustomKey(callable $closure) {
        $data = $this->data;
        \uksort($data, $closure);
        
        return (new self($data));
    }
1274747
private static function mapNumeric($value, \Closure $func)
    {
        if (is_numeric($value)) {
            $value = $func($value);
        } elseif (is_array($value)) {
            array_walk_recursive($value, function (&$value) use ($func) {
                $value = self::mapNumeric($value, $func);
            });
        }

        return $value;
    }
1040539
function filter(callable $closure) {
        $new = array();
        foreach($this->data as $key => $val) {
            $feed = (bool) $closure($val, $key);
            if($feed) {
                $new[$key] = $val;
            }
        }
        
        return (new self($new));
    }
374000
public function runInTrans(\Closure $closure) {
        $this->startTrans();
        try {
            $result = $closure();
            $this->commit();
            return $result;
        } catch (\Exception $e) {
            $this->rollback();
            throw $e;
        } catch (\Throwable $e) {
            $this->rollback();
            throw $e;
        }
    }
850921
function each(callable $closure) {
        foreach($this->data as $key => $val) {
            $feed = $closure($val, $key);
            if($feed === false) {
                break;
            }
        }
        
        return $this;
    }
1239031
function sortCustomKey(callable $closure) {
        $args = $this->baseStorageArgs;
        $args[] = parent::sortCustomKey($closure)->all();
        
        return (new static(...$args));
    }
887339
static public function group($closure)
    {
        $backtrace = debug_backtrace();
        //!isset($this) || $backtrace[0]['type'] == '::' || 
        if(self::$instance->prefix == null) {
            exit('Can not be called statically or directly. Use Route::prefix(name)->group(routes-to-be-registered)');
        }
        if($closure instanceof Closure) {
            call_user_func($closure);
        }
        self::$instance->prefix = null;
    }
147626
public function at(\Closure $closure): self
    {
        $arrayy = clone $this;

        foreach ($arrayy->getGenerator() as $key => $value) {
            $closure($value, $key);
        }

        return static::create(
            $arrayy->toArray(),
            $this->iteratorClass,
            false
        );
    }
907835
public function fmap(callable $closure)
    {
        return $this->bind(function ($a) use ($closure) {
            return $this->of($closure($a));
        });
    }
215412
public function max($callback = null)
    {
        return $this->reduce(function ($carry, $value, $key) use ($callback) {
            if ($callback === null) {
                $result = $value;
            } else {
                $result = $this->accessKey($value, $callback, $key);
            }

            if ($carry === null || $carry < $result) {
                return $result;
            }

            return $carry;
        }, null);
    }
701398
public function handle(Closure $closure)
    {
        $this->strict(
            \call_user_func($closure, $this->getMessage(), [$this, 'fail'])
        );

        return $this->toResponse();
    }