public static function truncate($s, $maxLen, $append = "…")
{
if (strlen(utf8_decode($s)) > $maxLen) {
$maxLen = $maxLen - strlen(utf8_decode($append));
if ($maxLen < 1) {
return $append;
} elseif (preg_match('#^.{1,' . $maxLen . '}(?=[\\s\\x00-/:-@\\[-`{-~])#us', $s, $matches)) {
return $matches[0] . $append;
} else {
return self::substring($s, 0, $maxLen) . $append;
}
}
return $s;
}
/** @internal */ protected function checkExtraArgs(MacroNode $node) { if ($node->tokenizer->isNext()) { $args = Latte\Runtime\Filters::truncate($node->tokenizer->joinAll(), 20); trigger_error("Unexpected arguments '{$args}' in " . $node->getNotation()); } }