morphos\RussianGeneralDeclension::pluralizeAllDeclensions PHP Method

pluralizeAllDeclensions() public method

public pluralizeAllDeclensions ( $word, $animate = false )
    public function pluralizeAllDeclensions($word, $animate = false)
    {
        $word = lower($word);
        $prefix = slice($word, 0, -1);
        $last = slice($word, -1);
        if (($declension = $this->getDeclension($word)) == self::FIRST_DECLENSION) {
            $soft_last = $last == 'й' || in_array($last, ['ь', 'е', 'ё', 'ю', 'я']) && $this->isConsonant(slice($word, -2, -1));
            $prefix = $this->getPrefixOfFirstDeclension($word, $last);
        } else {
            if ($declension == self::SECOND_DECLENSION) {
                $soft_last = $this->checkLastConsonantSoftness($word);
            } else {
                $soft_last = false;
            }
        }
        $forms = array(RussianCases::IMENIT_1 => $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'я', $prefix . 'а'));
        // RODIT_2
        if ($this->isHissingConsonant($last) || $soft_last && $last != 'й') {
            $forms[RussianCases::RODIT_2] = $prefix . 'ей';
        } else {
            if ($last == 'й') {
                $forms[RussianCases::RODIT_2] = $prefix . 'ев';
            } else {
                // ($this->isConsonant($last) && !$this->isHissingConsonant($last))
                $forms[RussianCases::RODIT_2] = $prefix . 'ов';
            }
        }
        // DAT_3
        $forms[RussianCases::DAT_3] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'ям', $prefix . 'ам');
        // VINIT_4
        $forms[RussianCases::VINIT_4] = $this->getVinitCaseByAnimateness($forms, $animate);
        // TVORIT_5
        // my personal rule
        if ($last == 'ь' && $declension == self::THIRD_DECLENSION) {
            $forms[RussianCases::TVORIT_5] = $prefix . 'ми';
        } else {
            $forms[RussianCases::TVORIT_5] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'ями', $prefix . 'ами');
        }
        // PREDLOJ_6
        $forms[RussianCases::PREDLOJ_6] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'ях', $prefix . 'ах');
        return $forms;
    }