<commit_before><?php
namespace Sandhje\Spanner\Environment;

/**
 *
 * @author Sandhje
 *        
 */
class EnvironmentIterator implements \Iterator
{
    /**
     * Iterator source
     *
     * @var array
     */
    private $data;
    
    public function __construct(array $data)
    {
        $this->data = [];
        
        for($segment = 0; $segment < count($data); $segment++) {
            for($cycle = 0; $cycle <= $segment; $cycle++) {
                $cycleData = array_filter(array_flip($data), function($value) use ($segment, $cycle) {
                    if($segment == $value) return true; // Include the segment itself
                    if($value < $cycle) return true; // Include higher level environments
                    return false;
                });
                $this->data[] = array_values(array_intersect_key($data, array_flip($cycleData)));
            };
        }
    }
    
    /**
     * {@inheritDoc}
     * @see Iterator::current()
     */
    public function current()
    {
        return current($this->data);<commit_msg>Fix usage of function in loop<commit_after><?php
namespace Sandhje\Spanner\Environment;

/**
 *
 * @author Sandhje
 *        
 */
class EnvironmentIterator implements \Iterator
{
    /**
     * Iterator source
     *
     * @var array
     */
    private $data;
    
    public function __construct(array $data)
    {
        $this->data = [];
        
        $dataCount = count($data);
        for($segment = 0; $segment < $dataCount; $segment++) {
            for($cycle = 0; $cycle <= $segment; $cycle++) {
                $cycleData = array_filter(array_flip($data), function($value) use ($segment, $cycle) {
                    if($segment == $value) return true; // Include the segment itself
                    if($value < $cycle) return true; // Include higher level environments
                    return false;
                });
                $this->data[] = array_values(array_intersect_key($data, array_flip($cycleData)));
            };
        }
    }
    
    /**
     * {@inheritDoc}
     * @see Iterator::current()
     */
    public function current()
    {
        return current($this->data);
{'fraction_non_alphanumeric': 0.1397898583828232, 'fraction_numerical': 0.001827318410232983, 'mean_word_length': 1.8258064516129033, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '1773960', 'n_tokens_mistral': 612, 'n_tokens_neox': 589, 'n_words': 136}