You are here

private function TranslationDataCollector::sanitizeString in Plug 7

1 call to TranslationDataCollector::sanitizeString()
TranslationDataCollector::sanitizeCollectedMessages in lib/Symfony/translation/DataCollector/TranslationDataCollector.php

File

lib/Symfony/translation/DataCollector/TranslationDataCollector.php, line 131

Class

TranslationDataCollector
@author Abdellatif Ait boudad <a.aitboudad@gmail.com>

Namespace

Symfony\Component\Translation\DataCollector

Code

private function sanitizeString($string, $length = 80) {
  $string = trim(preg_replace('/\\s+/', ' ', $string));
  if (function_exists('mb_strlen') && false !== ($encoding = mb_detect_encoding($string))) {
    if (mb_strlen($string, $encoding) > $length) {
      return mb_substr($string, 0, $length - 3, $encoding) . '...';
    }
  }
  elseif (strlen($string) > $length) {
    return substr($string, 0, $length - 3) . '...';
  }
  return $string;
}