<commit_before><?php
namespace Asgard\Config;

class Config extends \Asgard\Common\Bag {
	public function loadConfigDir($dir, $env=null) {
		foreach(glob($dir.'/*.yml') as $filename) {
			if(is_dir($filename))
				$this->loadConfigDir($filename);
			else {
				$basename = basename($filename);
				if(preg_match('/^[^_]+.[^.]+$/', $basename))
					$this->loadConfigFile($filename);
				if($env !== null && preg_match('/^.+_'.$env.'.[^.]+$/', $basename))
					$this->loadConfigFile($filename);
			}
		}
		return $this;
	}
	
	public function loadConfigFile($filename) {
		$yaml = new \Symfony\Component\Yaml\Parser();
		if(($r = file_get_contents($filename))) {
			if(is_array($res = $yaml->parse($r)))
				$this->load($res);
		}
		return $this;
	}
}<commit_msg>config docblocks<commit_after><?php
namespace Asgard\Config;

/**
 * Configuration bag.
 */
class Config extends \Asgard\Common\Bag {
	/**
	 * Load a directory.
	 * @param  string $dir
	 * @param  string $env
	 * @return Config      $this
	 */
	public function loadConfigDir($dir, $env=null) {
		foreach(glob($dir.'/*.yml') as $filename) {
			if(is_dir($filename))
				$this->loadConfigDir($filename);
			else {
				$basename = basename($filename);
				if(preg_match('/^[^_]+.[^.]+$/', $basename))
					$this->loadConfigFile($filename);
				if($env !== null && preg_match('/^.+_'.$env.'.[^.]+$/', $basename))
					$this->loadConfigFile($filename);
			}
		}
		return $this;
	}
	
	/**
	 * Load a file.
	 * @param  string $filename
	 * @return Confug $this
	 */
	public function loadConfigFile($filename) {
		$yaml = new \Symfony\Component\Yaml\Parser();
		if(($r = file_get_contents($filename))) {
			if(is_array($res = $yaml->parse($r)))
				$this->load($res);
		}
		return $this;
	}
}
{'fraction_non_alphanumeric': 0.206401766004415, 'fraction_numerical': 0.0, 'mean_word_length': 3.0833333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3170048', 'n_tokens_mistral': 730, 'n_tokens_neox': 619, 'n_words': 108}