public static function closest(array $array, string $value)
    {
        sort($array);
        $closest = $array[0];

        for ($i = 1, $j = count($array), $k = 0; $i < $j; $i++, $k++) {
            $middleValue = ((int) $array[$i] - (int) $array[$k]) / 2 + (int) $array[$k];

            if ($value >= $middleValue) {
                $closest = $array[$i];
            }
        }

        return static::value($closest);
    }