<commit_before><?php namespace Illuminate\Foundation\Console;

use Illuminate\Console\Command;
use Illuminate\Foundation\Composer;
use Symfony\Component\Finder\Finder;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;

class AppNameCommand extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'app:name';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = "Set the application namespace";

	/**
	 * The Composer class instance.
	 *
	 * @var \Illuminate\Foundation\Composer
	 */
	protected $composer;

	/**
	 * The filesystem instance.
	 *
	 * @var \Illuminate\Filesystem\Filesystem
	 */
	protected $files;

	/**
	 * Current root application namespace.
	 *
	 * @var string
	 */
	protected $currentRoot;

	/**
	 * Create a new key generator command.
	 *
	 * @param  \Illuminate\Foundation\Composer  $composer
	 * @param  \Illuminate\Filesystem\Filesystem  $files
	 * @param  string  $currentRoot
	 * @return void
	 */
	public function __construct(Composer $composer, Filesystem $files, $currentRoot)
	{
		parent::__construct();

		$this->files = $files;
		$this->composer = $composer;
		$this->currentRoot = trim($currentRoot, '\\');
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		$this->setAppDirectoryNamespace();

		$this->setConfigNamespaces();

		$this->setComposerNamespace();

		$this->info('Application namespace set!');

		$this->composer->dumpAutoloads();
	}

	/**
	 * Set the namespace on the files in the app directory.
	 *
	 * @return void
	 */
	protected function setAppDirectoryNamespace()
	{
		$files = Finder::create()
                            ->in($this->laravel['path'])
                            ->exclude($this->laravel['path'].'/Http/Views')
                            ->name('*.php');

		foreach ($files as $file)
		{
			$this->replaceNamespace($file->getRealPath());
		}

		$this->setServiceProviderNamespaceReferences();
	}

	/**
	 * Replace the App namespace at the given path.
	 *
	 * @param  string  $path;
	 */
	protected function replaceNamespace($path)
	{
		$this->replaceIn(
			$path, 'namespace '.$this->currentRoot.';', 'namespace '.$this->argument('name').';'
		);

		$this->replaceIn(
			$path, 'namespace '.$this->currentRoot.'\\', 'namespace '.$this->argument('name').'\\'
		);
	}

	/**
	 * Set the referenced namespaces in various service providers.
	 *
	 * @return void
	 */
	protected function setServiceProviderNamespaceReferences()
	{
		$this->setReferencedFilterNamespaces();

		$this->setReferencedConsoleNamespaces();

		$this->setReferencedRouteNamespaces();
	}

	/**
	 * Set the namespace on the referenced filters in the filter service provider.
	 *
	 * @return void
	 */
	protected function setReferencedFilterNamespaces()
	{
		$this->replaceIn(
			$this->laravel['path'].'/Providers/FilterServiceProvider.php',
			$this->currentRoot.'\\Http\\Filters', $this->argument('name').'\\Http\\Filters'<commit_msg>Add some more namespace replacements.<commit_after><?php namespace Illuminate\Foundation\Console;

use Illuminate\Console\Command;
use Illuminate\Foundation\Composer;
use Symfony\Component\Finder\Finder;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Input\InputArgument;

class AppNameCommand extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'app:name';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = "Set the application namespace";

	/**
	 * The Composer class instance.
	 *
	 * @var \Illuminate\Foundation\Composer
	 */
	protected $composer;

	/**
	 * The filesystem instance.
	 *
	 * @var \Illuminate\Filesystem\Filesystem
	 */
	protected $files;

	/**
	 * Current root application namespace.
	 *
	 * @var string
	 */
	protected $currentRoot;

	/**
	 * Create a new key generator command.
	 *
	 * @param  \Illuminate\Foundation\Composer  $composer
	 * @param  \Illuminate\Filesystem\Filesystem  $files
	 * @param  string  $currentRoot
	 * @return void
	 */
	public function __construct(Composer $composer, Filesystem $files, $currentRoot)
	{
		parent::__construct();

		$this->files = $files;
		$this->composer = $composer;
		$this->currentRoot = trim($currentRoot, '\\');
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		$this->setAppDirectoryNamespace();

		$this->setConfigNamespaces();

		$this->setComposerNamespace();

		$this->info('Application namespace set!');

		$this->composer->dumpAutoloads();
	}

	/**
	 * Set the namespace on the files in the app directory.
	 *
	 * @return void
	 */
	protected function setAppDirectoryNamespace()
	{
		$files = Finder::create()
                            ->in($this->laravel['path'])
                            ->exclude($this->laravel['path'].'/Http/Views')
                            ->name('*.php');

		foreach ($files as $file)
		{
			$this->replaceNamespace($file->getRealPath());
		}

		$this->setServiceProviderNamespaceReferences();
	}

	/**
	 * Replace the App namespace at the given path.
	 *
	 * @param  string  $path;
	 */
	protected function replaceNamespace($path)
	{
		$this->replaceIn(
			$path, 'namespace '.$this->currentRoot.';', 'namespace '.$this->argument('name').';'
		);

		$this->replaceIn(
			$path, 'namespace '.$this->currentRoot.'\\', 'namespace '.$this->argument('name').'\\'
		);

		$this->replaceIn(
			$path, $this->currentRoot.'\\', $this->argument('name').'\\'
		);
	}

	/**
	 * Set the referenced namespaces in various service providers.
	 *
	 * @return void
	 */
	protected function setServiceProviderNamespaceReferences()
	{
		$this->setReferencedFilterNamespaces();

		$this->setReferencedConsoleNamespaces();

		$this->setReferencedRouteNamespaces();
	}

	/**
	 * Set the namespace on the referenced filters in the filter service provider.
	 *
	 * @return void
	 */
	protected function setReferencedFilterNamespaces()
	{
		$this->replaceIn(
			$this->laravel['path'].'/Providers/FilterServiceProvider.php',
			$this->currentRoot.'\\Http\\Filters', $this->argument('name').'\\Http\\Filters'
{'fraction_non_alphanumeric': 0.15513897866839044, 'fraction_numerical': 0.0, 'mean_word_length': 3.3340336134453783, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 66, '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': '7145535', 'n_tokens_mistral': 2024, 'n_tokens_neox': 1832, 'n_words': 401}