Skip to content

Commit

Permalink
#122 added works to tests and fix invalid suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Feb 5, 2023
1 parent 44968b3 commit e3564fd
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 29 deletions.
45 changes: 30 additions & 15 deletions src/Russian/LastNamesInflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,37 @@ public static function getCases($name, $gender = null)
];
}

// Верхний / Убогий / Толстой / Цой
// Верхнего / Убогого / Толстого / Цоя
// Верхнему / Убогому / Толстому / Цою
// Верхним / Убогим / Толстым / Цоя
// о Верхнем / об Убогом / о Толстом / Цоем
// Верхнем / Убогом / о Толстом / Цое
// Толстой / Цой / Лукелий
// Толстого / Цоя / Лукелия
// Толстому / Цою / Лукелию
// Толстым / Цоя / Лукелия
// о Толстом / Цоем / Лукелием
// о Толстом / о Цое / о Лукелие
// similar to next if
if (in_array(S::slice($name, -2), ['ой', 'ый', 'ий'], true)) {
$prefix = S::name(S::slice($name, 0, -2));
return [
static::IMENIT => S::name($name),
static::RODIT => $prefix . RussianLanguage::chooseEndingBySonority($prefix, 'оя', 'ого'),
static::DAT => $prefix . 'ому',
static::VINIT => $prefix . 'ого',
static::TVORIT => $prefix . 'ым',
static::PREDLOJ => $prefix . 'ом',
];
$last_consonant = S::slice($name, -3, -2);
$last_sonority = (RussianLanguage::isSonorousConsonant($last_consonant) && $last_consonant !== 'н') || $last_consonant === 'ц';
if ($last_sonority) {
$prefix = S::name(S::slice($name, 0, -1));
return [
static::IMENIT => S::name($name),
static::RODIT => $prefix . 'я',
static::DAT => $prefix . 'ю',
static::VINIT => $prefix . 'я',
static::TVORIT => $prefix . 'ем',
static::PREDLOJ => $prefix . (in_array(S::slice($name, -2), ['ой', 'ей']) ? 'е' : 'и'),
];
} else {
$prefix = S::name(S::slice($name, 0, -2));
return [
static::IMENIT => S::name($name),
static::RODIT => $prefix . 'ого',
static::DAT => $prefix . 'ому',
static::VINIT => $prefix . 'ого',
static::TVORIT => $prefix . 'ым',
static::PREDLOJ => $prefix . 'ом',
];
}
}

if (in_array(S::slice($name, -2), ['ей', 'ай'], true)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Russian/RussianLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class RussianLanguage
/**
* @var string[] Глухие согласные
*/
public static $deafConsonants = ['п', 'ф', 'к', 'т', 'с', 'ш', 'х', 'ч', 'ц', 'щ'];
public static $deafConsonants = ['п', 'ф', 'к', 'т', 'с', 'ш', 'х', 'ч', 'щ'];

/**
* @var string[] Союзы
Expand Down Expand Up @@ -320,7 +320,7 @@ public static function isVowel($char)
*/
public static function chooseEndingBySonority($word, $ifSonorous, $ifDeaf)
{
$last = S::slice(S::lower($word), -1);
$last = S::lower(S::slice($word, -1));
if (static::isSonorousConsonant($last)) {
return $ifSonorous;
}
Expand Down
23 changes: 12 additions & 11 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM php:7.4-cli
RUN apt-get update && apt-get install --yes --no-install-recommends libzip-dev libbz2-dev liblzma-dev p7zip-full git wget
RUN pecl install xdebug-3.1.5
RUN docker-php-source extract \
&& git clone https://github.com/cataphract/php-rar.git && cd php-rar && phpize && ./configure \
&& make && make install && cd ../ && rm -rf php-rar \
&& git clone https://github.com/codemasher/php-ext-xz.git && cd php-ext-xz && phpize && ./configure \
&& make && make install && cd ../ && rm -rf php-ext-xz \
&& docker-php-source delete
RUN docker-php-ext-install bz2 zip && docker-php-ext-enable rar xz xdebug

RUN echo "xdebug.mode = debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN apt-get update && apt-get install --yes --no-install-recommends git wget
#RUN apt-get update && apt-get install --yes --no-install-recommends libzip-dev libbz2-dev liblzma-dev p7zip-full git wget
#RUN pecl install xdebug-3.1.5
#RUN docker-php-source extract \
# && git clone https://github.com/cataphract/php-rar.git && cd php-rar && phpize && ./configure \
# && make && make install && cd ../ && rm -rf php-rar \
# && git clone https://github.com/codemasher/php-ext-xz.git && cd php-ext-xz && phpize && ./configure \
# && make && make install && cd ../ && rm -rf php-ext-xz \
# && docker-php-source delete
#RUN docker-php-ext-install bz2 zip && docker-php-ext-enable rar xz xdebug
#
#RUN echo "xdebug.mode = debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN wget https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer -O - -q | php -- --quiet --install-dir=/usr/local/bin --filename=composer
3 changes: 2 additions & 1 deletion tests/Russian/LastNamesInflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function lastNamesProvider()
['Прожога', NamesInflection::MALE, 'Прожоги', 'Прожоге', 'Прожогу', 'Прожогой', 'Прожоге'],
['Мазепа', NamesInflection::MALE, 'Мазепы', 'Мазепе', 'Мазепу', 'Мазепой', 'Мазепе'],
['Цой', NamesInflection::MALE, 'Цоя', 'Цою', 'Цоя', 'Цоем', 'Цое'],
['Лукелий', NamesInflection::MALE, 'Лукелия', 'Лукелию', 'Ликелия', 'Лукелием', 'Ликелии'],
['Лукелий', NamesInflection::MALE, 'Лукелия', 'Лукелию', 'Лукелия', 'Лукелием', 'Лукелии'],
['Стуккей', NamesInflection::MALE, 'Стуккея', 'Стуккею', 'Стуккея', 'Стуккеем', 'Стуккее'],

['Смирнова', NamesInflection::FEMALE, 'Смирновой', 'Смирновой', 'Смирнову', 'Смирновой', 'Смирновой'],
['Кромская', NamesInflection::FEMALE, 'Кромской', 'Кромской', 'Кромскую', 'Кромской', 'Кромской'],
Expand Down

0 comments on commit e3564fd

Please sign in to comment.