src/Charcoal/App/Script/ArgScriptTrait.php
protected function parseAsArray($var, $delimiter = '[\s,]+')
    {
        if (is_string($var)) {
            if (!is_string($delimiter)) {
                throw new InvalidArgumentException('The delimiter must be a string.');
            }

            $var = preg_split('#(?<!\\\\)'.$delimiter.'#', $var);
        }

        if (is_array($var) || $var instanceof Traversable) {
            return $var;
        }

        throw new InvalidArgumentException('The value cannot be split.');
    }
protected function parseAsArray($var, $delimiter = '[\s,]+')
    {
        if (is_string($var)) {
            if (!is_string($delimiter)) {
                throw new InvalidArgumentException('The delimiter must be a string.');
            }

            $var = preg_split('#(?<!\\\\)'.$delimiter.'#', $var);
        }

        if (is_array($var) || $var instanceof Traversable) {
            return $var;
        }

        throw new InvalidArgumentException('The value cannot be split.');
    }
protected function parseAsArray ( $ var , $ delimiter = '[\s,]+' ) { if ( is_string ( $ var ) ) { if ( ! is_string ( $ delimiter ) ) { throw new InvalidArgumentException ( 'The delimiter must be a string.' ) ; } $ var = preg_split ( '#(?<!\\\\)' . $ delimiter . '#' , $ var ) ; } if ( is_array ( $ var ) || $ var instanceof Traversable ) { return $ var ; } throw new InvalidArgumentException ( 'The value cannot be split.' ) ; }
Resolve the given value as a collection of values.

If the given value is a string, it will be split.

@param  mixed  $var       An argument to split.
@param  string $delimiter The boundary string.
@throws InvalidArgumentException If the value cannot be parsed into an array.
@return array|Traversable
Resolve the given value as a collection of values .