Helper/Text.php
public static function getIdListFromString($string)
    {
        if (filter_var($string, FILTER_VALIDATE_INT) !== false) {
            return array($string);
        }

        return array_map(
            function ($id) {
                if (false === filter_var($id, FILTER_VALIDATE_INT)) {
                    throw new InvalidArgumentException('String should be a list of Integers');
                }

                return (int) $id;
            },
            explode(',', $string)
        );
    }
public static function getIdListFromString($string)
    {
        if (filter_var($string, FILTER_VALIDATE_INT) !== false) {
            return array($string);
        }

        return array_map(
            function ($id) {
                if (false === filter_var($id, FILTER_VALIDATE_INT)) {
                    throw new InvalidArgumentException('String should be a list of Integers');
                }

                return (int) $id;
            },
            explode(',', $string)
        );
    }
public static function getIdListFromString ( $ string ) { if ( filter_var ( $ string , FILTER_VALIDATE_INT ) !== false ) { return array ( $ string ) ; } return array_map ( function ( $ id ) { if ( false === filter_var ( $ id , FILTER_VALIDATE_INT ) ) { throw new InvalidArgumentException ( 'String should be a list of Integers' ) ; } return ( int ) $ id ; } , explode ( ',' , $ string ) ) ; }
Preparing array of integers based on comma separated integers in string or single integer in string.

@param string $string list of integers separated by comma character

@return array

@throws InvalidArgumentException If incorrect $list value is given
Preparing array of integers based on comma separated integers in string or single integer in string .