<commit_before><?php
/**
 * Hostingcheck (https://github.com/zero2one/hostingcheck)
 *
 * @link      https://github.com/zero2one/hostingcheck source repository.
 * @copyright Copyright (c) 2014 Serial Graphics (http://serial-graphics.be)
 * @license   http://opensource.org/licenses/GPL-2.0 GNU Public License
 */


/**
 * Class Hostingcheck_Autoloader
 *
 * Autoloader provider for the hostingcheck project.
 *
 * @author <NAME> <<EMAIL>>
 */
class Hostingcheck_Autoloader {
    /**
     * Constructor registers itself to the autoload registry.
     */
    public function __construct() {
        spl_autoload_register(array($this, 'loader'));
    }
    
    /**
     * The loader method.
     *
     * @param string $className
     *      The name of the class that needs to be automatically loaded.
     */
    private function loader($className) {
        $path = explode('_', $className);
        $file = null;

        // List of class "namespaces" we support.
        $whitelist = array(
            'Hostingcheck' => 'Lib',
            'Check' => null,
        );

        // Autoload Hostingcheck classes.
        if ($path[0] === 'Hostingcheck') {
            // Construct the file path.
            $path[0] .= DIRECTORY_SEPARATOR . 'Lib';
            $file = implode(DIRECTORY_SEPARATOR, $path) . '.php';
        }

        // Autoload Check classes.
        if ($path[0] === 'Check') {
            $path[-1] = 'Hostingcheck';
            ksort($path);
            $file = implode(DIRECTORY_SEPARATOR, $path) . '.php';
        }

        if ($file) {
            include HOSTINGCHECK_BASEPATH . $file;
        }
    }
}<commit_msg>Decrease the complexity of the Autoload class.<commit_after><?php
/**
 * Hostingcheck (https://github.com/zero2one/hostingcheck)
 *
 * @link      https://github.com/zero2one/hostingcheck source repository.
 * @copyright Copyright (c) 2014 Serial Graphics (http://serial-graphics.be)
 * @license   http://opensource.org/licenses/GPL-2.0 GNU Public License
 */


/**
 * Class Hostingcheck_Autoloader
 *
 * Autoloader provider for the hostingcheck project.
 *
 * @author <NAME> <<EMAIL>>
 */
class Hostingcheck_Autoloader {
    /**
     * Constructor registers itself to the autoload registry.
     */
    public function __construct() {
        spl_autoload_register(array($this, 'loader'));
    }
    
    /**
     * The loader method.
     *
     * @param string $className
     *      The name of the class that needs to be automatically loaded.
     */
    private function loader($className) {
        $path = explode('_', $className);
        $file = null;

        switch ($path[0]) {
            case 'Hostingcheck':
                $file = $this->hostingcheckFile($path);
                break;

            case 'Check':
                $file = $this->checkFile($path);
                break;

        }

        if ($file) {
            include HOSTINGCHECK_BASEPATH . $file;
        }
    }

    /**
     * Create the file path for Hostingcheck classes.
     *
     * @param array $path
     *     The class name split by the underscore.
     *
     * @return string
     *     The path to the file.
     */
    protected function hostingcheckFile($path)
    {
        $path[0] .= DIRECTORY_SEPARATOR . 'Lib';
        return implode(DIRECTORY_SEPARATOR, $path) . '.php';
    }

    /**
     * Create the file path for Check classes.
     *
     * @param array $path
     *     The class name split by the underscore.
     *
     * @return string
     *     The path to the file.
     */
    protected function checkFile($path)
    {
        $path[-1] = 'Hostingcheck';
        ksort($path);
        return implode(DIRECTORY_SEPARATOR, $path) . '.php';
    }
}
{'fraction_non_alphanumeric': 0.12742456896551724, 'fraction_numerical': 0.006196120689655173, 'mean_word_length': 1.9991922455573505, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '243076', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1092, 'n_words': 276}