<commit_before><?php namespace System\Validation\Rules;

use System\Validation\Rule;

class With_Callback extends Rule {

	/**
	 * The callback.
	 *
	 * @var function
	 */
	public $callback;

	/**
	 * Evaluate the validity of an attribute.
	 *
	 * @param  string  $attribute
	 * @param  array   $attributes
	 * @return void
	 */
	public function check($attribute, $attributes)
	{
		if ( ! array_key_exists($attribute, $attributes))
		{
			return true;
		}

		if ( ! is_callable($this->callback))
		{
			throw new \Exception("A validation callback for the [$attribute] attribute is not callable.");
		}

		return call_user_func($this->callback, $attributes[$attribute]);
	}
<commit_msg>Improving validation code and comments.<commit_after><?php namespace System\Validation\Rules;

use System\Validation\Rule;

class With_Callback extends Rule {

	/**
	 * The callback that will be used to validate the attribute.
	 *
	 * @var function
	 */
	public $callback;

	/**
	 * Evaluate the validity of an attribute.
	 *
	 * @param  string  $attribute
	 * @param  array   $attributes
	 * @return void
	 */
	public function check($attribute, $attributes)
	{
		if ( ! array_key_exists($attribute, $attributes))
		{
			return true;
		}

		if ( ! is_callable($this->callback))
		{
			throw new \Exception("The validation callback for the [$attribute] attribute is not callable.");
		}

		return call_user_func($this->callback, $attributes[$attribute]);
	}

{'fraction_non_alphanumeric': 0.12413314840499307, 'fraction_numerical': 0.0, 'mean_word_length': 3.625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6190063', 'n_tokens_mistral': 471, 'n_tokens_neox': 417, 'n_words': 122}