def _get_value_as_int(dict_obj, key):
    """
    Return the value associated with a key in a dictionary, converted to an
    int.

    :param dict dict_obj: Dictionary to retrieve the value from
    :param str key: Key associated with the value to return
    :return The value, as an integer. Returns 'None' if the key cannot be found
        in the dictionary.
    :rtype: int
    :raises ValueError: If the key is present in the dictionary but the value
        cannot be converted to an int.
    """
    return_value = None
    if key in dict_obj:
        try:
            return_value = int(dict_obj.get(key))
        except ValueError:
            raise ValueError("'{}' of '{}' could not be converted to an int"
                .format(key, return_value))
    return return_value
