<commit_before><?php

namespace Zicht\Itertools\lib;

// todo: add tests

use Closure;
use Iterator;
use FilterIterator as BaseFilterIterator;

class FilterIterator extends BaseFilterIterator
{
    private $func;

    function __construct(Closure $func, Iterator $iterable)
    {
        $this->func = $func;
        parent::__construct($iterable);
    }

    public function accept()
    {
        return call_user_func($this->func, $this->current());
    }

    public function toArray()
    {
        return iterator_to_array($this);
    }<commit_msg>adds Countable interface to FilterIterator<commit_after><?php

namespace Zicht\Itertools\lib;

// todo: add tests

use Closure;
use Countable;
use Iterator;
use FilterIterator as BaseFilterIterator;

class FilterIterator extends BaseFilterIterator implements Countable
{
    private $func;

    function __construct(Closure $func, Iterator $iterable)
    {
        $this->func = $func;
        parent::__construct($iterable);
    }

    public function accept()
    {
        return call_user_func($this->func, $this->current());
    }

    /**
     * Count elements of an object
     * @link http://php.net/manual/en/countable.count.php
     * @return int The custom count as an integer.
     * </p>
     * <p>
     * The return value is cast to an integer.
     * @since 5.1.0
     */
    public function count()
    {
        return iterator_count($this);
    }

    public function toArray()
    {
        return iterator_to_array($this);
    }
{'fraction_non_alphanumeric': 0.10785619174434088, 'fraction_numerical': 0.0019973368841544607, 'mean_word_length': 2.7763819095477387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2755074', 'n_tokens_mistral': 454, 'n_tokens_neox': 441, 'n_words': 118}