def to_int(value: str | None) -> int | None:
    """Safely convert string value to int."""
    if value is None:
        return None

    try:
        return int(value)
    except (ValueError, TypeError):
        return None