public function checkLastConsonantSoftness($word)
{
if (($substring = last_position_for_one_of_chars(lower($word), array_map(__NAMESPACE__ . '\\lower', self::$consonants))) !== false) {
if (in_array(slice($substring, 0, 1), ['й', 'ч', 'щ'])) {
// always soft consonants
return true;
} else {
if (length($substring) > 1 && in_array(slice($substring, 1, 2), ['е', 'ё', 'и', 'ю', 'я', 'ь'])) {
// consonants are soft if they are trailed with these vowels
return true;
}
}
}
return false;
}