<commit_before><?php
namespace Metabor\Chronology;
use MetaborStd\CallbackInterface;

/**
 * @author <NAME>
 *
 */
class CombineTimelinesIterator implements \Iterator
{

    /**
     * @var \SplObjectStorage
     */
    private $timelines;

    /**
     * @var \DateTime
     */
    private $currentDate;

    /**
     * 
     */
    public function __construct()
    {
        $this->timelines = new \SplObjectStorage();
    }

    /**
     * @param \Iterator $timeline
     */
    public function attach(\Iterator $timeline)
    {
        $this->timelines->attach($timeline);
    }

    /**
     * @param \Iterator $timeline
     */
    public function detach(\Iterator $timeline)
    {
        $this->timelines->detach($timeline);
    }

    /**
     * @see Iterator::current()
     */
    public function current()
    {
    	$date = $this->currentDate;
    	$callback = function (\Iterator $timeline) use ($date)
    	{
    		return ($timeline->valid()
    				&& ($timeline->current()->getDate() == $date));
    	};
    	return new \CallbackFilterIterator($this->timelines, $callback);
    }

    /**
     * current timestamp
     * (DateTime as key is invalid until PHP 5.5)
     * @see Iterator::key()
     */
    public function key()
    {
        return $this->currentDate->getTimestamp();
    }

    protected function determineCurrentDate()
    {
        $dates = array();
        foreach ($this->timelines as $timeline) {
        	if ($timeline->valid()) {
        		$dates[] = $timeline->current()->getDate();
        	}
        }
        $this->currentDate = min($dates);
    }

    /**
     * @see Iterator::next()
     */
    public function next()
    {
        foreach ($this->current() as $timeline) {
            $timeline->next();
        }
        $this->determineCurrent();
    }

    /**
     * @see Iterator::rewind()
     */
    public function rewind()
    {
        foreach ($this->timelines as $timeline) {
            $timeline->rewind();
        }
        $this->determineCurrent();
    }

    /**
     * @see Iterator::valid()
     */
    public function valid()
    {
        foreach ($this->timelines as $timeline) {
            if ($timeline->valid()) {
                return true;
            }
        }
        return false;
    }

}<commit_msg>removed unused USE<commit_after><?php
namespace Metabor\Chronology;

/**
 * @author <NAME>
 *
 */
class CombineTimelinesIterator implements \Iterator
{

    /**
     * @var \SplObjectStorage
     */
    private $timelines;

    /**
     * @var \DateTime
     */
    private $currentDate;

    /**
     * 
     */
    public function __construct()
    {
        $this->timelines = new \SplObjectStorage();
    }

    /**
     * @param \Iterator $timeline
     */
    public function attach(\Iterator $timeline)
    {
        $this->timelines->attach($timeline);
    }

    /**
     * @param \Iterator $timeline
     */
    public function detach(\Iterator $timeline)
    {
        $this->timelines->detach($timeline);
    }

    /**
     * @see Iterator::current()
     */
    public function current()
    {
    	$date = $this->currentDate;
    	$callback = function (\Iterator $timeline) use ($date)
    	{
    		return ($timeline->valid()
    				&& ($timeline->current()->getDate() == $date));
    	};
    	return new \CallbackFilterIterator($this->timelines, $callback);
    }

    /**
     * current timestamp
     * (DateTime as key is invalid until PHP 5.5)
     * @see Iterator::key()
     */
    public function key()
    {
        return $this->currentDate->getTimestamp();
    }

    protected function determineCurrentDate()
    {
        $dates = array();
        foreach ($this->timelines as $timeline) {
        	if ($timeline->valid()) {
        		$dates[] = $timeline->current()->getDate();
        	}
        }
        $this->currentDate = min($dates);
    }

    /**
     * @see Iterator::next()
     */
    public function next()
    {
        foreach ($this->current() as $timeline) {
            $timeline->next();
        }
        $this->determineCurrent();
    }

    /**
     * @see Iterator::rewind()
     */
    public function rewind()
    {
        foreach ($this->timelines as $timeline) {
            $timeline->rewind();
        }
        $this->determineCurrent();
    }

    /**
     * @see Iterator::valid()
     */
    public function valid()
    {
        foreach ($this->timelines as $timeline) {
            if ($timeline->valid()) {
                return true;
            }
        }
        return false;
    }
}

{'fraction_non_alphanumeric': 0.15628439357252916, 'fraction_numerical': 0.0008804754567466431, 'mean_word_length': 1.7775061124694376, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 55, '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': '3516027', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1345, 'n_words': 262}