<commit_before><?php

/*
 * This file is a part of the Common Object library.
 *
 * (c) 2013 Ebidtech
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace EBT\CommonObject\Id;

use EBT\Validator\Model\Validator\Validator;
use EBT\CommonObject\Exception\InvalidArgumentException;

/**
 * IdSetFactory
 */
abstract class IdSetFactory
{
    /**
     * @param array $idsArr
     *
     * @return IdSet
     */
    public static function fromArray(array $idsArr)
    {
        $ids = array();

        foreach ($idsArr as $id) {
            $ids[] = static::fromId($id);
        }

        return static::fromIds($ids);
    }

    /**
     * @param string $idsStr Eg: '1, 3,  5, 10'
     *
     * @return IdSet
     *
     * @throws InvalidArgumentException
     */
    public static function fromString($idsStr)
    {
        if (!Validator::isRequiredString($idsStr)) {
            throw InvalidArgumentException::notString('ids', $idsStr);
        }

        $idsStr = preg_replace('/\s+/', '', $idsStr);

        $idsArr = $idsStr == '' ? array() : explode(IdSet::DELIMITER, $idsStr);

        return static::fromArray($idsArr);
    }<commit_msg>Changed validation on IdSetFactory to allow null values on fromString method<commit_after><?php

/*
 * This file is a part of the Common Object library.
 *
 * (c) 2013 Ebidtech
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace EBT\CommonObject\Id;

use EBT\Validator\Model\Validator\Validator;
use EBT\CommonObject\Exception\InvalidArgumentException;

/**
 * IdSetFactory
 */
abstract class IdSetFactory
{
    /**
     * @param array $idsArr
     *
     * @return IdSet
     */
    public static function fromArray(array $idsArr)
    {
        $ids = array();

        foreach ($idsArr as $id) {
            $ids[] = static::fromId($id);
        }

        return static::fromIds($ids);
    }

    /**
     * @param string $idsStr Eg: '1, 3,  5, 10'
     *
     * @return IdSet
     *
     * @throws InvalidArgumentException
     */
    public static function fromString($idsStr)
    {
        if (!Validator::isOptionalString($idsStr)) {
            throw InvalidArgumentException::notString('ids', $idsStr);
        }

        $idsStr = preg_replace('/\s+/', '', $idsStr);

        $idsArr = $idsStr == '' ? array() : explode(IdSet::DELIMITER, $idsStr);

        return static::fromArray($idsArr);
    }
{'fraction_non_alphanumeric': 0.13086322428064642, 'fraction_numerical': 0.007094994087504927, 'mean_word_length': 2.52990264255911, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139731', 'n_tokens_mistral': 774, 'n_tokens_neox': 740, 'n_words': 198}