FullNameParser::fix_case PHP Method

fix_case() public method

# ucfirst all upper/lower strings, but leave camelcase words alone
public fix_case ( $word )
    public function fix_case($word)
    {
        # Fix case for words split by periods (J.P.)
        if (strpos($word, '.') !== false) {
            $word = $this->safe_ucfirst(".", $word);
        }
        # Fix case for words split by hyphens (Kimura-Fay)
        if (strpos($word, '-') !== false) {
            $word = $this->safe_ucfirst("-", $word);
        }
        # Special case for single letters
        if (strlen($word) == 1) {
            $word = strtoupper($word);
        }
        # Special case for 2-letter words
        if (strlen($word) == 2) {
            # Both letters vowels (uppercase both)
            if (in_array(strtolower($word[0]), $this->dict['vowels']) && in_array(strtolower($word[1]), $this->dict['vowels'])) {
                $word = strtoupper($word);
            }
            # Both letters consonants (uppercase both)
            if (!in_array(strtolower($word[0]), $this->dict['vowels']) && !in_array(strtolower($word[1]), $this->dict['vowels'])) {
                $word = strtoupper($word);
            }
            # First letter is vowel, second letter consonant (uppercase first)
            if (in_array(strtolower($word[0]), $this->dict['vowels']) && !in_array(strtolower($word[1]), $this->dict['vowels'])) {
                $word = ucfirst(strtolower($word));
            }
            # First letter consonant, second letter vowel or "y" (uppercase first)
            if (!in_array(strtolower($word[0]), $this->dict['vowels']) && (in_array(strtolower($word[1]), $this->dict['vowels']) || strtolower($word[1]) == 'y')) {
                $word = ucfirst(strtolower($word));
            }
        }
        # Fix case for words which aren't initials, but are all uppercase or lowercase
        if (strlen($word) >= 3 && (ctype_upper($word) || ctype_lower($word))) {
            $word = ucfirst(strtolower($word));
        }
        return $word;
    }