def matches(line, pattern, flags):
    """
    Checks if the pattern is in the line currently being searched. Uses the flags to modify the patter and/or the
    line being searched through.
    `-i` Match line using a case-insensitive comparison.
    `-v` Invert the program -- collect all lines that fail to match the pattern.
    `-x` Only match entire lines, instead of lines that contain a match.
    :param line: the line to search through in the file or the string provided
    :param pattern: the pattern to use for the search
    :param flags: the flags to narrow down the search
    :return: Boolean value, returns True if the pattern is in the line
    :rtype: bool
    """
    # case insensitive, change the variables cases
    if "-i" in flags:
        pattern = pattern.lower()
        line = line.lower()

    # invert matching, will check if the patter is not in line, return True/False whether it is.
    if "-v" in flags:
        return pattern not in line

    # match an entire line
    if "-x" in flags:
        if len(line.rstrip()) != len(pattern):
            return False

    return pattern in line