Skip to content

Commit

Permalink
Fix verbs without 'л' at the end in RussianLanguage::verb()
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Oct 22, 2018
1 parent 082bc34 commit d55ee40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Russian/RussianLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,16 @@ public static function verb($verb, $gender)
$verb = S::lower($verb);
// возвратный глагол
if (S::slice($verb, -2) == 'ся') {
return ($gender == Gender::MALE ? $verb : mb_substr($verb, 0, -2).'ась');

return ($gender == Gender::MALE
? $verb
: S::slice($verb, 0, -2).(S::slice($verb, -3, -2) === 'л' ? null : 'л').'ась');
}

// обычный глагол
return ($gender == Gender::MALE ? $verb : $verb.'а');
return ($gender == Gender::MALE
? $verb
: $verb.(S::slice($verb, -1) === 'л' ? null : 'л').'а');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/Russian/RussianLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public function verbsProvider()
['попал', Gender::FEMALE, 'попала'],
['попался', Gender::MALE, 'попался'],
['попался', Gender::FEMALE, 'попалась'],
['внес', Gender::FEMALE, 'внесла'],
['внесся', Gender::FEMALE, 'внеслась'],
];
}

Expand Down

0 comments on commit d55ee40

Please sign in to comment.