<commit_before><?php

namespace Sokil\Rest\Transport;

class StructureList implements \SeekableIterator, \Countable
{
    private $_list = array();
    
    private $_index = 0;
    
    protected $_structureClassName = '\Sokil\Rest\Transport\Structure';
    
    public function __construct(array $list = null, $structureClassName = null)
    {
        if($list) {
            $this->_list = $list;
        }
        
        if($structureClassName) {
            $this->_structureClassName = $structureClassName;
        }
    }
    
    private function _getStructureClassName(array $data)
    {
        if(is_callable($this->_structureClassName)) {
            $classNameGenerator = $this->_structureClassName;
            return $classNameGenerator($data);
        } else {
            return $this->_structureClassName;
        }
    }
    
    public function setFromArray(array $list)
    {
        $this->_list = $list;
        return $this;
    }
    
    /**
     * 
     * @return \Sokil\Rest\StructureList
     */
    public function current()
    {
        $data = $this->_list[$this->_index];
        $className = $this->_getStructureClassName($data);
        
        return new $className($data);
    }
    
    public function next()
    {
        $this->_index++;
    }
    
    public function valid()
    {
        return isset($this->_list[$this->_index]);
    }
    
    public function key()
    {
        return $this->_index;
    }
    
    public function rewind()
    {
        $this->_index = 0;
    }
    
    public function seek($index)<commit_msg>fix getting current structure<commit_after><?php

namespace Sokil\Rest\Transport;

class StructureList implements \SeekableIterator, \Countable
{
    private $_list = array();
    
    private $_index = 0;
    
    protected $_structureClassName = '\Sokil\Rest\Transport\Structure';
    
    public function __construct(array $list = null, $structureClassName = null)
    {
        if($list) {
            $this->_list = $list;
        }
        
        if($structureClassName) {
            $this->_structureClassName = $structureClassName;
        }
    }
    
    private function _getStructureClassName(array $data)
    {
        if(is_callable($this->_structureClassName)) {
            $classNameGenerator = $this->_structureClassName;
            return $classNameGenerator($data);
        } else {
            return $this->_structureClassName;
        }
    }
    
    public function setFromArray(array $list)
    {
        $this->_list = $list;
        return $this;
    }
    
    /**
     * 
     * @return \Sokil\Rest\StructureList
     */
    public function current()
    {
        if(!isset($this->_list[$this->_index])) {
            return null;
        }
        
        $data = $this->_list[$this->_index];
        $className = $this->_getStructureClassName($data);
        
        return new $className($data);
    }
    
    public function next()
    {
        $this->_index++;
    }
    
    public function valid()
    {
        return isset($this->_list[$this->_index]);
    }
    
    public function key()
    {
        return $this->_index;
    }
    
    public function rewind()
    {
        $this->_index = 0;
    }
    
    public function seek($index)
{'fraction_non_alphanumeric': 0.12048929663608562, 'fraction_numerical': 0.0012232415902140672, 'mean_word_length': 1.869298245614035, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '662765', 'n_tokens_mistral': 911, 'n_tokens_neox': 905, 'n_words': 173}