<commit_before><?php
/**
 * kreXX: Krumo eXXtended
 *
 * kreXX is a debugging tool, which displays structured information
 * about any PHP object. It is a nice replacement for print_r() or var_dump()
 * which are used by a lot of PHP developers.
 *
 * kreXX is a fork of Krumo, which was originally written by:
 * <NAME> <<EMAIL>>
 *
 * @author
 *   brainworXX GmbH <<EMAIL>>
 *
 * @license
 *   http://opensource.org/licenses/LGPL-2.1
 *
 *   GNU Lesser General Public License Version 2.1
 *
 *   kreXX Copyright (C) 2014-2017 Brainworxx GmbH
 *
 *   This library is free software; you can redistribute it and/or modify it
 *   under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation; either version 2.1 of the License, or (at
 *   your option) any later version.
 *   This library is distributed in the hope that it will be useful, but WITHOUT
 *   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 *   for more details.
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this library; if not, write to the Free Software Foundation,
 *   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

namespace Brainworxx\Krexx\Service\Config;

use Brainworxx\Krexx\Service\Factory\Pool;
use Brainworxx\Krexx\Service\Config\From\Cookie;
use Brainworxx\Krexx\Service\Config\From\Ini;
use Brainworxx\Krexx\Service\Overwrites;

/**
 * Access the debug settings here.
 *
 * @package Brainworxx\Krexx\Service\Config
 */
class Config extends Fallback
{

    /**
     * Our current settings.
     *
     * @var Model[]
     */
    public $settings = array();

    /**
     * List of all configured debug methods.
     *
     * @var array
     */
    public $debugFuncList = array();

    /**
     * Our security handler.
     *
     * @var Security
     */
    public $security;

    /**
     * Our ini file configuration handler.
     *
     * @var Ini
     */
    public $iniConfig;

    /**
     * Our cookie configuration handler.
     *
     * @var Cookie
     */
    public $cookieConfig;

    /**
     * Here we store the paths to our files and directories.
     *
     * @var array
     */
    protected $directories = array();

    /**
     * Injection the pool and loading the configuration.
     *
     * @param \Brainworxx\Krexx\Service\Factory\Pool $pool
     */
    public function __construct(Pool $pool)
    {
        parent::__construct($pool);

        $this->initDirectories();
        $this->security = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Security');
        $this->iniConfig = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\From\\Ini')
            ->loadIniFile($this->getPathToIniFile());
        $this->cookieConfig = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\From\\Cookie');

        // Loading the settings.
        foreach ($this->configFallback as $section => $settings) {
            foreach ($settings as $name => $factorySetting) {
                $this->loadConfigValue($section, $name, $factorySetting);
            }
        }

        // We may need to change the disabling again, in case we are in cli
        // or ajax mode and have no fileoutput.
        if ($this->isRequestAjaxOrCli() &&
            $this->getSetting('destination') !== 'file'
        ) {
            // No kreXX for you!
            $this->setDisabled(true);
        }

        // Now that our settings are in place, we need to check the
        // ip to decide if we need to deactivate kreXX.
        if (!$this->isAllowedIp($this->getSetting('iprange'))) {
            // No kreXX for you!
            $this->setDisabled(true);
        }

        $this->debugFuncList = explode(',', $this->getSetting('debugMethods'));
    }

    protected function initDirectories()<commit_msg>Added an overlooked php doc comment.<commit_after><?php
/**
 * kreXX: Krumo eXXtended
 *
 * kreXX is a debugging tool, which displays structured information
 * about any PHP object. It is a nice replacement for print_r() or var_dump()
 * which are used by a lot of PHP developers.
 *
 * kreXX is a fork of Krumo, which was originally written by:
 * <NAME> <<EMAIL>>
 *
 * @author
 *   brainworXX GmbH <<EMAIL>>
 *
 * @license
 *   http://opensource.org/licenses/LGPL-2.1
 *
 *   GNU Lesser General Public License Version 2.1
 *
 *   kreXX Copyright (C) 2014-2017 Brainworxx GmbH
 *
 *   This library is free software; you can redistribute it and/or modify it
 *   under the terms of the GNU Lesser General Public License as published by
 *   the Free Software Foundation; either version 2.1 of the License, or (at
 *   your option) any later version.
 *   This library is distributed in the hope that it will be useful, but WITHOUT
 *   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *   FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 *   for more details.
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this library; if not, write to the Free Software Foundation,
 *   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

namespace Brainworxx\Krexx\Service\Config;

use Brainworxx\Krexx\Service\Factory\Pool;
use Brainworxx\Krexx\Service\Config\From\Cookie;
use Brainworxx\Krexx\Service\Config\From\Ini;
use Brainworxx\Krexx\Service\Overwrites;

/**
 * Access the debug settings here.
 *
 * @package Brainworxx\Krexx\Service\Config
 */
class Config extends Fallback
{

    /**
     * Our current settings.
     *
     * @var Model[]
     */
    public $settings = array();

    /**
     * List of all configured debug methods.
     *
     * @var array
     */
    public $debugFuncList = array();

    /**
     * Our security handler.
     *
     * @var Security
     */
    public $security;

    /**
     * Our ini file configuration handler.
     *
     * @var Ini
     */
    public $iniConfig;

    /**
     * Our cookie configuration handler.
     *
     * @var Cookie
     */
    public $cookieConfig;

    /**
     * Here we store the paths to our files and directories.
     *
     * @var array
     */
    protected $directories = array();

    /**
     * Injection the pool and loading the configuration.
     *
     * @param \Brainworxx\Krexx\Service\Factory\Pool $pool
     */
    public function __construct(Pool $pool)
    {
        parent::__construct($pool);

        $this->initDirectories();
        $this->security = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Security');
        $this->iniConfig = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\From\\Ini')
            ->loadIniFile($this->getPathToIniFile());
        $this->cookieConfig = $pool->createClass('Brainworxx\\Krexx\\Service\\Config\\From\\Cookie');

        // Loading the settings.
        foreach ($this->configFallback as $section => $settings) {
            foreach ($settings as $name => $factorySetting) {
                $this->loadConfigValue($section, $name, $factorySetting);
            }
        }

        // We may need to change the disabling again, in case we are in cli
        // or ajax mode and have no fileoutput.
        if ($this->isRequestAjaxOrCli() &&
            $this->getSetting('destination') !== 'file'
        ) {
            // No kreXX for you!
            $this->setDisabled(true);
        }

        // Now that our settings are in place, we need to check the
        // ip to decide if we need to deactivate kreXX.
        if (!$this->isAllowedIp($this->getSetting('iprange'))) {
            // No kreXX for you!
            $this->setDisabled(true);
        }

        $this->debugFuncList = explode(',', $this->getSetting('debugMethods'));
    }

    /**
     * Set the directory path, according to the overwrites for:
     * - Chunk files
     * - Log files
     * - Configuration files
     */
    protected function initDirectories()
{'fraction_non_alphanumeric': 0.11334164588528678, 'fraction_numerical': 0.006982543640897756, 'mean_word_length': 2.400169563374311, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 55, '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': '5190954', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2280, 'n_words': 749}