src/Command/Executor/Translation/Duplicates.php
public function execute()
	{
		$entries = [];
		$path = rtrim(str_replace('\\', '/', $this->getArguments()[0]), '/') . '/';

		try
		{
			$directory = new \RecursiveDirectoryIterator($path);
			$iterator = new \RecursiveIteratorIterator($directory);
			$regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);

			foreach ($regex as $matches)
			{
				$file = str_replace('\\', '/', $matches[0]);
				$translations = require $matches[0];

				foreach ($translations as $key => $content)
				{
					if (array_key_exists($content, $entries) === false)
					{
						$entries[$content] = [];
					}

					$entries[$content][] = [
						'file' => str_replace([$path, '.php'], '', $file),
						'key' => $key
					];
				}
			}

			$entries = array_filter($entries, function($files)
			{
				return count($files) > 1;
			});

			foreach ($entries as $content => $files)
			{
				for ($i = 1; $i < count($files); $i++)
				{
					$this->write($files[0], $files[$i]);
				}
			}

			$this->getConsole()->writeLine('Done.', ColorInterface::BLACK, ColorInterface::LIGHT_GREEN);
		}
		catch (\Exception $exception)
		{
			$this->getConsole()->writeLine('Can not search for duplicates. Maybe the path is wrong.', ColorInterface::LIGHT_YELLOW, ColorInterface::LIGHT_RED);
			return false;
		}

		return true;
	}
public function execute()
	{
		$entries = [];
		$path = rtrim(str_replace('\\', '/', $this->getArguments()[0]), '/') . '/';

		try
		{
			$directory = new \RecursiveDirectoryIterator($path);
			$iterator = new \RecursiveIteratorIterator($directory);
			$regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);

			foreach ($regex as $matches)
			{
				$file = str_replace('\\', '/', $matches[0]);
				$translations = require $matches[0];

				foreach ($translations as $key => $content)
				{
					if (array_key_exists($content, $entries) === false)
					{
						$entries[$content] = [];
					}

					$entries[$content][] = [
						'file' => str_replace([$path, '.php'], '', $file),
						'key' => $key
					];
				}
			}

			$entries = array_filter($entries, function($files)
			{
				return count($files) > 1;
			});

			foreach ($entries as $content => $files)
			{
				for ($i = 1; $i < count($files); $i++)
				{
					$this->write($files[0], $files[$i]);
				}
			}

			$this->getConsole()->writeLine('Done.', ColorInterface::BLACK, ColorInterface::LIGHT_GREEN);
		}
		catch (\Exception $exception)
		{
			$this->getConsole()->writeLine('Can not search for duplicates. Maybe the path is wrong.', ColorInterface::LIGHT_YELLOW, ColorInterface::LIGHT_RED);
			return false;
		}

		return true;
	}
public function execute ( ) { $ entries = [ ] ; $ path = rtrim ( str_replace ( '\\' , '/' , $ this -> getArguments ( ) [ 0 ] ) , '/' ) . '/' ; try { $ directory = new \ RecursiveDirectoryIterator ( $ path ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory ) ; $ regex = new \ RegexIterator ( $ iterator , '/^.+\.php$/i' , \ RecursiveRegexIterator :: GET_MATCH ) ; foreach ( $ regex as $ matches ) { $ file = str_replace ( '\\' , '/' , $ matches [ 0 ] ) ; $ translations = require $ matches [ 0 ] ; foreach ( $ translations as $ key => $ content ) { if ( array_key_exists ( $ content , $ entries ) === false ) { $ entries [ $ content ] = [ ] ; } $ entries [ $ content ] [ ] = [ 'file' => str_replace ( [ $ path , '.php' ] , '' , $ file ) , 'key' => $ key ] ; } } $ entries = array_filter ( $ entries , function ( $ files ) { return count ( $ files ) > 1 ; } ) ; foreach ( $ entries as $ content => $ files ) { for ( $ i = 1 ; $ i < count ( $ files ) ; $ i ++ ) { $ this -> write ( $ files [ 0 ] , $ files [ $ i ] ) ; } } $ this -> getConsole ( ) -> writeLine ( 'Done.' , ColorInterface :: BLACK , ColorInterface :: LIGHT_GREEN ) ; } catch ( \ Exception $ exception ) { $ this -> getConsole ( ) -> writeLine ( 'Can not search for duplicates. Maybe the path is wrong.' , ColorInterface :: LIGHT_YELLOW , ColorInterface :: LIGHT_RED ) ; return false ; } return true ; }
/*
(non-PHPdoc)
@see \DasRed\Translation\Command\ExecutorAbstract::execute()
/ * ( non - PHPdoc )