import logging


def bases_to_complete_previous_codon(phase):  # pylint: disable=invalid-name
    """
    Return the bases at exon start that completes the previous codon.

    >>> bases_to_complete_previous_codon(0) # e.g. -----XXX
    0
    >>> bases_to_complete_previous_codon(2) # e.g. XX-----X
    1
    >>> bases_to_complete_previous_codon(1) # e.g. X-----XX
    2
    """
    if phase == 0:
        return 0
    if phase == 1:
        return 2
    if phase == 2:
        return 1

    logging.warning(
        "Only phases 0, 1 and 2 are allowed for internal exons (phase: %s)",
        phase)
    return None