/** * Українські жіночі імена, що в називному відмінку однини закінчуються на приголосний, * відмінюються як відповідні іменники ІІІ відміни * @return boolean true - якщо було задіяно правило з переліку, false - якщо правило не знайдено */ protected function womanRule2() { if ($this->in($this->Last(1), $this->consonant . 'ь')) { $osnova = $this->getOsnova($this->workingWord); $apostrof = ''; $duplicate = ''; $osLast = NCLStr::substr($osnova, -1, 1); $osBeforeLast = NCLStr::substr($osnova, -2, 1); //Чи треба ставити апостроф if ($this->in($osLast, 'мвпбф') and $this->in($osBeforeLast, $this->vowels)) { $apostrof = '’'; } //Чи треба подвоювати if ($this->in($osLast, 'дтзсцлн')) { $duplicate = $osLast; } //Відмінюємо if ($this->Last(1) == 'ь') { $this->wordForms($osnova, array('і', 'і', 'ь', $duplicate . $apostrof . 'ю', 'і', 'е')); $this->Rule(201); return true; } else { $this->wordForms($osnova, array('і', 'і', '', $duplicate . $apostrof . 'ю', 'і', 'е')); $this->Rule(202); return true; } } return false; }
/** * Склоняет текущие слова в падеж <var>$caseNum</var> и форматирует слово по шаблону <var>$format</var> * <b>Формат:</b> * - S - Фамилия * - N - Имя * - F - Отчество * @param string $format строка с форматом * @return string строка в нужном падеже */ public function getFormatted($caseNum = 0, $format = "S N F") { $this->AllWordCases(); //Если не указан падеж используем другую функцию if ($caseNum === null) { return $this->getFormattedArray($format); } elseif (is_array($format)) { return $this->getFormattedHard($caseNum, $format); } else { $length = NCLStr::strlen($format); $result = ""; for ($i = 0; $i < $length; $i++) { $symbol = NCLStr::substr($format, $i, 1); if ($symbol == 'S') { $result .= $this->getSecondNameCase($caseNum); } elseif ($symbol == 'N') { $result .= $this->getFirstNameCase($caseNum); } elseif ($symbol == 'F') { $result .= $this->getFatherNameCase($caseNum); } else { $result .= $symbol; } } return $result; } }
/** * Превращает строку в массив букв * @param string $phrase строка * @return array массив букв */ static function splitLetters($phrase) { $resultArr = array(); $stop = NCLStr::strlen($phrase); for ($idx = 0; $idx < $stop; $idx++) { $resultArr[] = NCLStr::substr($phrase, $idx, 1); } return $resultArr; }
/** * Возвращает все падежи слова в начальную маску: * - x - маленькая буква * - X - больная буква */ private function returnMask() { if ($this->isUpperCase) { foreach ($this->NameCases as $index => $case) { $this->NameCases[$index] = NCLStr::strtoupper($this->NameCases[$index]); } } else { $splitedMask = $this->letterMask; $maskLength = count($splitedMask); foreach ($this->NameCases as $index => $case) { $caseLength = NCLStr::strlen($case); $max = min(array($caseLength, $maskLength)); $this->NameCases[$index] = ''; for ($letterIndex = 0; $letterIndex < $max; $letterIndex++) { $letter = NCLStr::substr($case, $letterIndex, 1); if ($splitedMask[$letterIndex] == 'X') { $letter = NCLStr::strtoupper($letter); } $this->NameCases[$index] .= $letter; } $this->NameCases[$index] .= NCLStr::substr($case, $max, $caseLength - $maskLength); } } }