From 1897e184a9fd138a54091cb769212852b4849034 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 11 Oct 2014 01:36:34 +0200 Subject: [PATCH] fixed CS --- lib/Twig/Extension/Core.php | 34 +++++++++++++++++----------------- 1 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 1668b83..a94e97c 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -798,29 +798,29 @@ function twig_join_filter($value, $glue = '') */ function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = null) { - if (empty($delimiter)) { - if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) { - if ($limit > 1) { - $length = mb_strlen($value, $charset); - if ($length < $limit) { - return array($value); - } + if (!empty($delimiter)) { + return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit); + } - $r = array(); - for ($i = 0; $i < $length; $i += $limit) { - $r[] = mb_substr($value, $i, $limit, $charset); - } + if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) { + return str_split($value, null === $limit ? 1 : $limit); + } - return $r; - } + if ($limit <= 1) { + return preg_split('/(?