morphos\RussianGeneralDeclension::declinateFirstDeclension PHP Method

declinateFirstDeclension() public method

public declinateFirstDeclension ( $word, $animate = false )
    public function declinateFirstDeclension($word, $animate = false)
    {
        $word = lower($word);
        $last = slice($word, -1);
        $soft_last = $last == 'й' || in_array($last, ['ь', 'е', 'ё', 'ю', 'я']) && $this->isConsonant(slice($word, -2, -1));
        $prefix = $this->getPrefixOfFirstDeclension($word, $last);
        $forms = array(RussianCases::IMENIT_1 => $word);
        // RODIT_2
        $forms[RussianCases::RODIT_2] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'я', $prefix . 'а');
        // DAT_3
        $forms[RussianCases::DAT_3] = $this->chooseVowelAfterConsonant($last, $soft_last, $prefix . 'ю', $prefix . 'у');
        // VINIT_4
        if (in_array($last, ['о', 'е', 'ё'])) {
            $forms[RussianCases::VINIT_4] = $word;
        } else {
            $forms[RussianCases::VINIT_4] = $this->getVinitCaseByAnimateness($forms, $animate);
        }
        // TVORIT_5
        // if ($last == 'ь')
        // 	$forms[RussianCases::TVORIT_5] = $prefix.'ом';
        // else if ($last == 'й' || ($this->isConsonant($last) && !$this->isHissingConsonant($last)))
        // 	$forms[RussianCases::TVORIT_5] = $prefix.'ем';
        // else
        // 	$forms[RussianCases::TVORIT_5] = $prefix.'ом'; # http://morpher.ru/Russian/Spelling.aspx#sibilant
        if ($this->isHissingConsonant($last) || $last == 'ц') {
            $forms[RussianCases::TVORIT_5] = $prefix . 'ем';
        } else {
            if (in_array($last, ['й']) || $soft_last) {
                $forms[RussianCases::TVORIT_5] = $prefix . 'ем';
            } else {
                $forms[RussianCases::TVORIT_5] = $prefix . 'ом';
            }
        }
        // PREDLOJ_6
        $forms[RussianCases::PREDLOJ_6] = $this->getPredCaseOf12Declensions($word, $last, $prefix);
        return $forms;
    }