self::MAX_DIGIT_RATIO) { return false; } return self::longestConsonantRun($token) <= self::MAX_CONSONANT_RUN; } /** * @param string $token a lowercase alphanumeric-and-separator token * @return int the longest run of consecutive consonants, where 'y' counts * as a vowel (it carries one in 'correctly' and 'your'), separators end a * run, and digits are skipped over without ending one. */ private static function longestConsonantRun(string $token): int { $longest = 0; $current = 0; for ($i = 0, $length = strlen($token); $i < $length; $i++) { $character = $token[$i]; if ($character >= '0' && $character <= '9') { continue; } if ($character >= 'a' && $character <= 'z' && strpos('aeiouy', $character) === false) { $current++; if ($current > $longest) { $longest = $current; } } else { $current = 0; } } return $longest; } }