I wrote a PHP class to manage some statistic functions but there are some functions that need a minimum of elements i.e. >0. So I added a try catch and I still get the same error.
/**
* Calculates the minimum for a given set of values.
*
* @param array $values The input values
* @return float|int The minimum of values as an integer or float
*/
public static function min($values)
{
try {
min($values);
} catch (Exception $e) {
return 0;
}
}
And I get:
ErrorException in Statistics.php line 41: min(): Array must contain at least one element
Thanks in advance.