<commit_before><?php

/**
 * This file is part of the Krystal Framework
 * 
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 * 
 * For the full copyright and license information, please view
 * the license file that was distributed with this source code.
 */

namespace Krystal\Validate\File\Constraint;

final class FilenameRegEx extends AbstractConstraint
{
	/**
	 * RegEx pattern to test against
	 * 
	 * @var string
	 */
	private $pattern;

	/**
	 * {@inheritDoc}
	 */
	protected $message = 'Filename %s does not match a regex';

	/**
	 * Class initialization
	 * 
	 * @param string $pattern
	 * @return void
	 */
	public function __construct($pattern)
	{
		$this->pattern = $pattern;
	}

	/**
	 * {@inheritDoc}
	 */
	public function isValid(array $files)
	{
		foreach ($files as $file) {
			// @ - because pattern could be wrong and an E_WARNING will be issued
			if (!@preg_match($this->pattern, $file->getName())) {
				$this->violate(sprintf($this->message, $file->getName()));
			}
		}

		return !$this->hasErrors();
	}
}<commit_msg>Improved descriptions<commit_after><?php

/**
 * This file is part of the Krystal Framework
 * 
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 * 
 * For the full copyright and license information, please view
 * the license file that was distributed with this source code.
 */

namespace Krystal\Validate\File\Constraint;

final class FilenameRegEx extends AbstractConstraint
{
	/**
	 * RegEx pattern to match against
	 * 
	 * @var string
	 */
	private $pattern;

	/**
	 * {@inheritDoc}
	 */
	protected $message = 'Filename %s does not match a regex';

	/**
	 * State initialization
	 * 
	 * @param string $pattern RegEx pattern
	 * @return void
	 */
	public function __construct($pattern)
	{
		$this->pattern = $pattern;
	}

	/**
	 * {@inheritDoc}
	 */
	public function isValid(array $files)
	{
		foreach ($files as $file) {
			// @ - because the RegEx pattern itself could be wrong and issue E_WARNING
			if (!@preg_match($this->pattern, $file->getName())) {
				$this->violate(sprintf($this->message, $file->getName()));
			}
		}

		return !$this->hasErrors();
	}
}
{'fraction_non_alphanumeric': 0.13944603629417382, 'fraction_numerical': 0.0038204393505253103, 'mean_word_length': 3.3645833333333335, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '4667272', 'n_tokens_mistral': 704, 'n_tokens_neox': 625, 'n_words': 199}