$item = (string) $item;
if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
- if (null === $length) {
- $length = mb_strlen($item, $charset) - $start;
- }
-
- return mb_substr($item, $start, $length, $charset);
- }
-
- if (null === $length) {
- return substr($item, $start);
+ return mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
}
- return substr($item, $start, $length);
+ return null === $length ? substr($item, $start) : substr($item, $start, $length);
}
/**