<commit_before><?php

/**
 * New BSD License
 *
 * Copyright (C) 2013 <NAME> (http://framework.koweb.ch) All rights reserved
 * See the LICENSE file for the full license text.
 */

Class ConfigEditor
{
	private $_file_path = '';
	private $_file_data = '';
	private $_array_depth = 0;

	public function __construct($file_path)
	{
		$this->_file_path = $file_path;
		if (is_file($this->_file_path))
			$this->_file_data = file_get_contents($this->_file_path);
	}

	public function to_text_array($value)
	{
		$arr = '';
		++$this->_array_depth;

		foreach ($value as $k => $v)
		{
			if (empty($arr))
				$arr .= "array(\r\n";

			for ($i = 0; $i < $this->_array_depth; ++$i)
				$arr .= '	';

			if (is_array($v))
				$arr .= ((is_string($k)) ? '\'' . $k . '\'' : $k) . ' => ' . $this->to_text_array($v);
			else
			{
				// Not very clean but constant function throw an excepetion if the constant doesn't exist...
				if (DEBUG_MODE)
					error_reporting(0);

				if (is_string($k))
				{
					$arr .= ((!constant($k)) ? '\'' . $k . '\'' : $k) . ' => ';
					$arr .= ((is_string($v)) ? '\'' . $v . '\'' : $v) . ",\r\n";
				}
				else
					$arr .= ((is_string($v) and !constant($v)) ? '\'' . $v . '\'' : $v) . ",\r\n";

				// Enable debug mode again
				if (DEBUG_MODE)
					error_reporting(E_ALL | E_STRICT);
			}
		}

		--$this->_array_depth;
		for ($i = 0; $i < $this->_array_depth; ++$i)
			$arr .= '	';

		$value = $arr . ')';
		if ($this->_array_depth != 0)
			$value .= "\r\n";<commit_msg>Support des constantes également pour les valeurs.<commit_after><?php

/**
 * New BSD License
 *
 * Copyright (C) 2013 <NAME> (http://framework.koweb.ch) All rights reserved
 * See the LICENSE file for the full license text.
 */

Class ConfigEditor
{
	private $_file_path = '';
	private $_file_data = '';
	private $_array_depth = 0;

	public function __construct($file_path)
	{
		$this->_file_path = $file_path;
		if (is_file($this->_file_path))
			$this->_file_data = file_get_contents($this->_file_path);
	}

	public function to_text_array($value)
	{
		$arr = '';
		++$this->_array_depth;

		foreach ($value as $k => $v)
		{
			if (empty($arr))
				$arr .= "array(\r\n";

			for ($i = 0; $i < $this->_array_depth; ++$i)
				$arr .= '	';

			if (is_array($v))
				$arr .= ((is_string($k)) ? '\'' . $k . '\'' : $k) . ' => ' . $this->to_text_array($v);
			else
			{
				// Not very clean but constant function throw an excepetion if the constant doesn't exist...
				if (DEBUG_MODE)
					error_reporting(0);

				if (is_string($k))
				{
					$arr .= ((!constant($k)) ? '\'' . $k . '\'' : $k) . ' => ';
					$arr .= ((is_string($v) and !constant($v)) ? '\'' . $v . '\'' : $v) . ",\r\n";
				}
				else
					$arr .= ((is_string($v) and !constant($v)) ? '\'' . $v . '\'' : $v) . ",\r\n";

				// Enable debug mode again
				if (DEBUG_MODE)
					error_reporting(E_ALL | E_STRICT);
			}
		}

		--$this->_array_depth;
		for ($i = 0; $i < $this->_array_depth; ++$i)
			$arr .= '	';

		$value = $arr . ')';
		if ($this->_array_depth != 0)
			$value .= "\r\n";
{'fraction_non_alphanumeric': 0.2261240564489662, 'fraction_numerical': 0.00590744995077125, 'mean_word_length': 2.619952494061758, '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': '5852927', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1180, 'n_words': 261}