<commit_before><?php

namespace Soluble\FlexStore\Column\ColumnModel;

use Soluble\FlexStore\Column\ColumnModel\Search\Result;
use Soluble\FlexStore\Column\Exception;
use ArrayObject;

class Search
{

    /**
     *
     * @var ArrayObject
     */
    protected $columns;

    function __construct(ArrayObject $columns)
    {
        $this->columns = $columns;
    }

    /**
     *
     * @return Result
     */
    function all()
    {
        return new Result(array_keys((array) $this->columns), $this->columns);
    }

    /**
     *
     * @throws Exception\InvalidArgumentException
     * @return Result
     */
    function notIn(array $columns)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            if (!array_key_exists($name, $columns)) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @throws Exception\InvalidArgumentException
     * @return Result
     */
    function in(array $columns)
    {
        $results = array();
        foreach ($columns as $column) {
            $column = trim($column);
            if ($this->columns->offsetExists($column)) {
                $results[] = $column;
            } else {
                throw new Exception\InvalidArgumentException(__METHOD__ . " Column '$column' does not exists in column model.");
            }
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @return Result
     */
    function regexp($regexp)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            $column = trim($column);
            if (preg_match($regexp, $name)) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @param string $type
     * @return Result
     */
    function findByType($type)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            if ($column->getType() == $type) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }
}
<commit_msg>More permissive search->in method<commit_after><?php

namespace Soluble\FlexStore\Column\ColumnModel;

use Soluble\FlexStore\Column\ColumnModel\Search\Result;
use Soluble\FlexStore\Column\Exception;
use ArrayObject;

class Search
{

    /**
     *
     * @var ArrayObject
     */
    protected $columns;

    function __construct(ArrayObject $columns)
    {
        $this->columns = $columns;
    }

    /**
     *
     * @return Result
     */
    function all()
    {
        return new Result(array_keys((array) $this->columns), $this->columns);
    }

    /**
     *
     * @throws Exception\InvalidArgumentException
     * @return Result
     */
    function notIn(array $columns)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            if (!array_key_exists($name, $columns)) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @return Result
     */
    function in(array $columns)
    {
        $results = array();
        foreach ($columns as $column) {
            $column = trim($column);
            if ($this->columns->offsetExists($column)) {
                $results[] = $column;
            } 
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @return Result
     */
    function regexp($regexp)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            $column = trim($column);
            if (preg_match($regexp, $name)) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }

    /**
     *
     * @param string $type
     * @return Result
     */
    function findByType($type)
    {
        $results = array();
        foreach ($this->columns as $name => $column) {
            if ($column->getType() == $type) {
                $results[] = $name;
            }
        }
        return new Result($results, $this->columns);
    }
}

{'fraction_non_alphanumeric': 0.14349355216881593, 'fraction_numerical': 0.0, 'mean_word_length': 1.6830188679245284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '1854404', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1196, 'n_words': 253}