<commit_before>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 +------------------------------------------------------------------------+
 */

namespace Phalcon\Mvc\Model;

use Phalcon\Mvc\Model\Message;

/**
 * Phalcon\Mvc\Model\Validator
 *
 * This is a base class for Phalcon\Mvc\Model validators
 */
abstract class Validator
{

	protected _options;

	protected _messages = [];

	/**
	 * Phalcon\Mvc\Model\Validator constructor
	 */
	public function __construct(array! options)
	{
		let this->_options = options;
	}

	/**
	 * Appends a message to the validator
	 *
	 * @param string message
	 * @param string|array field
	 * @param string type
	 */
	protected function appendMessage(string! message, field = null, type = null)
	{
		if !type {
			let type = str_replace("Validator", "", get_class(this));
		}
		let this->_messages[] = new Message(message, field, type);
	}

	/**
	 * Returns messages generated by the validator
	 */
	public function getMessages() -> array
	{
		return this->_messages;
	}

	/**
	 * Returns all the options from the validator
	 *
	 * @return array
	 */
	protected function getOptions()
	{
		return this->_options;
	}

	/**
	 * Returns an option
	 *
	 * @param	string option
	 * @return	mixed
	 */
	protected function getOption(string! option)
	{
		var options, value;
		let options = this->_options;
		if fetch value, options[option] {
			return value;
		}
		return "";
	}

	/**
	 * Check whether a option has been defined in the validator options
	 */
	protected function isSetOption(string! option) -> boolean
	{
		return isset this->_options[option];
	}
}<commit_msg>Fixes #10520<commit_after>
/*
 +------------------------------------------------------------------------+
 | Phalcon Framework                                                      |
 +------------------------------------------------------------------------+
 | Copyright (c) 2011-2015 Phalcon Team (http://www.phalconphp.com)       |
 +------------------------------------------------------------------------+
 | This source file is subject to the New BSD License that is bundled     |
 | with this package in the file docs/LICENSE.txt.                        |
 |                                                                        |
 | If you did not receive a copy of the license and are unable to         |
 | obtain it through the world-wide-web, please send an email             |
 | to <EMAIL> so we can send you a copy immediately.       |
 +------------------------------------------------------------------------+
 | Authors: <NAME> <<EMAIL>>                      |
 |          <NAME> <<EMAIL>>                         |
 +------------------------------------------------------------------------+
 */

namespace Phalcon\Mvc\Model;

use Phalcon\Mvc\Model\Message;

/**
 * Phalcon\Mvc\Model\Validator
 *
 * This is a base class for Phalcon\Mvc\Model validators
 */
abstract class Validator
{

	protected _options;

	protected _messages = [];

	/**
	 * Phalcon\Mvc\Model\Validator constructor
	 */
	public function __construct(array! options)
	{
		let this->_options = options;
	}

	/**
	 * Appends a message to the validator
	 *
	 * @param string message
	 * @param string|array field
	 * @param string type
	 */
	protected function appendMessage(string! message, field = null, type = null)
	{
		if !type {
			let type = str_replace("Validator", "", get_class(this));
		}
		let this->_messages[] = new Message(message, field, type);
	}

	/**
	 * Returns messages generated by the validator
	 */
	public function getMessages() -> array
	{
		return this->_messages;
	}

	/**
	 * Returns all the options from the validator
	 *
	 * @return array
	 */
	public function getOptions()
	{
		return this->_options;
	}

	/**
	 * Returns an option
	 *
	 * @param	string option
	 * @return	mixed
	 */
	public function getOption(string! option)
	{
		var options, value;
		let options = this->_options;
		if fetch value, options[option] {
			return value;
		}
		return "";
	}

	/**
	 * Check whether a option has been defined in the validator options
	 */
	public function isSetOption(string! option) -> boolean
	{
		return isset this->_options[option];
	}
}
{'fraction_non_alphanumeric': 0.23544353262993356, 'fraction_numerical': 0.004103165298944901, 'mean_word_length': 1.405545112781955, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5372622', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1251, 'n_words': 403}