src/Fusonic/Linq/Linq.php
public function min(callable $func = null)
    {
        $min = null;
        $iterator = $this->getSelectIteratorOrInnerIterator($func);
        foreach ($iterator as $value) {
            if (!is_numeric($value) && !is_string($value) && !($value instanceof \DateTime)) {
                throw new UnexpectedValueException("min() only works on numeric values, strings and DateTime objects.");
            }

            if (is_null($min)) {
                $min = $value;
            } elseif ($min > $value) {
                $min = $value;
            }
        }

        if ($min === null) {
            throw new \RuntimeException("Cannot calculate min() as the Linq sequence contains no elements.");
        }

        return $min;
    }
public function min(callable $func = null)
    {
        $min = null;
        $iterator = $this->getSelectIteratorOrInnerIterator($func);
        foreach ($iterator as $value) {
            if (!is_numeric($value) && !is_string($value) && !($value instanceof \DateTime)) {
                throw new UnexpectedValueException("min() only works on numeric values, strings and DateTime objects.");
            }

            if (is_null($min)) {
                $min = $value;
            } elseif ($min > $value) {
                $min = $value;
            }
        }

        if ($min === null) {
            throw new \RuntimeException("Cannot calculate min() as the Linq sequence contains no elements.");
        }

        return $min;
    }
public function min ( callable $ func = null ) { $ min = null ; $ iterator = $ this -> getSelectIteratorOrInnerIterator ( $ func ) ; foreach ( $ iterator as $ value ) { if ( ! is_numeric ( $ value ) && ! is_string ( $ value ) && ! ( $ value instanceof \ DateTime ) ) { throw new UnexpectedValueException ( "min() only works on numeric values, strings and DateTime objects." ) ; } if ( is_null ( $ min ) ) { $ min = $ value ; } elseif ( $ min > $ value ) { $ min = $ value ; } } if ( $ min === null ) { throw new \ RuntimeException ( "Cannot calculate min() as the Linq sequence contains no elements." ) ; } return $ min ; }
Gets the minimum item value 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 \RuntimeException if the sequence contains no elements
@throws \UnexpectedValueException
@return  double Minimum item value
Gets the minimum item value of all items or by invoking a transform function on each item to get a numeric value .