You are here

protected static function Porter2::charAt in Porter-Stemmer 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 $word: The word from which to retrieve the character.

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/Porter2.php
Checks whether a character is a vowel.
Porter2::step2 in src/Porter2.php
Implements step 2 of the Porter2 algorithm.
Porter2::step4 in src/Porter2.php
Implements step 4 of the Porter2 algorithm.
Porter2::step5 in src/Porter2.php
Implements step 5 of the Porter2 algorithm.

File

src/Porter2.php, line 427

Class

Porter2
PHP Implementation of the Porter2 Stemming Algorithm.

Namespace

Drupal\porterstemmer

Code

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