<commit_before><?php

/**
 * Reader.php - Jaxon config reader
 *
 * @package jaxon-core
 * @author <NAME> <<EMAIL>>
 * @copyright 2016 <NAME> <<EMAIL>>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

namespace Jaxon\Utils\Config;

class Reader
{
    /**
     * Read options from a config file
     *
     * @param string        $sConfigFile        The full path to the config file
     *
     * @return array
     */
    public function read($sConfigFile)
    {
        $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION);
        switch($sExt)
        {
        case 'php':
            $aConfigOptions = Php::read($sConfigFile);
            break;
        case 'yaml':
        case 'yml':
            $aConfigOptions = Yaml::read($sConfigFile);
            break;
        case 'json':
            $aConfigOptions = Json::read($sConfigFile);
            break;
        default:
            $sErrorMsg = jaxon_trans('config.errors.file.extension', ['path' => $sConfigFile]);
            throw new \Jaxon\Utils\Config\Exception\File($sErrorMsg);
        }

        return $aConfigOptions;
    }

    /**
     * Read options from a config file and setup the library
     *
     * @param string        $sConfigFile        The full path to the config file
     * @param string        $sConfigSection     The section of the config file to be loaded<commit_msg>The config reader checks if the filename is empty.<commit_after><?php

/**
 * Reader.php - Jaxon config reader
 *
 * @package jaxon-core
 * @author <NAME> <<EMAIL>>
 * @copyright 2016 <NAME> <<EMAIL>>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

namespace Jaxon\Utils\Config;

class Reader
{
    /**
     * Read options from a config file
     *
     * @param string        $sConfigFile        The full path to the config file
     *
     * @return array
     */
    public function read($sConfigFile)
    {
        if(!($sConfigFile = trim($sConfigFile)))
        {
            return [];
        }

        $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION);
        switch($sExt)
        {
        case 'php':
            $aConfigOptions = Php::read($sConfigFile);
            break;
        case 'yaml':
        case 'yml':
            $aConfigOptions = Yaml::read($sConfigFile);
            break;
        case 'json':
            $aConfigOptions = Json::read($sConfigFile);
            break;
        default:
            $sErrorMsg = jaxon_trans('config.errors.file.extension', ['path' => $sConfigFile]);
            throw new \Jaxon\Utils\Config\Exception\File($sErrorMsg);
        }

        return $aConfigOptions;
    }

    /**
     * Read options from a config file and setup the library
     *
     * @param string        $sConfigFile        The full path to the config file
     * @param string        $sConfigSection     The section of the config file to be loaded
{'fraction_non_alphanumeric': 0.11717709720372836, 'fraction_numerical': 0.0039946737683089215, 'mean_word_length': 2.0110220440881763, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 4, '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': '940482', 'n_tokens_mistral': 895, 'n_tokens_neox': 865, 'n_words': 228}