<commit_before><?php
	/** Php Commands
	 * REQUIRE PhpShrink!
	 * 
	 * @author		<NAME>, <<EMAIL>>
	 * @version		2012-12-13-2
	 */
	
	namespace Heymaster\Commands;
	
	use Nette\Object,
		Heymaster\Command,
		Heymaster\InvalidException;
	
	class PhpCommands extends CommandSet
	{
		const MASK = '*.php';
		
		
		
		public static function install(\Heymaster\Heymaster $heymaster)
		{
			$me = new static($heymaster);
			
			$heymaster->addCommand('Php::lint', array($me, 'commandLint'));
			$heymaster->addCommand('Php::compress', array($me, 'commandCompress'));
			$heymaster->addCommand('Php::compile', array($me, 'commandCompile'));
			
			return $me;
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandLint(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			$error = FALSE;
			$output = (bool)$command->config->output;
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$ret = $this->heymaster->runner->run(array(
					'php -l',
					'-f' => (string)$file,
				), $output);
				
				if($ret !== 0)
				{
					$this->heymaster->logger->error('PhpLint: ' . $file);
					$error = TRUE;
				}
			}
			
			if($error)
			{
				throw new InvalidException('Php::lint: Any invalid files.');
			}
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandCompress(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$shrink = self::createPhpShrink();
				$shrink->addFile((string)$file);
				
				file_put_contents((string)$file, $shrink->getOutput());
			}
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandCompile(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			
			if(isset($command->params['file']) && !is_string($command->params['file']))
			{
				throw new InvalidException('Nebylo zadano jmeno souboru, do ktereho se ma kompilovat.');
			}
			
			$outputFile = $command->params['file'];
			$shrink = self::createPhpShrink();
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$shrink->addFile((string)$file);
			}
			
			file_put_contents($command->config->root . '/' . $file, $shrink->getOutput());
		}
		
		
		
		public function findFiles($mask, $actionMask, $root)
		{
			$finder = $this->heymaster->findFiles($mask)
				->mask($actionMask);
			
			$finder->from($root)
				->exclude('.git');
			
			return $finder;
		}
		
		
		
		protected static function createPhpShrink()
		{
			$shrink = new PhpShrink;
			$shrink->useNamespaces = TRUE;
			
			return $shrink;
		}
	}

<commit_msg>Heymaster\Commands\PhpCommands: bug fix - bad class name<commit_after><?php
	/** Php Commands
	 * REQUIRE PhpShrink!
	 * 
	 * @author		<NAME>, <<EMAIL>>
	 * @version		2012-12-17-1
	 */
	
	namespace Heymaster\Commands;
	
	use Nette\Object,
		Heymaster\Command,
		Heymaster\InvalidException;
	
	class PhpCommands extends CommandSet
	{
		const MASK = '*.php';
		
		
		
		public static function install(\Heymaster\Heymaster $heymaster)
		{
			$me = new static($heymaster);
			
			$heymaster->addCommand('Php::lint', array($me, 'commandLint'));
			$heymaster->addCommand('Php::compress', array($me, 'commandCompress'));
			$heymaster->addCommand('Php::compile', array($me, 'commandCompile'));
			
			return $me;
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandLint(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			$error = FALSE;
			$output = (bool)$command->config->output;
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$ret = $this->heymaster->runner->run(array(
					'php -l',
					'-f' => (string)$file,
				), $output);
				
				if($ret !== 0)
				{
					$this->heymaster->logger->error('PhpLint: ' . $file);
					$error = TRUE;
				}
			}
			
			if($error)
			{
				throw new InvalidException('Php::lint: Any invalid files.');
			}
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandCompress(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$shrink = self::createPhpShrink();
				$shrink->addFile((string)$file);
				
				file_put_contents((string)$file, $shrink->getOutput());
			}
		}
		
		
		
		/**
		 * @param	Heymaster\Command
		 * @param	string
		 * @throws	Heymaster\InvalidException
		 * @return	void
		 */
		public function commandCompile(Command $command, $actionMask)
		{
			$mask = isset($command->params['mask']) ? $command->params['mask'] : self::MASK;
			
			if(isset($command->params['file']) && !is_string($command->params['file']))
			{
				throw new InvalidException('Nebylo zadano jmeno souboru, do ktereho se ma kompilovat.');
			}
			
			$outputFile = $command->params['file'];
			$shrink = self::createPhpShrink();
			
			foreach($this->findFiles($mask, $actionMask, $command->config->root) as $file)
			{
				$shrink->addFile((string)$file);
			}
			
			file_put_contents($command->config->root . '/' . $file, $shrink->getOutput());
		}
		
		
		
		public function findFiles($mask, $actionMask, $root)
		{
			$finder = $this->heymaster->findFiles($mask)
				->mask($actionMask);
			
			$finder->from($root)
				->exclude('.git');
			
			return $finder;
		}
		
		
		
		protected static function createPhpShrink()
		{
			$shrink = new \PhpShrink;
			$shrink->useNamespaces = TRUE;
			
			return $shrink;
		}
	}


{'fraction_non_alphanumeric': 0.17549775208734747, 'fraction_numerical': 0.0032113037893384713, 'mean_word_length': 3.1777330650570086, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 93, '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': '4911399', 'n_tokens_mistral': 2693, 'n_tokens_neox': 2121, 'n_words': 367}