Lower mbstring dependency

This commit is contained in:
Nicolas Grekas 2014-05-12 11:22:51 +02:00
parent b3ec567224
commit 6ab671361b
1 changed files with 2 additions and 6 deletions

View File

@ -211,12 +211,8 @@ abstract class Descriptor implements DescriptorInterface
if (is_bool($value) || is_array($value) || (null === $value)) {
$jsonString = json_encode($value);
if (!function_exists('mb_strlen')) {
return substr($jsonString, 0, 60).(strlen($jsonString) > 60 ? ' ...' : '');
}
if (mb_strlen($jsonString) > 60) {
return mb_substr($jsonString, 0, 60).' ...';
if (preg_match('/^(.{60})./us', $jsonString, $matches)) {
return $matches[1].'...';
}
return $jsonString;