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