You are here

protected function Porter2::charAt in Search API 8

Retrieves the character at the given position.

Parameters

int $position: The 0-based index of the character. If a negative number is given, the position is counted from the end of the string.

string|null $word: (optional) The word from which to retrieve the character. Defaults to $this->word.

Return value

string The character at the given position, or an empty string if the given position was illegal.

4 calls to Porter2::charAt()
Porter2::isVowel in src/Plugin/search_api/processor/Resources/Porter2.php
Checks whether a character is a vowel.
Porter2::step2 in src/Plugin/search_api/processor/Resources/Porter2.php
Implements step 2 of the Porter2 algorithm.
Porter2::step4 in src/Plugin/search_api/processor/Resources/Porter2.php
Implements step 4 of the Porter2 algorithm.
Porter2::step5 in src/Plugin/search_api/processor/Resources/Porter2.php
Implements step 5 of the Porter2 algorithm.

File

src/Plugin/search_api/processor/Resources/Porter2.php, line 429

Class

Porter2
Implements the Porter2 stemming algorithm.

Namespace

Drupal\search_api\Plugin\search_api\processor\Resources

Code

protected function charAt($position, $word = NULL) {
  if ($word === NULL) {
    $word = $this->word;
  }
  $length = strlen($word);
  if (abs($position) >= $length) {
    return '';
  }
  if ($position < 0) {
    $position += $length;
  }
  return $word[$position];
}