final public static function autoload($className)
    {
        if (\Phar::running() && defined('PHAR_SWAGGER_VALIDATOR_ROOT_PATH')) {
            $baseDir = PHAR_SWAGGER_VALIDATOR_ROOT_PATH;
        }
        elseif (\Phar::running()) {
            $baseDir = null;
        }
        else {
            $baseDir = __DIR__ . DIRECTORY_SEPARATOR;
        }

        $thisClass = 'SwaggerValidator';

        $namespace = explode('\\', $className);
        $className = array_pop($namespace);
        $rootPath  = array_shift($namespace);

        if ($rootPath == $thisClass) {
            $namespace = $baseDir . trim(implode(DIRECTORY_SEPARATOR, $namespace), DIRECTORY_SEPARATOR);
        }
        else {
            $namespace = $baseDir . trim($rootPath . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $namespace), DIRECTORY_SEPARATOR);
        }

        if (substr($namespace, -1, 1) != DIRECTORY_SEPARATOR) {
            $namespace .= DIRECTORY_SEPARATOR;
        }

        if ($namespace == DIRECTORY_SEPARATOR) {
            $namespace = "";
        }

        $fileName = $namespace . str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';

        if (file_exists($fileName)) {
            require_once $fileName;
        }
    }