<commit_before><?php

namespace Gears\Framework\App;

/**
 * Provides classes autoload functionality
 * @package    Gears\Framework
 * @subpackage App
 */
class Autoloader
{
    private $namespacePrefix;
    private $includePath;
    private static $ns = '\\';
    private static $ds = DIRECTORY_SEPARATOR;

    /**
     * Register a set of namespace prefixes and their base directories
     * @param array $vendors
     */
    public static function registerNamespaces(array $vendors)
    {
        foreach ($vendors as $namespacePrefix => $includePath) {
            (new self($namespacePrefix, $includePath))->register();
        }
    }

    /**
     * @param string $namespacePrefix
     * @param string $includePath The base include path from within to load classes
     */
    public function __construct($namespacePrefix, $includePath)
    {
        // store fully qualified namespace prefix
        $this->namespacePrefix = rtrim(self::$ns . ltrim($namespacePrefix, self::$ns), self::$ns) . self::$ns;
        // store normalized base include path
        $this->includePath = rtrim($includePath, self::$ds) . self::$ds;
    }

    /**
     * Register current loader
     * @return bool
     */
    public function register()
    {
        return spl_autoload_register([$this, 'loadClass']);
    }

    /**
     * Try to load the given class by matching its full name against the registered
     * namespace prefixes and then transforming it into class file full path
     * @param string $className
     */
    public function loadClass($className)
    {
        // getting fully qualified class name
        $className = self::$ns . ltrim($className, self::$ns);
        if (0 === strpos($className, $this->namespacePrefix)) {
            $relativeClassName = substr($className, strlen($this->namespacePrefix));
            $fileName = $this->includePath . str_replace(self::$ns, self::$ds, $relativeClassName) . '.php';
            if (is_file($fileName)) {<commit_msg>A bit simplified Autoloader in order to be compatible with upcoming PSR-4<commit_after><?php

namespace Gears\Framework\App;

/**
 * Provides classes autoload functionality. Follows to yet non accpetped PSR-4 proposal
 * (https://github.com/php-fig/fig-standards/blob/master/proposed/psr-4-autoloader/psr-4-autolader.md)
 * @package    Gears\Framework
 * @subpackage App
 */
class Autoloader
{
    /**
     * Namespace prefix by which to match a loaded class name
     * @var string
     */
    private $namespacePrefix;
    
    /**
     * Full path to the directory from within to load class files
     * @var string
     */
    private $includePath;
    
    /**
     * Namespace separator shortuct
     * @var string
     */
    private static $ns = '\\';
    
    /**
     * Directory separator shortcut
     * @var string
     */
    private static $ds = DIRECTORY_SEPARATOR;

    /**
     * Register a set of namespace prefixes and their base directories
     * @param array $vendors
     */
    public static function registerNamespaces(array $vendors)
    {
        foreach ($vendors as $namespacePrefix => $includePath) {
            (new self($namespacePrefix, $includePath))->register();
        }
    }

    /**
     * @param string $namespacePrefix
     * @param string $includePath The base include path from within to load classes
     */
    public function __construct($namespacePrefix, $includePath)
    {
        // store normalized namespace prefix
        $this->namespacePrefix = rtrim($namespacePrefix, self::$ns) . self::$ns;
        // store normalized base include path
        $this->includePath = rtrim($includePath, self::$ds) . self::$ds;
    }

    /**
     * Register current loader
     * @return bool
     */
    public function register()
    {
        return spl_autoload_register([$this, 'loadClass']);
    }

    /**
     * Try to load the given class by matching its full name against the registered
     * namespace prefixes and then transforming it into class file full path
     * @param string $className
     */
    public function loadClass($className)
    {
        if (0 === strpos($className, $this->namespacePrefix)) {
            $relativeClassName = substr($className, strlen($this->namespacePrefix));
            $fileName = $this->includePath . str_replace(self::$ns, self::$ds, $relativeClassName) . '.php';
            if (is_file($fileName)) {
{'fraction_non_alphanumeric': 0.11504222780187172, 'fraction_numerical': 0.0013695503309746632, 'mean_word_length': 2.6455906821963393, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '7628342', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1189, 'n_words': 352}