src/Fusonic/Linq/Linq.php
public function sum(callable $func = null)
    {
        $sum = 0;
        $iterator = $this->getSelectIteratorOrInnerIterator($func);
        foreach ($iterator as $value) {
            if (!is_numeric($value)) {
                throw new UnexpectedValueException("sum() only works on numeric values.");
            }

            $sum += $value;
        }
        return $sum;
    }
public function sum(callable $func = null)
    {
        $sum = 0;
        $iterator = $this->getSelectIteratorOrInnerIterator($func);
        foreach ($iterator as $value) {
            if (!is_numeric($value)) {
                throw new UnexpectedValueException("sum() only works on numeric values.");
            }

            $sum += $value;
        }
        return $sum;
    }
public function sum ( callable $ func = null ) { $ sum = 0 ; $ iterator = $ this -> getSelectIteratorOrInnerIterator ( $ func ) ; foreach ( $ iterator as $ value ) { if ( ! is_numeric ( $ value ) ) { throw new UnexpectedValueException ( "sum() only works on numeric values." ) ; } $ sum += $ value ; } return $ sum ; }
Gets the sum of all items or by invoking a transform function on each item to get a numeric value.

@param callable $func    A func that returns any numeric type (int, float etc.) from the given element, or NULL to use the element itself.
@throws \UnexpectedValueException if any element is not a numeric value.
@return  double         The sum of all items.
Gets the sum of all items or by invoking a transform function on each item to get a numeric value .