Get the sum of the collection items.

@param  mixed  $callback
@return mixed
503970
public function sum($callback = null)
    {
        if (is_null($callback)) {
            return array_sum($this->items);
        }

        return array_reduce($this->items, function ($result, $item) use ($callback) {
            if (is_string($callback)) {
                return $result += $item->{$callback}();
            }

            return $result += $callback($item);
        }, 0);
    }
261124
public function find($callback)
    {
        foreach ($this->value as $value) {
            if (call_user_func($callback, $value)) {
                return $value;
            }
        }
        
        return null;
    }
969976
public static function sum($items, $callback = null)
    {
        $callback = static::valueRetriever($callback);
        $sum = null;

        foreach ($items as $item) {
            if (($amount = $callback($item)) !== null) {
                $sum = $sum ? $sum->add($amount) : $amount;
            }
        }

        return $sum ?: static::zero();
    }
446148
public function map(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$key] = $callback($value, $key);
        }

        return new static($items);
    }
39301
private function walkProgressMultiPage($walkableCollection, $callback)
    {
        $lastPage = $walkableCollection->getLastPageNumber();

        for ($currentPage = $walkableCollection->getCurPage(); $currentPage <= $lastPage; $currentPage++) {
            $walkableCollection->clear();
            $walkableCollection->setCurPage($currentPage);
            $walkableCollection->load();

            $walkableItems = $walkableCollection->getItems();

            if (count($walkableItems) == 0) {
                throw new \Exception('Failed to retrieve Collection Page...');
            }

            $this->walkProgress($walkableItems, function ($walkableItem) use ($currentPage, $lastPage, $callback) {
                return 'Page ' . $currentPage . ' of ' . $lastPage . ' -> ' . $callback($walkableItem);
            });
        }
    }
615873
static public function listSum($list, $field,$callback = null)
    {
        $sum = 0;
        foreach ($list as $row) {
            if ($callback instanceof \Closure) {
                if ($callback($row) === true) {
                    $sum += $row[$field];
                }
            }else {
                $sum += $row[$field];
            }
        }
        return $sum;
    }
747204
public function each(callable $callback): ArrayCollection
    {
        foreach ($this->items as $key => $value) {
            $callback($value, $key);
        }

        return $this;
    }
89215
public function last(callable $callback = null, $default = null)
    {
        $collection = $callback ? $this->filter($callback) : $this;

        foreach ($collection->all() as $key => $value) {
            // Nothing needed here
        }

        return isset($value) ? $value : $default;
    }
560848
public function min($callback = null)
    {
        $callback = $this->valueRetriever($callback);

        return $this->filter(function ($value) {
            return !is_null($value);
        })->reduce(function ($result, $item) use ($callback) {
            $value = $callback($item);

            return is_null($result) || $value < $result ? $value : $result;
        });
    }
845659
public function sum(callable $callback = null)
    {

        if ($callback === null)
        {
            $callback = function ($time) {

                return $time->getSeconds();
            };

            return $this->createTime(0, 0, parent::sum($callback));
        }

        return parent::sum($callback);
    }
98525
public function sort(callable $callback = null)
    {
        $items = $this->items;

        $callback = $callback ?: function ($a, $b) {
            return $a == $b ? 0 : (($a < $b) ? -1 : 1);

        };

        uasort($items, $callback);

        return new static($items);
    }
948019
public function every(callable $callback) {
		$match = true;
		foreach ($this->collection as $element) {
			$match = $match && $callback($element);
		}

		return $match;
	}
361199
public function reject($callback): CollectionInterface
    {
        return $this->filter(function ($item, $key) use ($callback) {
            if (is_callable($callback)) {
                return !$callback($item, $key);
            }

            if (null === $item || is_scalar($item)) {
                return $item !== $callback;
            }

            return !$this->accessKey($item, $callback, $key);
        });
    }
977925
public function each(callable $callback)
    {
        if ($this->isCollection()) {
            foreach ($this->data as $val) {
                $callback($this->box($val));
            }
        } else {
            $callback($this->box($this->data));
        }

        return $this;
    }
1239310
private function getCallback($callback)
    {
        if (is_callable($callback)) {
            if (is_array($callback)) {
                $callback = function (Vertex $vertex) use ($callback) {
                    return call_user_func($callback, $vertex);
                };
            }
            return $callback;
        }

        static $methods = array(
            self::ORDER_ID => 'getId',
            self::ORDER_GROUP => 'getGroup'
        );

        if (!is_int($callback) || !isset($methods[$callback])) {
            throw new InvalidArgumentException('Invalid callback given');
        }

        $method = $methods[$callback];

        return function (Vertex $vertex) use ($method) {
            return $vertex->$method();
        };
    }
132087
public function mapWithKeys(callable $callback): CollectionInterface
    {
        return $this->wrap(function (Iterator $data) use ($callback) {
            foreach ($data as $key => $value) {
                /** @var iterable $result */
                $result = $callback($value, $key);

                foreach ($result as $resultKey => $resultValue) {
                    yield $resultKey => $resultValue;
                }
            }
        });
    }
834074
public function reduce($callback)
    {
        $result = null;
        foreach ($this as $key => $value) {
            $result = $callback($value, $key);
        }

        return $result;
    }