Skip to content

Commit

Permalink
Merge pull request #7 from jarda-jakoube/Case_sensitive_comparison
Browse files Browse the repository at this point in the history
Case sensitive comparison fixed
  • Loading branch information
Jan Navrátil committed Sep 30, 2015
2 parents 3c2d068 + 0b42594 commit 5700714
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Inflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,20 +537,20 @@ public function inflect($text, $animate = FALSE)

$inflectedWord = [1 => $word];
$word = $this->breakAccents($word);

$wordLower = strtolower($word);
if ($gender === NULL) {
if (in_array($word, $this->forceM)) {
if (in_array($wordLower, $this->forceM)) {
$gender = 'm';
} else if (in_array($word, $this->forceF)) {
} else if (in_array($wordLower, $this->forceF)) {
$gender = 'f';
} else if (in_array($word, $this->forceS)) {
} else if (in_array($wordLower, $this->forceS)) {
$gender = 's';
}
}

$exception = NULL;
foreach ($this->exceptions as $e) {
if ($word === $e[0]) {
if ($wordLower === $e[0]) {
$exception = $e;
break;
}
Expand Down
20 changes: 20 additions & 0 deletions tests/InflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ public function providerNames()
13 => 'Marcelích',
14 => 'Marcely'
)
),
array(
"Dagmar", //name to inflection
null, //environment ? - životné - null because it is inferred from the array with exceptional words
array( //expected result
1 => "Dagmar",
2 => "Dagmary",
3 => "Dagmaře",
4 => "Dagmar",
5 => "Dagmar",
6 => "Dagmar",
7 => "Dagmar",
8 => 'Dagmary',
9 => 'Dagmar',
10 => 'Dagmarám',
11 => 'Dagmary',
12 => 'Dagmary',
13 => 'Dagmarách',
14 => 'Dagmarami'
)
)

);
Expand Down

0 comments on commit 5700714

Please sign in to comment.