def count_phrase_in_text(phrase: str, text: str) -> int:
    """Count how many times the phrase appears in the text

    :param phrase: string that may contain white spaces
    :param text: string where the phrase will get count
    :return: count: number of times the phrase appears in the text
    """
    count = 0
    # Remove leading and trailing white spaces
    phrase = phrase.strip()
    # Substitute multiple whitespace with single whitespace
    phrase = ' '.join(phrase.split())
    if text.startswith(phrase + " "):
        count += 1
    if text.endswith(" " + phrase + "\n") or text.endswith(" " + phrase) or \
            text.endswith(" " + phrase + "\r\n") or text.endswith(phrase):
        count += 1
    count += len(text.split(" " + phrase + " ")) - 1
    return count