public static function toArray($value)
    {
        if (is_array($value)) {
            return $value;
        }

        if ($value === null) {
            return [];
        }

        if (!$value instanceof Traversable) {
            throw new Exception\InvalidArgumentException(
                'An invalid value was provided, should either be an null, array or Traversable'
            );
        }

        return iterator_to_array($value);
    }