<commit_before><?php
namespace ay\vlad;

abstract class Validator {
	protected
		$options = [],
		$messages = [];
	
	/**
	 * @throws BadMethodCallException if either of the $options argument properties do not already exist in the instance $options array.
	 */
	final public function __construct (array $options = []) {
		$unrecognised_options = \array_diff_key($options, $this->options);
		
		if ($unrecognised_options) {
			throw new \BadMethodCallException('Unrecognised options: ' . implode(', ', array_keys($unrecognised_options)) . '.');
		}
		
		$this->options = $options + $this->options;
	}

	/**
	 * @return array
	 */
	final public function getOptions () {
		return $this->options;
	}

	/**
	 * @throws Exception if $error_name is undefined in the $messages array.
	 * @param string $error_name
	 * @return string
	 */
	final public function getMessage ($error_name) {
		if (!isset($this->messages[$error_name])) {
			throw new \Exception('Undefined error message "' . $error_name . '".');
		}
		
		return $this->messages[$error_name];
	}
	
	abstract public function validate (Subject $subject);
}<commit_msg>Validator  separated into  and . Restricted direct access to the  array.<commit_after><?php
namespace ay\vlad;

abstract class Validator {
	private
		$instance_options = [];
	
	protected
		$default_options = [],
		$messages = [];
	
	/**
	 * @throws BadMethodCallException if either of the $options argument properties do not already exist in the instance $options array.
	 */
	final public function __construct (array $options = []) {
		$unrecognised_options = \array_diff_key($options, $this->default_options);
		
		if ($unrecognised_options) {
			throw new \BadMethodCallException('Unrecognised options: ' . implode(', ', array_keys($unrecognised_options)) . '.');
		}
		
		$this->instance_options = $options + $this->default_options;
	}

	/**
	 * @return array
	 */
	final public function getOptions () {
		return $this->instance_options;
	}

	/**
	 * @throws Exception if $error_name is undefined in the $messages array.
	 * @param string $error_name
	 * @return string
	 */
	final public function getMessage ($error_name) {
		if (!isset($this->messages[$error_name])) {
			throw new \Exception('Undefined error message "' . $error_name . '".');
		}
		
		return $this->messages[$error_name];
	}
	
	abstract public function validate (Subject $subject);
}
{'fraction_non_alphanumeric': 0.1351010101010101, 'fraction_numerical': 0.0, 'mean_word_length': 4.00421052631579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '5175157', 'n_tokens_mistral': 756, 'n_tokens_neox': 682, 'n_words': 193}