<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\Helper;

    use ArrayObject,
        InvalidArgumentException,
        KevinGH\Box\Console\Exception\JSONException,
        Phar,
        RuntimeException,
        Symfony\Component\Console\Helper\HelperInterface,
        Symfony\Component\Console\Helper\HelperSet,
        Symfony\Component\Finder\Finder,
        Symfony\Component\Process\Process;

    /**
     * Manages the loading and use of configuration settings.
     *
     * @author <NAME> <<EMAIL>>
     */
    class Config extends ArrayObject implements HelperInterface
    {
        /**
         * The helper set.
         *
         * @type HelperSet
         */
        private $helperSet;

        /**
         * Sets the default configuration settings.
         */
        public function __construct()
        {
            parent::__construct(array(
                'algorithm' => Phar::SHA1,
                'alias' => 'default.phar',
                'base-path' => null,
                'directories' => array(),
                'files' => array(),
                'finder' => array(),
                'git-version' => null,
                'key' => null,
                'key-pass' => null,
                'main' => null,
                'output' => 'default.phar',
                'replacements' => array(),
                'stub' => null,
            ));
        }

        /**
         * Finds the appropriate configuration file.
         *
         * @throws InvalidArgumentException If the file does not exist.
         * @param string $file The optional file path.
         * @return string The found configuration file path.
         */
        public function find($file)
        {
            if ($file)
            {
                if (false === file_exists($file))
                {
                    throw new InvalidArgumentException('The configuration file does not exist.');
                }

                $file = realpath($file);
            }

            elseif (file_exists('box.json'))
            {
                $file = realpath('box.json');
            }

            elseif (file_exists('box-dist.json'))
            {
                $file = realpath('box-dist.json');
            }

            else
            {
                throw new RuntimeException('No configuration file found.');
            }

            return $file;
        }

        /**
         * Returns a list of files found using the configuration.
         *
         * @throws InvalidArgumentException If a path is not a file.
         * @return array The list of files.
         */
        public function getFiles()
        {
            $files = array();

            if (is_dir($this['base-path']))
            {
                $pwd = getcwd();

                chdir($this['base-path']);
            }

            foreach ((array) $this['files'] as $file)
            {
                if (false === is_file($file))
                {
                    throw new InvalidArgumentException(sprintf(
                        'The path is not a file: %s',
                        $file
                    ));
                }

                $files[] = realpath($file);
            }

            foreach ((array) $this['directories'] as $dir)
            {
                $finder = new Finder;

                $finder->files()
                       ->ignoreVCS(true)
                       ->name('*.php')
                       ->in($dir);
<commit_msg>Constructor accepts array, and adding getCurrentDir().<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\Helper;

    use ArrayObject,
        InvalidArgumentException,
        KevinGH\Box\Console\Exception\JSONException,
        Phar,
        RuntimeException,
        Symfony\Component\Console\Helper\HelperInterface,
        Symfony\Component\Console\Helper\HelperSet,
        Symfony\Component\Finder\Finder,
        Symfony\Component\Process\Process;

    /**
     * Manages the loading and use of configuration settings.
     *
     * @author <NAME> <<EMAIL>>
     */
    class Config extends ArrayObject implements HelperInterface
    {
        /**
         * The helper set.
         *
         * @type HelperSet
         */
        private $helperSet;

        /**
         * Sets the default configuration settings.
         */
        public function __construct(array $input = array())
        {
            parent::__construct(array_merge(
                array(
                    'algorithm' => Phar::SHA1,
                    'alias' => 'default.phar',
                    'base-path' => null,
                    'directories' => array(),
                    'files' => array(),
                    'finder' => array(),
                    'git-version' => null,
                    'key' => null,
                    'key-pass' => null,
                    'main' => null,
                    'output' => 'default.phar',
                    'replacements' => array(),
                    'stub' => null
                ),
                $input
            ));
        }

        /**
         * Finds the appropriate configuration file.
         *
         * @throws InvalidArgumentException If the file does not exist.
         * @param string $file The optional file path.
         * @return string The found configuration file path.
         */
        public function find($file)
        {
            if ($file)
            {
                if (false === file_exists($file))
                {
                    throw new InvalidArgumentException('The configuration file does not exist.');
                }

                $file = realpath($file);
            }

            elseif (file_exists('box.json'))
            {
                $file = realpath('box.json');
            }

            elseif (file_exists('box-dist.json'))
            {
                $file = realpath('box-dist.json');
            }

            else
            {
                throw new RuntimeException('No configuration file found.');
            }

            return $file;
        }

        /**
         * Returns the current work directory path.
         *
         * @return string The directory path.
         */
        public function getCurrentDir()
        {
            if (false === ($cwd = getcwd()))
            {
                if (isset($_SERVER['PWD']))
                {
                    $cwd = $_SERVER['PWD'];
                }

                else
                {
                    throw new RuntimeException('Could not get current working directory path.');
                }
            }

            return $cwd;
        }

        /**
         * Returns a list of files found using the configuration.
         *
         * @throws InvalidArgumentException If a path is not a file.
         * @return array The list of files.
         */
        public function getFiles()
        {
            $files = array();

            if (is_dir($this['base-path']))
            {
                $pwd = $this->getCurrentDir();

                chdir($this['base-path']);
            }

            foreach ((array) $this['files'] as $file)
            {
                if (false === is_file($file))
                {
                    throw new InvalidArgumentException(sprintf(
                        'The path is not a file: %s',
                        $file
                    ));
                }

                $files[] = realpath($file);
            }

            foreach ((array) $this['directories'] as $dir)
            {
                $finder = new Finder;

                $finder->files()
                       ->ignoreVCS(true)
                       ->name('*.php')
                       ->in($dir);

{'fraction_non_alphanumeric': 0.10748630553864881, 'fraction_numerical': 0.0012172854534388314, 'mean_word_length': 1.1418143899895725, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 46, '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': '5822217', 'n_tokens_mistral': 2039, 'n_tokens_neox': 1910, 'n_words': 501}