<commit_before><?php

    /* This file is part of Box.
     *
     * (c) 2012 <NAME>
     *
     * For the full copyright and license information, please
     * view the LICENSE file that was distributed with this
     * source code.
     */

    namespace KevinGH\Box\Console\Command;

    use InvalidArgumentException,
        KevinGH\Box\Box,
        Phar,
        RuntimeException,
        Symfony\Component\Console\Command\Command,
        Symfony\Component\Console\Input\InputInterface,
        Symfony\Component\Console\Input\InputOption,
        Symfony\Component\Console\Output\OutputInterface;

    /**
     * The command that creates the PHAR.
     *
     * @author <NAME> <<EMAIL>>
     */
    class Create extends Command
    {
        /**
         * The output instance.
         *
         * @type OutputInterface
         */
        private $output;

        /**
         * The verbosity level.
         *
         * @type boolean
         */
        private $verbose = false;

        /** {@inheritDoc} */
        public function configure()
        {
            $this->setName('create')
                 ->setDescription('Creates a new PHAR.');

            $this->addOption(
                'config',
                'c',
                InputOption::VALUE_REQUIRED,
                'The configuration file path.'
            );
        }

        /** {@inheritDoc} */
        public function execute(InputInterface $input, OutputInterface $output)
        {
            if (true == ini_get('phar.readonly'))
            {
                throw new RuntimeException('PHAR writing has been disabled by "phar.readonly".');
            }

            $this->output = $output;

            $this->verbose = (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity());

            if ($this->verbose)
            {
                $output->writeln('Creating PHAR...');
            }

            else
            {
                $output->write('Creating PHAR...');
            }

            $config = $this->getHelper('config');

            $config->load($config->find($input->getOption('config')));

            if (true === $config['key-pass'])
            {
                $dialog = $this->getHelper('dialog');

                if ('' == ($config['key-pass'] = trim($dialog->ask($output, 'Private key password: '))))
                {
                    throw new InvalidArgumentException('Your private key password is required for signing.');
                }
            }

            $box = $this->start();

            $count = $this->add($box);
            $count += $this->add($box, true);

            $this->end($box);

            if ($this->verbose)
            {
                $output->writeln('Done.');
            }

            else
            {
                if (0 < $count)
                {
                    $output->writeln(' done.');
                }

                else
                {
                    $output->writeln(' no files found.');
                }
            }
        }

        /**
         * Adds files to the PHAR.
         *
         * @param Box $box The Box instance.
         * @param boolean $bin Binary safe adding of files?
         * @return integer The number of files added.
         */
        protected function add(Box $box, $bin = false)
        {
            if ($this->verbose)
            {
                $this->output->writeln(
                    $bin ? '    - Adding files'
                         : '    - Adding files (binary safe)'
                );
            }

            $counter = 0;

            $config = $this->getHelper('config');

            foreach ($config->getFiles($bin) as $file)
            {
                $relative = $config->relativeOf($file);

                if ($this->verbose)
                {
                    $this->output->writeln("        - $relative");<commit_msg>Fixed backwards output of "Adding files" and "Addign files (binary safe)".<commit_after><?php

    /* This file is part of Box.
     *
     * (c) 2012 <NAME>
     *
     * For the full copyright and license information, please
     * view the LICENSE file that was distributed with this
     * source code.
     */

    namespace KevinGH\Box\Console\Command;

    use InvalidArgumentException,
        KevinGH\Box\Box,
        Phar,
        RuntimeException,
        Symfony\Component\Console\Command\Command,
        Symfony\Component\Console\Input\InputInterface,
        Symfony\Component\Console\Input\InputOption,
        Symfony\Component\Console\Output\OutputInterface;

    /**
     * The command that creates the PHAR.
     *
     * @author <NAME> <<EMAIL>>
     */
    class Create extends Command
    {
        /**
         * The output instance.
         *
         * @type OutputInterface
         */
        private $output;

        /**
         * The verbosity level.
         *
         * @type boolean
         */
        private $verbose = false;

        /** {@inheritDoc} */
        public function configure()
        {
            $this->setName('create')
                 ->setDescription('Creates a new PHAR.');

            $this->addOption(
                'config',
                'c',
                InputOption::VALUE_REQUIRED,
                'The configuration file path.'
            );
        }

        /** {@inheritDoc} */
        public function execute(InputInterface $input, OutputInterface $output)
        {
            if (true == ini_get('phar.readonly'))
            {
                throw new RuntimeException('PHAR writing has been disabled by "phar.readonly".');
            }

            $this->output = $output;

            $this->verbose = (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity());

            if ($this->verbose)
            {
                $output->writeln('Creating PHAR...');
            }

            else
            {
                $output->write('Creating PHAR...');
            }

            $config = $this->getHelper('config');

            $config->load($config->find($input->getOption('config')));

            if (true === $config['key-pass'])
            {
                $dialog = $this->getHelper('dialog');

                if ('' == ($config['key-pass'] = trim($dialog->ask($output, 'Private key password: '))))
                {
                    throw new InvalidArgumentException('Your private key password is required for signing.');
                }
            }

            $box = $this->start();

            $count = $this->add($box);
            $count += $this->add($box, true);

            $this->end($box);

            if ($this->verbose)
            {
                $output->writeln('Done.');
            }

            else
            {
                if (0 < $count)
                {
                    $output->writeln(' done.');
                }

                else
                {
                    $output->writeln(' no files found.');
                }
            }
        }

        /**
         * Adds files to the PHAR.
         *
         * @param Box $box The Box instance.
         * @param boolean $bin Binary safe adding of files?
         * @return integer The number of files added.
         */
        protected function add(Box $box, $bin = false)
        {
            if ($this->verbose)
            {
                $this->output->writeln(
                    $bin ? '    - Adding files (binary safe)'
                         : '    - Adding files'
                );
            }

            $counter = 0;

            $config = $this->getHelper('config');

            foreach ($config->getFiles($bin) as $file)
            {
                $relative = $config->relativeOf($file);

                if ($this->verbose)
                {
                    $this->output->writeln("        - $relative");
{'fraction_non_alphanumeric': 0.1264426125554851, 'fraction_numerical': 0.0015218769816106531, 'mean_word_length': 1.2251693002257336, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 75, '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': '3577', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1919, 'n_words': 445}