Add limit parameter to StringHelper::trimSplit()

refs #2153
This commit is contained in:
Eric Lippmann 2017-06-07 15:40:00 +02:00 committed by Alexander A. Klimov
parent cfbd5c500e
commit 53eae8d93e
1 changed files with 9 additions and 2 deletions

View File

@ -13,12 +13,19 @@ class StringHelper
* *
* @param string $value * @param string $value
* @param string $delimiter * @param string $delimiter
* @param int $limit
* *
* @return array * @return array
*/ */
public static function trimSplit($value, $delimiter = ',') public static function trimSplit($value, $delimiter = ',', $limit = null)
{ {
return array_map('trim', explode($delimiter, $value)); if ($limit !== null) {
$exploded = explode($delimiter, $value, $limit);
} else {
$exploded = explode($delimiter, $value);
}
return array_map('trim', $exploded);
} }
/** /**