private static function normalizeHue($hue) 
    {
        if (!is_numeric($hue)) {
            throw new \InvalidArgumentException(
                "'$hue' is not a valid hue.");
        }

        $hue = $hue % 360;
        if ($hue < 0) {
            $hue += 360;
        }

        return $hue;
    }