Skip to content

Commit

Permalink
Merge pull request #153 from anoriar/fix-male-ek-etz
Browse files Browse the repository at this point in the history
Склонение мужских фамилий с окончаниями ек, ец
  • Loading branch information
wapmorgan authored Sep 26, 2024
2 parents 1065704 + 015f123 commit 71dec63
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Russian/LastNamesInflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,24 @@ public static function getCases($name, $gender = null)
];
}

if (S::length($name) > 3 && in_array(S::slice($name, -2), ['ек', 'ец'], true)) {
$last_consonant = S::slice($name, -3, -2);
if (in_array($last_consonant, ['л'])) {
$prefix = S::name(S::slice($name, 0, -2)) . 'ь' . S::slice($name, -1);
} else {
$prefix = S::name(S::slice($name, 0, -2)) . S::slice($name, -1);
}

return [
static::IMENIT => S::name($name),
static::RODIT => $prefix . 'а',
static::DAT => $prefix . 'у',
static::VINIT => $prefix . 'а',
static::TVORIT => $prefix . 'ом',
static::PREDLOJ => $prefix . 'е',
];
}

} else {
if (in_array(S::slice($name, -3), ['ова', 'ева', 'ина', 'ына', 'ёва'], true)) {
$prefix = S::name(S::slice($name, 0, -1));
Expand Down
4 changes: 4 additions & 0 deletions tests/Russian/LastNamesInflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public function lastNamesProvider()
['Янушонок', NamesInflection::MALE, 'Янушонка', 'Янушонку', 'Янушонка', 'Янушонком', 'Янушонке'],
['Оборок', NamesInflection::MALE, 'Оборка', 'Оборку', 'Оборка', 'Оборком', 'Оборке'],
['Бок', NamesInflection::MALE, 'Бока', 'Боку', 'Бока', 'Боком', 'Боке'],
['Неборачек', NamesInflection::MALE, 'Неборачка', 'Неборачку', 'Неборачка', 'Неборачком', 'Неборачке'],
['Городец', NamesInflection::MALE, 'Городца', 'Городцу', 'Городца', 'Городцом', 'Городце'],
['Малец', NamesInflection::MALE, 'Мальца', 'Мальцу', 'Мальца', 'Мальцом', 'Мальце'],
['Малек', NamesInflection::MALE, 'Малька', 'Мальку', 'Малька', 'Мальком', 'Мальке'],
[
'Завгородняя',
NamesInflection::FEMALE,
Expand Down

0 comments on commit 71dec63

Please sign in to comment.