<commit_before><?php
require_once 'Yadif_Exception.php';

class Yadif_Container
{
	const CONFIG_CLASS = 'class';

	const CONFIG_ARGUMENTS = 'arguments';

	protected $_container = array();

	protected function _validateArg($arg, $argVar, $type)
	{
		$isTypes = array('array', 'bool', 'float', 'int', 'null', 'numeric', 'object',
						 'resource', 'scalar', 'string');

		if (in_array($type, $isTypes)) $isType = "is_$type";

		if (!$isType($arg))
			throw new Yadif_Exception($argVar . ' must be ' . $type . ', is ' . gettype($arg));

		return $arg;
	}

	public function __construct(array $config = null)
	{
		$config = $this->_validateArg($config, '$config', 'array');

		foreach ($config as $componentName => $componentConfig) {
			$this->addComponent( $componentName, $componentConfig );
		}
	}
	
	public function addComponent($name = null, array $config = null)
	{
		$name = $this->_validateArg($name, '$name', 'string');

		$config = $this->_validateArg($config, '$config', 'array');

		if (!class_exists( $config[self::CONFIG_CLASS] ))<commit_msg>small container constructor fix<commit_after><?php
require_once 'Yadif_Exception.php';

class Yadif_Container
{
	const CONFIG_CLASS = 'class';

	const CONFIG_ARGUMENTS = 'arguments';

	protected $_container = array();

	protected function _validateArg($arg, $argVar, $type)
	{
		$isTypes = array('array', 'bool', 'float', 'int', 'null', 'numeric', 'object',
						 'resource', 'scalar', 'string');

		if (in_array($type, $isTypes)) $isType = "is_$type";

		if (!$isType($arg))
			throw new Yadif_Exception($argVar . ' must be ' . $type . ', is ' . gettype($arg));

		return $arg;
	}

	public function __construct(array $config = null)
	{
		if (isset($array)) {
			$config = $this->_validateArg($config, '$config', 'array');

			foreach ($config as $componentName => $componentConfig) {
				$this->addComponent( $componentName, $componentConfig );
			}
		}
	}
	
	public function addComponent($name = null, array $config = null)
	{
		$name = $this->_validateArg($name, '$name', 'string');

		$config = $this->_validateArg($config, '$config', 'array');

		if (!class_exists( $config[self::CONFIG_CLASS] ))
{'fraction_non_alphanumeric': 0.1842227378190255, 'fraction_numerical': 0.0, 'mean_word_length': 4.827027027027027, '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': '1413533', 'n_tokens_mistral': 766, 'n_tokens_neox': 699, 'n_words': 169}