function SearchTextProcessor::truncate

Same name in other branches
  1. 9 core/modules/search/src/SearchTextProcessor.php \Drupal\search\SearchTextProcessor::truncate()
  2. 11.x core/modules/search/src/SearchTextProcessor.php \Drupal\search\SearchTextProcessor::truncate()

Helper function for array_walk in ::analyze().

Parameters

string $text: The text to be truncated.

File

core/modules/search/src/SearchTextProcessor.php, line 180

Class

SearchTextProcessor
Processes search text for indexing.

Namespace

Drupal\search

Code

protected function truncate(string &$text) : void {
    if (is_numeric($text)) {
        $text = ltrim($text, '0');
    }
    if (mb_strlen($text) <= 50) {
        return;
    }
    $text = mb_substr($text, 0, 50);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.