Add or replace an adapter with a fully qualified class name.

@throws \RuntimeException

@param  string $name
@param  string $class

@return $this
352526
public function registerAdapter($name, $class)
    {
        if (!is_subclass_of($class, AdapterInterface::class)) {
            throw new \RuntimeException(sprintf(
                'Adapter class "%s" must implement ' . AdapterInterface::class,
                $class
            ));
        }
        $this->adapters[$name] = $class;

        return $this;
    }
1039995
public function api(string $name): API\AbstractAPI
    {
        $name = ucfirst($name);
        $class = "ArkEcosystem\\Client\\API\\{$name}";

        if (! class_exists($class)) {
            throw new RuntimeException("Class [$class] does not exist.");
        }

        return new $class($this);
    }
1252816
public function setAdapterClass($name, $adapterClass)
    {
        $this->adapterClasses[$name] = $adapterClass;
        unset($this->adapters[$name]);
    }
1003685
protected function addClass(string $class)
    {
        if ($this->initialized) {
            throw new RuntimeException("You can't register provider class as registry as been initialized.");
        }

        if (!class_exists($class)) {
            throw new InvalidArgumentException("Class $class does not exist.");
        }

        if (!is_subclass_of($class, ProviderInterface::class)) {
            throw new InvalidArgumentException("Class $class must implement " . ProviderInterface::class);
        }

        $this->classes[] = $class;
    }
1276357
public static function registerExtensionClass(string $name, string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        if (self::$extension_classes === null) {
            self::$extension_classes = [];
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Extension") === true) {
            self::$extension_classes[$name] = $class;
            return true;
        } else {
            return false;
        }
    }
288214
public static function registerPluginClass(string $name, string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        if (self::$plugin_classes === null) {
            self::$plugin_classes = [];
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Plugin") === true) {
            self::$plugin_classes[$name] = $class;
            return true;
        } else {
            return false;
        }
    }
546161
public function addClass($name)
    {
        foreach ($this as $node) {
            if ($node instanceof \DOMElement) {
                /** @var \DOMElement $node */
                $classes = preg_split('/\s+/s', $node->getAttribute('class'));
                $found = false;
                $count = count($classes);
                for ($i = 0; $i < $count; $i++) {
                    if ($classes[$i] == $name) {
                        $found = true;
                    }
                }
                if (!$found) {
                    $classes[] = $name;
                    $node->setAttribute('class', trim(join(' ', $classes)));
                }
            }
        }
        return $this;
    }
940143
public function on($class)
    {
        $this->instance = is_string($class) ? $this->container !== null ? $this->container->make($class) : new $class : $class;
        
        return $this;
    }
1005288
public function optional($name, $class)
    {
        if (isset($this->$name) and !Utilities::isSubclassOf($this->$name, $class)) {
            throw new InvalidModuleException(
                'The module "' . $name . '" of type ' . get_class($this->$name)
                . ' was expected by ' . Utilities::getCaller()
                . ' to be of type ' . $class
            );
        }
    }
524143
static function annotationClass($name)
	{
		if (!AnnotationRegistry::loadAnnotationClass($name)) {
			throw new \Doctrine\Common\Annotations\AnnotationException('Annotation ' . $name . ' - not exists');
		}

		return new $name;
	}
354660
private function loadModuleFromClass(string $name, $moduleClass) : IModule
    {
        if (is_callable($moduleClass)) {
            $moduleFactory = function () use ($moduleClass, $name) {
                return $moduleClass($this, $name);
            };
        } else {
            $moduleFactory = function () use ($moduleClass) {
                return $this->container->get($moduleClass);
            };
        }

        if (is_string($moduleClass) && !is_subclass_of($moduleClass, IModule::class, true)) {
            throw InvalidArgumentException::format(
                'Invalid module class defined within package \'%s\': expecting subclass of %s, %s given',
                $this->name, IModule::class, $moduleClass
            );
        }

        $this->loadingModules[$name] = true;

        /** @var IAuthSystem $authSystem */
        $authSystem = $this->container->get(IAuthSystem::class);

        /** @var IModule $module */
        $module = $this->container->bindForCallback(
            IAuthSystem::class,
            $authSystem->inPackageContext($this->container, $this->name),
            $moduleFactory
        );

        unset($this->loadingModules[$name]);

        if ($module->getName() !== $name) {
            throw InvalidArgumentException::format(
                'Invalid module class defined within package \'%s\': defined module name \'%s\' does not match module name \'%s\' from instance of %s',
                $this->name, $name, $module->getName(), get_class($module)
            );
        }

        return $module;
    }
259291
public function adapter(?string $name = null): AdapterInterface
	{
		$name = $name ?? $this->defaultAdapter;

		return $this->adapters[$name] ?? $this->adapterFactory($name);
	}
313493
public function registerCustomDoctrineType($class, $name, $type)
    {
        if (! $this->connection->isDoctrineAvailable()) {
            throw new RuntimeException(
                'Registering a custom Doctrine type requires Doctrine DBAL (doctrine/dbal).'
            );
        }

        if (! Type::hasType($name)) {
            Type::addType($name, $class);

            $this->connection
                ->getDoctrineSchemaManager()
                ->getDatabasePlatform()
                ->registerDoctrineTypeMapping($type, $name);
        }
    }
1317348
public function setRepositoryClass($name, $class)
  {
    if (!class_exists($class) || !in_array('SQRT\DB\Repository', class_parents($class))) {
      Exception::ThrowError(Exception::NOT_REPOSITORY, $class);
    }

    $this->repositories[strtolower($name)] = $class;

    return $this;
  }
483647
public function addConfiguration($name, array $config)
    {
        if(array_key_exists($name, $this->configs)) {
            throw new \RuntimeException(
                "Connection with given name already exists!"
            );
        }

        $this->configs[$name] = $config;
    }
1158736
protected function getWrapperClass($name)
    {
        if (empty($this->wrappers[$name])) {
            throw new \RuntimeException(sprintf(
                'Wrapper "%s" has not been registered',
                $name
            ));
        }

        return $this->wrappers[$name];
    }
97170
public function loadClass($class)
    {
        if ($file = $this->classFinder->findFile($class)) {
            require $file;

            if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) {
                if (false !== strpos($class, '/')) {
                    throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class));
                }

                throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file));
            }

            return true;
        }
    }