<commit_before><?php
/*
*
* (c) <NAME> <<EMAIL>>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*
* Date: 08.02.2016
* Time: 15:08
*/

namespace Blast\Db\Entity;



use Blast\Db\DataConverterTrait;

class Collection implements CollectionInterface
{
    use DataConverterTrait;

    /**
     * @var EntityInterface[]
     */
    private $data = [];

    /**
     * EntityCollectionInterface constructor.
     * @param EntityInterface[] $data
     */
    public function __construct(array $data = [])
    {
        //check data and remove when value is no valid entity
        foreach($data as $key => $value){
            if(!($value instanceof EntityInterface)){
                unset($data[$key]);
            }
        }
        $this->data = $data;
    }

    /**
     * reset pointer on data
     */
    public function rewind() {
        reset($this->getData());
    }

    /**
     * Get current entity
     * @return EntityInterface
     */
    public function current() {
        return current($this->getData());
    }

    /**
     * Get current position
     * @return string|int
     */
    public function key() {
        return key($this->getData());
    }

    /**
     * Set pointer to next entity and return entity
     * @return mixed
     */
    public function next() {
        return next($this->getData());
    }

    /**
     * check if current value is valid
     * @return bool
     */
    public function valid() {
        return $this->current() !== false;
    }

    /**
     * get count of data
     *
     * @return int
     */
    public function count()
    {
        return count($this->getData());
    }

    /**
     * Filter containing entities
     *
     * @param callable $filter
     * @return EntityInterface[]
     */
    public function filter(callable $filter)
    {
        return array_filter($this->getData(), $filter, ARRAY_FILTER_USE_BOTH);
    }<commit_msg>Pass data by variable reference instead of calling data directly<commit_after><?php
/*
*
* (c) <NAME> <<EMAIL>>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*
* Date: 08.02.2016
* Time: 15:08
*/

namespace Blast\Db\Entity;



use Blast\Db\DataConverterTrait;

class Collection implements CollectionInterface
{
    use DataConverterTrait;

    /**
     * @var EntityInterface[]
     */
    private $data = [];

    /**
     * EntityCollectionInterface constructor.
     * @param EntityInterface[] $data
     */
    public function __construct(array $data = [])
    {
        //check data and remove when value is no valid entity
        foreach($data as $key => $value){
            if(!($value instanceof EntityInterface)){
                unset($data[$key]);
            }
        }
        $this->data = $data;
    }

    /**
     * reset pointer on data
     */
    public function rewind() {
        $data = $this->getData();
        reset($data);
    }

    /**
     * Get current entity
     * @return EntityInterface
     */
    public function current() {
        $data = $this->getData();
        return current($data);
    }

    /**
     * Get current position
     * @return string|int
     */
    public function key() {
        $data = $this->getData();
        return key($data);
    }

    /**
     * Set pointer to next entity and return entity
     * @return mixed
     */
    public function next() {
        $data = $this->getData();
        return next($data);
    }

    /**
     * check if current value is valid
     * @return bool
     */
    public function valid() {
        return $this->current() !== false;
    }

    /**
     * get count of data
     *
     * @return int
     */
    public function count()
    {
        return count($this->getData());
    }

    /**
     * Filter containing entities
     *
     * @param callable $filter
     * @return EntityInterface[]
     */
    public function filter(callable $filter)
    {
        return array_filter($this->getData(), $filter, ARRAY_FILTER_USE_BOTH);
    }
{'fraction_non_alphanumeric': 0.12896969696969696, 'fraction_numerical': 0.005818181818181818, 'mean_word_length': 1.9726224783861672, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '1328476', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1148, 'n_words': 325}