Conditions | 5 |
Paths | 6 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 5.0187 |
Changes | 0 |
1 | <?php |
||
41 | 4 | private function findClosesMatch(array $words, string $input) |
|
42 | { |
||
43 | 4 | $shortestDistance = -1; |
|
44 | 4 | $closest = ''; |
|
45 | 4 | foreach ($words as $word) { |
|
46 | 4 | $levenshtein = levenshtein($input, $word); |
|
47 | 4 | if ($levenshtein <= $shortestDistance || $shortestDistance < 0) { |
|
48 | 4 | $closest = $word; |
|
49 | 4 | $shortestDistance = $levenshtein; |
|
50 | } |
||
51 | } |
||
52 | |||
53 | 4 | if ($shortestDistance <= 60) { |
|
54 | 4 | return $closest; |
|
55 | } |
||
56 | |||
57 | return ''; |
||
58 | } |
||
59 | } |
||
60 |