<commit_before><?php
/**
 * The main class for fetching the configuration, update and delete items. This
 * class is also a small Dependency Injection Container for phpMyFAQ.
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Configuration
 * @author    <NAME> <<EMAIL>>
 * @copyright 2006-2013 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2006-01-04
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    exit();
}

/**
 * Configuration
 *
 * @category  phpMyFAQ
 * @package   Configuration
 * @author    <NAME> <<EMAIL>>
 * @copyright 2006-2013 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2006-01-04
 */
class PMF_Configuration
{
    /**
     * Tablename
     *
     * @var string
     */
    protected $_tableName = 'faqconfig';

    /**
     * Configuration array
     *
     * @var array
     */
    public $config = array();

    /**
     * Constructor
     *
     * @param PMF_DB_Driver $database
     *
     * @return PMF_Configuration
     */
    public function __construct(PMF_DB_Driver $database)
    {
        $this->setDb($database);
    }

    /**
     * Fetches all configuration items into an array
     *
     * @return void
     */
    public function getAll()
    {
        $query = sprintf("
            SELECT
                config_name, config_value
            FROM
                %s%s",
            PMF_Db::getTablePrefix(),
            $this->_tableName
        );
            
        $result = $this->getDb()->query($query);
        $config = $this->getDb()->fetchAll($result);
        
        foreach ($config as $items) {
            $this->config[$items->config_name] = $items->config_value;
        }
        
    }

    /**
     * Returns a configuration item
     *
     * @param  string $item Configuration item
     *
     * @return mixed
     */
    public function get($item)
    {
        if (!isset($this->config[$item])) {
            $this->getAll();
        }
        switch ($this->config[$item]) {
            case 'true':
                return true;
                break;
            case 'false':
                return false;<commit_msg>Added missing try/catch block (#771)<commit_after><?php
/**
 * The main class for fetching the configuration, update and delete items. This
 * class is also a small Dependency Injection Container for phpMyFAQ.
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Configuration
 * @author    <NAME> <<EMAIL>>
 * @copyright 2006-2013 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2006-01-04
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    exit();
}

/**
 * Configuration
 *
 * @category  phpMyFAQ
 * @package   Configuration
 * @author    <NAME> <<EMAIL>>
 * @copyright 2006-2013 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2006-01-04
 */
class PMF_Configuration
{
    /**
     * Tablename
     *
     * @var string
     */
    protected $_tableName = 'faqconfig';

    /**
     * Configuration array
     *
     * @var array
     */
    public $config = array();

    /**
     * Constructor
     *
     * @param PMF_DB_Driver $database
     *
     * @return PMF_Configuration
     */
    public function __construct(PMF_DB_Driver $database)
    {
        $this->setDb($database);
    }

    /**
     * Fetches all configuration items into an array
     *
     * @return void
     */
    public function getAll()
    {
        $query = sprintf("
            SELECT
                config_name, config_value
            FROM
                %s%s",
            PMF_Db::getTablePrefix(),
            $this->_tableName
        );
            
        $result = $this->getDb()->query($query);
        try {
            $config = $this->getDb()->fetchAll($result);
        } catch (Exception $e) {
            // @todo Added proper handling of exception
            echo $e->getMessage();
        }
        foreach ($config as $items) {
            $this->config[$items->config_name] = $items->config_value;
        }
        
    }

    /**
     * Returns a configuration item
     *
     * @param  string $item Configuration item
     *
     * @return mixed
     */
    public function get($item)
    {
        if (!isset($this->config[$item])) {
            $this->getAll();
        }
        switch ($this->config[$item]) {
            case 'true':
                return true;
                break;
            case 'false':
                return false;
{'fraction_non_alphanumeric': 0.12659698025551683, 'fraction_numerical': 0.018389469608981805, 'mean_word_length': 1.8219552157291097, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, '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': '4649928', 'n_tokens_mistral': 1635, 'n_tokens_neox': 1527, 'n_words': 401}