<commit_before><?php

class CM_Params extends CM_Class_Abstract {

	/**  @var array */
	private $_paramsOriginal = array();

	/**  @var array */
	private $_params = array();

	/** @var bool */
	private $_decode;

	/**
	 * @param array|null $params
	 * @param bool       $decode OPTIONAL
	 */
	public function __construct(array $params = null, $decode = true) {
		$this->_decode = (bool) $decode;
		$this->_paramsOriginal = (array) $params;
		$this->_params = (array) $params;
		if ($this->_decode) {
			foreach ($this->_params as $key => &$param) {
				$param = self::decode($param);
			}
		}
	}

	/**
	 * @param string     $key
	 * @param mixed|null $default
	 * @return mixed
	 */
	public function get($key, $default = null) {
		return $this->_get($key, $default);
	}

	/**
	 * @param string $key
	 * @param mixed  $value
	 */
	public function set($key, $value) {
		if ($this->_decode) {
			$value = self::decode($value);
		}
		$this->_params[$key] = $value;
	}

	/**
	 * @param string $key
	 * @return bool
	 */
	public function has($key) {
		return (array_key_exists($key, $this->_params) && null !== $this->_params[$key]);
	}

	/**
	 * @return array
	 */
	public function getAll() {
		return $this->_params;
	}

	/**
	 * @return array
	 */
	public function getAllOriginal() {
		return $this->_paramsOriginal;
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return float
	 */
	public function getFloat($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getFloat($param);
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return string
	 */
	public function getString($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getString($param);
	}

	/**
	 * @param string        $key
	 * @param string[]|null $default
	 * @return string[]
	 */
	public function getStringArray($key, array $default = null) {
		return array_map(array($this, '_getString'), $this->getArray($key, $default));
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return int
	 */
	public function getInt($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getInt($param);
	}

	/**
	 * @param string      $key
	 * @param int[]|null  $default
	 * @return int[]
	 */
	public function getIntArray($key, array $default = null) {
		return array_map(array($this, '_getInt'), $this->getArray($key, $default));
	}

	/**
	 * @param string $key
	 * @param array  $default
	 * @return array
	 * @throws CM_Exception_InvalidParam
	 */
	public function getArray($key, array $default = null) {
		$param = $this->_get($key, $default);
		if (!is_array($param)) {
			throw new CM_Exception_InvalidParam('Not an Array');
		}
		return (array) $param;
	}

	/**
	 * @param string  $key
	 * @param boolean $default
	 * @return boolean
	 * @throws CM_Exception_InvalidParam
	 */
	public function getBoolean($key, $default = null) {
		$param = $this->_get($key, $default);
		if (1 === $param || '1' === $param || 'true' === $param) {
			$param = true;
		}
		if (0 === $param || '0' === $param || 'false' === $param) {
			$param = false;
		}
		if (!is_bool($param)) {
			throw new CM_Exception_InvalidParam('Not a boolean');
		}
		return (boolean) $param;
	}

	/**
	 * @param string   $key
	 * @param int|null $default
	 * @return int
	 */
	public function getPage($key = 'page', $default = null) {
		if (null === $default) {
			$default = 1;
		}
		$page = $this->getInt($key, $default);
		$page = min(1000, $page);
		$page = max(1, $page);
		return $page;
	}

	/**
	 * @param string       $key
	 * @param string       $className<commit_msg>Add getDateTime<commit_after><?php

class CM_Params extends CM_Class_Abstract {

	/**  @var array */
	private $_paramsOriginal = array();

	/**  @var array */
	private $_params = array();

	/** @var bool */
	private $_decode;

	/**
	 * @param array|null $params
	 * @param bool       $decode OPTIONAL
	 */
	public function __construct(array $params = null, $decode = true) {
		$this->_decode = (bool) $decode;
		$this->_paramsOriginal = (array) $params;
		$this->_params = (array) $params;
		if ($this->_decode) {
			foreach ($this->_params as $key => &$param) {
				$param = self::decode($param);
			}
		}
	}

	/**
	 * @param string     $key
	 * @param mixed|null $default
	 * @return mixed
	 */
	public function get($key, $default = null) {
		return $this->_get($key, $default);
	}

	/**
	 * @param string $key
	 * @param mixed  $value
	 */
	public function set($key, $value) {
		if ($this->_decode) {
			$value = self::decode($value);
		}
		$this->_params[$key] = $value;
	}

	/**
	 * @param string $key
	 * @return bool
	 */
	public function has($key) {
		return (array_key_exists($key, $this->_params) && null !== $this->_params[$key]);
	}

	/**
	 * @return array
	 */
	public function getAll() {
		return $this->_params;
	}

	/**
	 * @return array
	 */
	public function getAllOriginal() {
		return $this->_paramsOriginal;
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return float
	 */
	public function getFloat($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getFloat($param);
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return string
	 */
	public function getString($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getString($param);
	}

	/**
	 * @param string        $key
	 * @param string[]|null $default
	 * @return string[]
	 */
	public function getStringArray($key, array $default = null) {
		return array_map(array($this, '_getString'), $this->getArray($key, $default));
	}

	/**
	 * @param string      $key
	 * @param string|null $default
	 * @return int
	 */
	public function getInt($key, $default = null) {
		$param = $this->_get($key, $default);
		return $this->_getInt($param);
	}

	/**
	 * @param string      $key
	 * @param int[]|null  $default
	 * @return int[]
	 */
	public function getIntArray($key, array $default = null) {
		return array_map(array($this, '_getInt'), $this->getArray($key, $default));
	}

	/**
	 * @param string $key
	 * @param array  $default
	 * @return array
	 * @throws CM_Exception_InvalidParam
	 */
	public function getArray($key, array $default = null) {
		$param = $this->_get($key, $default);
		if (!is_array($param)) {
			throw new CM_Exception_InvalidParam('Not an Array');
		}
		return (array) $param;
	}

	/**
	 * @param string  $key
	 * @param boolean $default
	 * @return boolean
	 * @throws CM_Exception_InvalidParam
	 */
	public function getBoolean($key, $default = null) {
		$param = $this->_get($key, $default);
		if (1 === $param || '1' === $param || 'true' === $param) {
			$param = true;
		}
		if (0 === $param || '0' === $param || 'false' === $param) {
			$param = false;
		}
		if (!is_bool($param)) {
			throw new CM_Exception_InvalidParam('Not a boolean');
		}
		return (boolean) $param;
	}

	/**
	 * @param string $key
	 * @return DateTime
	 */
	public function getDateTime($key) {
		return $this->_getObject($key, 'DateTime');
	}

	/**
	 * @param string   $key
	 * @param int|null $default
	 * @return int
	 */
	public function getPage($key = 'page', $default = null) {
		if (null === $default) {
			$default = 1;
		}
		$page = $this->getInt($key, $default);
		$page = min(1000, $page);
		$page = max(1, $page);
		return $page;
	}

	/**
	 * @param string       $key
	 * @param string       $className
{'fraction_non_alphanumeric': 0.18683680322364002, 'fraction_numerical': 0.002686366689053056, 'mean_word_length': 3.2020316027088036, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, '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': '4375773', 'n_tokens_mistral': 2744, 'n_tokens_neox': 2480, 'n_words': 637}