public static function valueToBytes($value): int
    {
        if (is_int($value)) {
            return $value;
        }

        $value = trim($value);

        // Native PHP check for digits in string
        if (ctype_digit(ltrim($value, '-'))) {
            return (int)$value;
        }

        $signed = (substr($value, 0, 1) === '-') ? -1 : 1;

        // Kilobytes
        if (preg_match('/(\d+)K$/i', $value, $matches)) {
            return (int)($matches[1] * $signed * 1024);
        }

        // Megabytes
        if (preg_match('/(\d+)M$/i', $value, $matches)) {
            return (int)($matches[1] * $signed * 1024 * 1024);
        }

        // Gigabytes
        if (preg_match('/(\d+)G$/i', $value, $matches)) {
            return (int)($matches[1] * $signed * 1024 * 1024 * 1024);
        }

        throw new InvalidArgumentException("Failed to find K, M, or G in a non-integer value [$value]");
    }