<commit_before><?php
	/** Heymaster File & Directory Finder
	 * 
	 * @author		<NAME>, <<EMAIL>>
	 * @version		2012-12-06-1
	 */
	
	namespace Heymaster\Utils;
	
	use \Nette\Utils\Finder as NFinder;
	
	class Finder extends NFinder
	{
		/**
		 * @param	string|string[]
		 * @return	void
		 */
		public function mask($masks)
		{
			if(!is_array($masks))
			{
				$masks = func_get_args();
			}
			
			$pattern = self::buildPattern($masks);
			
			if($pattern)
			{
				$this->filter(function($file) use ($pattern) {
					return !$file->isDot()
						&& (!$pattern || preg_match($pattern, '/' . strtr($file->getSubPathName(), '\\', '/')));
				});
			}
		}
		
		
		
		/**
		 * Converts Finder pattern to regular expression.
		 * @param	array
		 * @return	string
		 * @author	<NAME>
		 * @link	http://api.nette.org/2.0.7/source-Utils.Finder.php.html#176
		 */
		protected static function buildPattern($masks)
		{
			$pattern = array();
			// TODO: accept regexp
			foreach ($masks as $mask)<commit_msg>Heymaster\Utils\Finder: updated - method mask() provides fluent interface<commit_after><?php
	/** Heymaster File & Directory Finder
	 * 
	 * @author		<NAME>, <<EMAIL>>
	 * @version		2012-12-09-1
	 */
	
	namespace Heymaster\Utils;
	
	use \Nette\Utils\Finder as NFinder;
	
	class Finder extends NFinder
	{
		/**
		 * @param	string|string[]
		 * @return	void
		 */
		public function mask($masks)
		{
			if(!is_array($masks))
			{
				$masks = func_get_args();
			}
			
			$pattern = self::buildPattern($masks);
			
			if($pattern)
			{
				$this->filter(function($file) use ($pattern) {
					return !$file->isDot()
						&& (!$pattern || preg_match($pattern, '/' . strtr($file->getSubPathName(), '\\', '/')));
				});
			}
			
			return $this;
		}
		
		
		
		/**
		 * Converts Finder pattern to regular expression.
		 * @param	array
		 * @return	string
		 * @author	<NAME>
		 * @link	http://api.nette.org/2.0.7/source-Utils.Finder.php.html#176
		 */
		protected static function buildPattern($masks)
		{
			$pattern = array();
			// TODO: accept regexp
			foreach ($masks as $mask)
{'fraction_non_alphanumeric': 0.1736613603473227, 'fraction_numerical': 0.01447178002894356, 'mean_word_length': 2.664310954063604, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '4471757', 'n_tokens_mistral': 905, 'n_tokens_neox': 717, 'n_words': 143}