<commit_before><?php

namespace webignition\CharacterSetList;

/**
 * List of official names for character sets as sourced from
 * http://www.iana.org/assignments/character-sets/character-sets.xhtml
 */
class CharacterSetList {
    
    /**
     *
     * @var \webignition\CharacterSetList\Configuration
     */
    private $configuration; 
    
    
    /**
     *
     * @var array
     */
    private $list = null;
    
    
    /**
     *
     * @var array
     */
    private $index = null;
    
    
    /**
     * 
     * @return \webignition\CharacterSetList\Configuration
     */
    public function getConfiguration() {
        if (is_null($this->configuration)) {
            $this->configuration = new Configuration();
        }
        
        return $this->configuration;
    }
    
    
    /**
     * 
     * @return array
     */
    public function get() {
        if (is_null($this->list)) {
            $this->loadList();            
        }
        
        return $this->list;
    }
    
    
    /**
     * 
     * @param string $name
     * @return boolean
     */
    public function contains($name) {
        return array_key_exists(strtolower($name), $this->getIndex());
    }
    
    
    /**
     * 
     * @return boolean
     */
    private function hasSourceFile() {
        return file_exists($this->getConfiguration()->getOutputContentPath());
    }
    
    
    private function loadList() {
        if (!$this->hasSourceFile()) {
            $generator = new Generator();
            $generator->generate();
        }

        $this->list = json_decode(file_get_contents($this->getConfiguration()->getOutputContentPath()));        
    }
    
    
    /**
     * 
     * @return array
     */
    private function getIndex() {
        if (is_null($this->index)) {
            $this->buildIndex();
        }
        
        return $this->index;
    }
    
    
    private function buildIndex() {
        $this->index = array();
        
        foreach ($this->get() as $name) {
            $this->index[strtolower($name)] = true;
        }
    }
    
}<commit_msg>Expost list generator; use generator config only<commit_after><?php

namespace webignition\CharacterSetList;

/**
 * List of official names for character sets as sourced from
 * http://www.iana.org/assignments/character-sets/character-sets.xhtml
 */
class CharacterSetList {
    
    
    /**
     *
     * @var array
     */
    private $list = null;
    
    
    /**
     *
     * @var array
     */
    private $index = null;
    
    
    /**
     *
     * @var \webignition\CharacterSetList\Generator
     */
    private $generator = null;
    
    
    /**
     * 
     * @return \webignition\CharacterSetList\Configuration
     */
    public function getConfiguration() {
        return $this->getGenerator()->getConfiguration();
    }
    
    
    /**
     * 
     * @return array
     */
    public function get() {
        if (is_null($this->list)) {
            $this->loadList();            
        }
        
        return $this->list;
    }
    
    
    /**
     * 
     * @param string $name
     * @return boolean
     */
    public function contains($name) {
        return array_key_exists(strtolower($name), $this->getIndex());
    }
    
    
    /**
     * 
     * @return boolean
     */
    private function hasSourceFile() {
        return file_exists($this->getConfiguration()->getOutputContentPath());
    }
    
    
    private function loadList() {
        if (!$this->hasSourceFile()) {
            $this->getGenerator()->generate();
        }

        $this->list = json_decode(file_get_contents($this->getConfiguration()->getOutputContentPath()));        
    }
    
    
    /**
     * 
     * @return \webignition\CharacterSetList\Generator
     */
    public function getGenerator() {
        if (is_null($this->generator)) {
            $this->generator = new Generator();
        }
        
        return $this->generator;
    }
    
    
    /**
     * 
     * @return array
     */
    private function getIndex() {
        if (is_null($this->index)) {
            $this->buildIndex();
        }
        
        return $this->index;
    }
    
    
    private function buildIndex() {
        $this->index = array();
        
        foreach ($this->get() as $name) {
            $this->index[strtolower($name)] = true;
        }
    }
    
}
{'fraction_non_alphanumeric': 0.13560864618885096, 'fraction_numerical': 0.0, 'mean_word_length': 1.5587892898719442, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5896229', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1255, 'n_words': 215}