protected function SuggestionsSpellCheck::odometerIncrement in Search API Spellcheck 8.3
Increment the odometer.
1 call to SuggestionsSpellCheck::odometerIncrement()
- SuggestionsSpellCheck::combineArrays in src/
Plugin/ views/ area/ SuggestionsSpellCheck.php - Combine multiple arrays to one array with all possible suggestions.
File
- src/
Plugin/ views/ area/ SuggestionsSpellCheck.php, line 137
Class
- SuggestionsSpellCheck
- Provides an area for messages.
Namespace
Drupal\search_api_spellcheck\Plugin\views\areaCode
protected function odometerIncrement(array &$odometer, array $suggestions) {
// Basically, work your way from the rightmost digit of the "odometer"...
// if you're able to increment without cycling that digit back to zero,
// you're all done, otherwise, cycle that digit to zero and go one digit to
// the left, and begin again until you're able to increment a digit without
// cycling it.
$count = count($odometer);
for ($i = $count - 1; $i >= 0; $i--) {
$max = count($suggestions[$i]) - 1;
if ($odometer[$i] + 1 <= $max) {
// Increment and done.
$odometer[$i]++;
return TRUE;
}
if ($i - 1 < 0) {
// No more digits left to increment, end of the line.
break;
}
// Can't increment this digit, cycle it to zero and continue the loop
// to go over to the next digit.
$odometer[$i] = 0;
}
return FALSE;
}