From 4ad81d6dfdee68fded2ce62f0f0e01ff070038c7 Mon Sep 17 00:00:00 2001 From: Alexey Borisov Date: Thu, 26 Sep 2024 12:06:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BA=D0=BB=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BC=D1=83=D0=B6=D1=81=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D1=84=D0=B0=D0=BC=D0=B8=D0=BB=D0=B8=D0=B9=20=D1=81=20=D0=BE?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=87=D0=B0=D0=BD=D0=B8=D1=8F=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=B5=D0=BA,=20=D0=B5=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Russian/LastNamesInflection.php | 18 ++++++++++++++++++ tests/Russian/LastNamesInflectionTest.php | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/Russian/LastNamesInflection.php b/src/Russian/LastNamesInflection.php index a7f00bc..3b80848 100644 --- a/src/Russian/LastNamesInflection.php +++ b/src/Russian/LastNamesInflection.php @@ -212,6 +212,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)); diff --git a/tests/Russian/LastNamesInflectionTest.php b/tests/Russian/LastNamesInflectionTest.php index 68a7f24..83ddb7b 100644 --- a/tests/Russian/LastNamesInflectionTest.php +++ b/tests/Russian/LastNamesInflectionTest.php @@ -77,6 +77,10 @@ public function lastNamesProvider() // ['Зоя', NamesInflection::FEMALE, 'Зои', 'Зое', 'Зою', 'Зоей', 'Зое'], // ['Молодыха', NamesInflection::FEMALE, 'Молодыхи', 'Молодыхе', 'Молодыху', 'Молодыхой', 'Молодыхе'], ['Стальная', NamesInflection::FEMALE, 'Стальной', 'Стальной', 'Стальную', 'Стальной', 'Стальной'], + ['Неборачек', NamesInflection::MALE, 'Неборачка', 'Неборачку', 'Неборачка', 'Неборачком', 'Неборачке'], + ['Городец', NamesInflection::MALE, 'Городца', 'Городцу', 'Городца', 'Городцом', 'Городце'], + ['Малец', NamesInflection::MALE, 'Мальца', 'Мальцу', 'Мальца', 'Мальцом', 'Мальце'], + ['Малек', NamesInflection::MALE, 'Малька', 'Мальку', 'Малька', 'Мальком', 'Мальке'], [ 'Завгородняя', NamesInflection::FEMALE,