<?php
namespace Se7enChat\src;

class Autoloader
{
    private $projectRoot;

    public function __construct($projectRoot)
    {
        $this->projectRoot = $projectRoot;
    }

    public function load()
    {
        spl_autoload_register(function($className)
        {
            if (preg_match('/^Se7enChat/', $className)) {
                require $this->projectRoot . str_replace('\\', '/', $className . '.php');
            }
        });
    }
}

<?php
namespace Se7enChat\src;

class Autoloader
{
    private $projectRoot;

    public function __construct($projectRoot)
    {
        $this->projectRoot = $projectRoot;
    }

    public function load()
    {
        spl_autoload_register(array($this, 'requireFile'));
    }

    private function requireFile($className)
    {
        $path = sprintf('%s%s.php',
            $this->projectRoot, str_replace('\\', '/', $className));
        if (preg_match('/^Se7enChat/', $className)) {
            require $path;
        }
    }
}

Refactor autoloader to clean it up a bit.
Refactor autoloader to clean it up a bit.

Signed-off-by: Se7enChat <e5dc7202134ade0d04c45466a5972470210b05f6@zoho.com>
