Skip to content

Commit

Permalink
[!]: re-write -> "object oriented" -> try to fix for PHP < 7 v4
Browse files Browse the repository at this point in the history
  • Loading branch information
voku committed Apr 5, 2017
1 parent 7bf8de4 commit 9a0bee5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/voku/helper/Phonetic.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ public function phonetic_matches($needle, array $haystack)
}

if (count($result) > 0) {
uasort(
uksort(
$result, function ($a, $b) {
if ($a === $b) {
return -1;
if ($a == $b) {
return 1;
}

return (count($a) > count($b)) ? -1 : 1;
return (count($a) < count($b)) ? -1 : 1;
}
);

Expand Down
6 changes: 3 additions & 3 deletions tests/PhoneticAlgorithmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public function testPhoneticMatchesSentence()
'Wasche' => 'Wäsche',
'troknen' => 'trocknen',
),
342 => array(
'Wasche' => 'Wäsche',
),
621 => array(
'Wasche' => 'Wäsche',
),
313 => array(
'Wasche' => 'Wäsche',
),
342 => array(
'Wasche' => 'Wäsche',
),
),
$phonetic->phonetic_matches('Wasche troknen? Wie geht das?', $tests)
);
Expand Down

0 comments on commit 9a0bee5

Please sign in to comment.