<commit_before><?php

class Config
{
    private static $instance;

    public $conf = array();

    /**
     * @static
     * @return Config
     */
    public static function getInstance()
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }
        return self::$instance;
    }


    private function __construct()
    {
        $this->buildConf();
    }

    public function buildConf()
    {
        $p = dirname(__FILE__).'/conf/';

        // First, we load the global configuration file
        $this->conf['GLOBAL_CONFIGURATION'] = parse_ini_file($p."conf.ini");

        if( is_file($p."localConf.ini") ) {
            $this->conf['GLOBAL_CONFIGURATION'] = array_merge( $this->conf['GLOBAL_CONFIGURATION'], parse_ini_file($p."localConf.ini") );
        }

        // We fix the data path here
        $this->conf['GLOBAL_CONFIGURATION']['data.path'] = realpath(dirname(__FILE__).'/../'.$this->conf['GLOBAL_CONFIGURATION']['data.path']).'/';

        // Second, we load all config project file
        $d = dir($p);
        while (false !== ($entry = $d->read())) {
            if( is_file($p.$entry) && ( $entry != 'conf.ini' && $entry != 'localConf.ini' ) ) {

               // Get the name of the project directly into the filename
               $t = explode(".", $entry);

               $this->conf[strtoupper($t[1])] = parse_ini_file($p.$entry);
            }
        }
        $d->close();

        // Third, we find all marks to be replace by a var from global_configuration array or current project<commit_msg>Allow to have a localConfiguration file for each project. For example, if you have a file named local.project.php.ini into conf directory, his content will override value from project.php.ini configuration file<commit_after><?php

class Config
{
    private static $instance;

    public $conf = array();

    /**
     * @static
     * @return Config
     */
    public static function getInstance()
    {
        if (!isset(self::$instance)) {
            $c = __CLASS__;
            self::$instance = new $c;
        }
        return self::$instance;
    }


    private function __construct()
    {
        $this->buildConf();
    }

    public function buildConf()
    {
        $p = dirname(__FILE__).'/conf/';

        // First, we load the global configuration file
        $this->conf['GLOBAL_CONFIGURATION'] = parse_ini_file($p."conf.ini");

        // Second, we try to load localConfiguration file
        // This file must have this name : localConf.ini
        if( is_file($p."localConf.ini") ) {
            $this->conf['GLOBAL_CONFIGURATION'] = array_merge( $this->conf['GLOBAL_CONFIGURATION'], parse_ini_file($p."localConf.ini") );
        }

        // We fix the data path here
        $this->conf['GLOBAL_CONFIGURATION']['data.path'] = realpath(dirname(__FILE__).'/../'.$this->conf['GLOBAL_CONFIGURATION']['data.path']).'/';

        // Second, we load all config project file
        $d = dir($p);
        while (false !== ($entry = $d->read())) {
            if( is_file($p.$entry) && ( $entry != 'conf.ini' && $entry != 'localConf.ini' ) ) {

               // Get the name of the project directly into the filename
               $t = explode(".", $entry);

               // First, we load the configuration file for this project
               $this->conf[strtoupper($t[1])] = parse_ini_file($p.$entry);
               
               // Second, we try to load a local configuration file for this project
               // This file must have this name, for example, PHP project : local.project.php.ini
               if( is_file($p.'local.'.$entry) ) {
                    $this->conf[strtoupper($t[1])] = array_merge( $this->conf[strtoupper($t[1])], parse_ini_file($p.'local.'.$entry) );
                }
               
            }
        }
        $d->close();

        // Third, we find all marks to be replace by a var from global_configuration array or current project
{'fraction_non_alphanumeric': 0.1498875843117662, 'fraction_numerical': 0.0009992505620784412, 'mean_word_length': 2.1135303265940903, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6383724', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1136, 'n_words': 298}