<commit_before><?php
/******************************************************************************
 * An implementation of the "Formlets"-abstraction in PHP.
 * Copyright (c) 2014, 2015 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received 
 * a copy of the along with the code.
 */

/*
 * The NameSource is used to create unique names for every input. This is 
 * needed for composability of the Formlets without the need to worry about
 * names.
 * It should only be instantiated once per process. Unsafe should only be used
 * for testing or debugging.
 */

final class NameSource {
    private $_i;
    private $_used = false;
    private $_prefix;
    static private $_instantiated = false;
    
    public static function instantiate($prefix) {
        if (static::$_instantiated) {
            throw new Exception("NameSource can only be instantiated once.");
        }
        return new NameSource(0, $prefix);
    } 

    private function __construct($i, $prefix) {
        $this->_i = $i;
        $this->_prefix = $prefix;
    }

    public function getNameAndNext() {
        if ($this->_used) {
            throw new Exception("NameSource can only be used once.");
        }

        $this->_used = true;
        return array
            ( "name" => $this->_prefix."_input_".$this->_i
            , "name_source" => new NameSource($this->_i + 1, $this->_prefix)
            );
    }
}

?>
<commit_msg>correct namespacing<commit_after><?php
/******************************************************************************
 * An implementation of the "Formlets"-abstraction in PHP.
 * Copyright (c) 2014, 2015 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received 
 * a copy of the along with the code.
 */

namespace Lechimp\Formlets\Internal;

/*
 * The NameSource is used to create unique names for every input. This is 
 * needed for composability of the Formlets without the need to worry about
 * names.
 * It should only be instantiated once per process. Unsafe should only be used
 * for testing or debugging.
 */

final class NameSource {
    private $_i;
    private $_used = false;
    private $_prefix;
    static private $_instantiated = false;
    
    public static function instantiate($prefix) {
        if (static::$_instantiated) {
            throw new Exception("NameSource can only be instantiated once.");
        }
        return new NameSource(0, $prefix);
    } 

    private function __construct($i, $prefix) {
        $this->_i = $i;
        $this->_prefix = $prefix;
    }

    public function getNameAndNext() {
        if ($this->_used) {
            throw new Exception("NameSource can only be used once.");
        }

        $this->_used = true;
        return array
            ( "name" => $this->_prefix."_input_".$this->_i
            , "name_source" => new NameSource($this->_i + 1, $this->_prefix)
            );
    }
}

?>

{'fraction_non_alphanumeric': 0.15563808237677246, 'fraction_numerical': 0.00675219446320054, 'mean_word_length': 2.6625463535228677, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, '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': '2616405', 'n_tokens_mistral': 818, 'n_tokens_neox': 769, 'n_words': 285}