<commit_before><?php

namespace Rougin\Weasley\Commands;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Rougin\Weasley\Common\Configuration;
use Rougin\Weasley\Common\Commands\AbstractCommand;

/**
 * Create Application Command
 *
 * @package Weasley
 * @author  <NAME> <<EMAIL>>
 */
class CreateApplicationCommand extends AbstractCommand
{
    /**
     * Configures the current command.
     *
     * @return void
     */
    protected function configure()
    {
        $config = Configuration::get();

        $this->setName('make:app')
            ->setDescription('Creates a base application');
    }

    /**
     * Executes the command.
     * 
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
     * @return object|\Symfony\Component\Console\Output\OutputInterface
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = Configuration::get();
        $slash = DIRECTORY_SEPARATOR;

        $directory = str_replace('Commands', 'Templates' . $slash . 'Application', __DIR__);
        $templates = $this->glob($directory . $slash . '**.*');
        $result = [];

        $data = [
            'application' => $config->application,
            'author'      => $config->author,
            'namespaces'  => (object) $config->namespaces,
        ];

        foreach ($templates as $template) {
            $sourceFile = str_replace($directory . $slash, '', $template);
            $contents = $this->renderer->render('Application' . $slash . $sourceFile, $data);

            if ( ! $this->filesystem->has($sourceFile)) {
                $this->filesystem->write($sourceFile, $contents);
            }
        }

        $text = 'Application created successfully.';

        return $output->writeln('<info>' . $text . '</info>');
    }

    /**
     * Find pathnames matching a pattern.
     * 
     * @param  string  $pattern
     * @param  integer $flags
     * @return array
     */
    public function glob($pattern, $flags = 0)
    {
        $files      = glob($pattern, $flags);
        $slash      = DIRECTORY_SEPARATOR;
        $newPattern = dirname($pattern) . $slash . '*';

        foreach (glob($newPattern, GLOB_ONLYDIR|GLOB_NOSORT) as $directory) {
            $anotherPattern = $directory . $slash . basename($pattern);
            $files = array_merge($files, $this->glob($anotherPattern, $flags));
        }

        return $files;
    }<commit_msg>Update CreateApplicationCommand<commit_after><?php

namespace Rougin\Weasley\Commands;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use Rougin\Weasley\Common\Configuration;
use Rougin\Weasley\Common\Commands\AbstractCommand;

/**
 * Create Application Command
 *
 * @package Weasley
 * @author  <NAME> <<EMAIL>>
 */
class CreateApplicationCommand extends AbstractCommand
{
    /**
     * Configures the current command.
     *
     * @return void
     */
    protected function configure()
    {
        $config = Configuration::get();

        $this->setName('make:app')
            ->setDescription('Creates a base application');
    }

    /**
     * Executes the command.
     * 
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
     * @return object|\Symfony\Component\Console\Output\OutputInterface
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = Configuration::get();
        $slash = DIRECTORY_SEPARATOR;

        $directory = str_replace('Commands', 'Templates' . $slash . 'Application', __DIR__);
        $templates = $this->glob($directory . $slash . '**');
        $result = [];

        $data = [
            'application' => $config->application,
            'author'      => $config->author,
            'namespaces'  => (object) $config->namespaces,
        ];

        foreach ($templates as $template) {
            $sourceFile = str_replace($directory . $slash, '', $template);
            $contents = $this->renderer->render('Application' . $slash . $sourceFile, $data);

            if ($this->filesystem->has($sourceFile)) {
                $this->filesystem->delete($sourceFile);
            }

            $this->filesystem->write($sourceFile, $contents);
        }

        $text = 'Application created successfully.';

        return $output->writeln('<info>' . $text . '</info>');
    }

    /**
     * Find pathnames matching a pattern.
     * 
     * @param  string  $pattern
     * @param  integer $flags
     * @return array
     */
    public function glob($pattern, $flags = 0)
    {
        $files      = glob($pattern, $flags);
        $slash      = DIRECTORY_SEPARATOR;
        $newPattern = dirname($pattern) . $slash . '*';

        foreach (glob($newPattern, GLOB_ONLYDIR|GLOB_NOSORT) as $directory) {
            $anotherPattern = $directory . $slash . basename($pattern);
            $files = array_merge($files, $this->glob($anotherPattern, $flags));
        }

        return $files;
    }
{'fraction_non_alphanumeric': 0.14038956266078648, 'fraction_numerical': 0.0003675119441381845, 'mean_word_length': 2.509348807221148, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 49, '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': '2966811', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1508, 'n_words': 298}