<commit_before><?php
/**
 * This file is part of the SVN-Buddy library.
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 *
 * @copyright <NAME> <<EMAIL>>
 * @link      https://github.com/aik099/svn-buddy
 */

namespace aik099\SVNBuddy\Config;


class ConfigSetting
{

	const TYPE_STRING = 1;

	const TYPE_INTEGER = 2;

	const TYPE_ARRAY = 3;

	const SCOPE_GLOBAL = 1;

	const SCOPE_WORKING_COPY = 2;

	/**
	 * Scope.
	 *
	 * @var integer
	 */
	private $_scope;

	/**
	 * Name.
	 *
	 * @var string
	 */
	private $_name;

	/**
	 * Data type.
	 *
	 * @var integer
	 */
	private $_dataType;

	/**
	 * Default value.
	 *
	 * @var mixed
	 */
	private $_defaultValue;

	/**
	 * Config editor.
	 *
	 * @var ConfigEditor
	 */
	private $_editor;

	/**
	 * Working copy url.
	 *
	 * @var string
	 */
	private $_workingCopyUrl = '';

	/**
	 * Creates config setting instance.
	 *
	 * @param string  $name      Name.
	 * @param integer $data_type Data type.
	 * @param mixed   $default   Default value.
	 * @param integer $scope_bit Scope.
	 */
	public function __construct($name, $data_type, $default, $scope_bit = null)
	{
		$data_types = array(
			self::TYPE_STRING,
			self::TYPE_INTEGER,
			self::TYPE_ARRAY,
		);

		if ( !in_array($data_type, $data_types) ) {
			throw new \InvalidArgumentException('The "' . $data_type . '" is not valid config setting data type.');
		}

		$this->_dataType = $data_type;

		if ( !isset($scope_bit) ) {
			$scope_bit = self::SCOPE_WORKING_COPY;
		}

		// Always add global scope.
		$this->_scope = $scope_bit | self::SCOPE_GLOBAL;

		if ( !in_array($scope_bit, array(self::SCOPE_WORKING_COPY, self::SCOPE_GLOBAL)) ) {
			throw new \InvalidArgumentException('The $scope must be either "working copy" or "global".');
		}

		$this->_name = $name;
		$this->_defaultValue = $default;
	}

	/**
	 * Detects if config variable is within requested scope.
	 *
	 * @param integer $scope_bit Scope bit.
	 *
	 * @return boolean
	 */
	public function isWithinScope($scope_bit)
	{
		return ($this->_scope & $scope_bit) === $scope_bit;
	}

	/**
	 * Sets config editor.
	 *
	 * @param ConfigEditor $editor Config editor.
	 *
	 * @return void
	 */
	public function setEditor(ConfigEditor $editor)
	{
		$this->_editor = $editor;
	}
<commit_msg>Default config setting value is converted to storage format now<commit_after><?php
/**
 * This file is part of the SVN-Buddy library.
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 *
 * @copyright <NAME> <<EMAIL>>
 * @link      https://github.com/aik099/svn-buddy
 */

namespace aik099\SVNBuddy\Config;


class ConfigSetting
{

	const TYPE_STRING = 1;

	const TYPE_INTEGER = 2;

	const TYPE_ARRAY = 3;

	const SCOPE_GLOBAL = 1;

	const SCOPE_WORKING_COPY = 2;

	/**
	 * Scope.
	 *
	 * @var integer
	 */
	private $_scope;

	/**
	 * Name.
	 *
	 * @var string
	 */
	private $_name;

	/**
	 * Data type.
	 *
	 * @var integer
	 */
	private $_dataType;

	/**
	 * Default value.
	 *
	 * @var mixed
	 */
	private $_defaultValue;

	/**
	 * Config editor.
	 *
	 * @var ConfigEditor
	 */
	private $_editor;

	/**
	 * Working copy url.
	 *
	 * @var string
	 */
	private $_workingCopyUrl = '';

	/**
	 * Creates config setting instance.
	 *
	 * @param string  $name      Name.
	 * @param integer $data_type Data type.
	 * @param mixed   $default   Default value.
	 * @param integer $scope_bit Scope.
	 */
	public function __construct($name, $data_type, $default, $scope_bit = null)
	{
		$data_types = array(
			self::TYPE_STRING,
			self::TYPE_INTEGER,
			self::TYPE_ARRAY,
		);

		if ( !in_array($data_type, $data_types) ) {
			throw new \InvalidArgumentException('The "' . $data_type . '" is not valid config setting data type.');
		}

		$this->_dataType = $data_type;

		if ( !isset($scope_bit) ) {
			$scope_bit = self::SCOPE_WORKING_COPY;
		}

		// Always add global scope.
		$this->_scope = $scope_bit | self::SCOPE_GLOBAL;

		if ( !in_array($scope_bit, array(self::SCOPE_WORKING_COPY, self::SCOPE_GLOBAL)) ) {
			throw new \InvalidArgumentException('The $scope must be either "working copy" or "global".');
		}

		$this->_name = $name;
		$this->_defaultValue = $this->_convertToScalarValue($this->_normalizeValue($default));
	}

	/**
	 * Detects if config variable is within requested scope.
	 *
	 * @param integer $scope_bit Scope bit.
	 *
	 * @return boolean
	 */
	public function isWithinScope($scope_bit)
	{
		return ($this->_scope & $scope_bit) === $scope_bit;
	}

	/**
	 * Sets config editor.
	 *
	 * @param ConfigEditor $editor Config editor.
	 *
	 * @return void
	 */
	public function setEditor(ConfigEditor $editor)
	{
		$this->_editor = $editor;
	}

{'fraction_non_alphanumeric': 0.13937867338371115, 'fraction_numerical': 0.004617968094038623, 'mean_word_length': 3.0866209262435675, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, 'https://': 2, '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': '1771245', 'n_tokens_mistral': 1787, 'n_tokens_neox': 1570, 'n_words': 419}