DaveChild\TextStatistics\Maths::normaliseScore PHP Method

normaliseScore() public static method

Also rounds result to specified precision. Thanks to github.com/lvil.
public static normaliseScore ( integer | float $score, integer $min, integer $max, $dps = 1 ) : integer | float
$score integer | float Initial score
$min integer Minimum score allowed
$max integer Maximum score allowed
return integer | float
    public static function normaliseScore($score, $min, $max, $dps = 1)
    {
        if ($score > $max) {
            $score = $max;
        } elseif ($score < $min) {
            $score = $min;
        }
        $score = self::bcCalc($score, '+', 0, true, $dps);
        // Round
        return $score;
    }