Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
parshikov committed Nov 5, 2013
1 parent eb80c8b commit 41df529
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions Petrovich.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,18 @@ public function lastname($lastname, $case = Petrovich::CASE_NOMENATIVE) {
* @return bool|string
*/
private function inflect($name,$case,$type) {
if(($exception = $this->checkException($name,$case,$type)) !== false)
return $exception;
$names_arr = explode('-',$name);
$result = array();

//если двойное имя или фамилия или отчество
if(mb_substr_count($name,'-') > 0) {
$names_arr = explode('-',$name);
$result = '';

foreach($names_arr as $arr_name) {
$result .= $this->findInRules($arr_name,$case,$type).'-';
foreach($names_arr as $arr_name) {
if(($exception = $this->checkException($arr_name,$case,$type)) !== false) {
$result[] = $exception;
}
else {
$result[] = $this->findInRules($arr_name,$case,$type);
}
return mb_substr($result,0,mb_strlen($result)-1);
}
else {
return $this->findInRules($name,$case,$type);
}
return implode('-',$result);
}

/**
Expand Down Expand Up @@ -184,6 +180,8 @@ private function checkException($name,$case,$type) {
if ( ! $this->checkGender($rule->gender) )
continue;
if(array_search($lower_name,$rule->test) !== false) {
if($rule->mods[$case] == '.')
return $name;
return $this->applyRule($rule->mods,$name,$case);
}
}
Expand Down

0 comments on commit 41df529

Please sign in to comment.