@param string          $name
@param string|callable $moduleClass

@return IModule
@throws InvalidArgumentException
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;
    }
456399
public function getModule($name)
    {
        if (!isset($this->modules[$name])) {
            throw new \LogicException(sprintf('The module "%s" don\'t exists.', $name));
        }
        return $this->modules[$name];
    }
438320
public function register($name, $class, $requirement = '', $priority = false)
    {
        if (!class_exists($class)) {
            throw new \InvalidArgumentException(sprintf('%s is not a valid class name.', $class));
        }

        $definition = [
            'class'       => $class,
            'requirement' => $requirement
        ];

        if ($priority) {
            $this->classes = array_merge_recursive([$name => $definition], $this->classes);
        } else {
            $this->classes[$name] = $definition;
        }
    }
1078243
private function createMethod(string $name): MethodInterface
    {
        $class = 'Ekyna\\Component\\Dpd\\EPrint\\Method\\' . ucwords($name);
        if (class_exists($class)) {
            /** @var MethodInterface $instance */
            return new $class($this->getClient());
        }

        throw new RuntimeException("Method {$name} does not exist");
    }
1341504
public static function get($name, &$args, &$options, &$called)
    {
        $moduleClass = 'Xiphe\HTML\modules\\'.ucfirst($name);

        if (!isset(self::$_loadedModules[$name])) {
            self::$_loadedModules[$name] = new $moduleClass();
            self::$_loadedModules[$name]->name = $name;
        }

        self::$_loadedModules[$name]->init($args, $options, $called);
        return self::$_loadedModules[$name];
    }
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;
        }
    }
843568
public static function overrideType($name, $class, $phpTypeName = null)
    {
        if (!is_subclass_of($class, static::class)) {
            throw new BadArgumentException('Class :class should been subclass of :subClass', [
                'class' => $class, 'subClass' => static::class,
            ]);
        }
        
        if (null !== $phpTypeName) {
            static::$phpNamesMap[$name] = $phpTypeName;
        }
        
        static::$typesMap[$name] = $class;
    }
999376
public function getModuleClass ($name = FALSE)
	{
		
		// Set name if none is passed
		
		if ($name === FALSE)
		{
			$name	= $this->get ('name');
		}
		
		// Convert . in module name to \
		// and ucfirst each section
		
		$arr	= explode ('.', $name);
		
		foreach ($arr as &$val)
		{
			$val	= ucfirst ($val);
		}
		
		$name	= implode ('\\', $arr);
		
		// Return module class
		
		return get_called_class () . '\\' . $name;
		
	}
1323011
private function createMethod(string $name): MethodInterface
    {
        $methodClass = $clientClass = null;

        foreach (['Postage', 'Tracking', 'Withdrawal'] as $ns) {
            $class = 'Ekyna\\Component\\Colissimo\\' . $ns . '\\Method\\' . ucwords($name) . 'Method';
            if (class_exists($class)) {
                $methodClass = $class;
                $clientClass = 'Ekyna\\Component\\Colissimo\\' . $ns . '\\Client';
                break;
            }
        }

        if (is_null($methodClass)) {
            throw new RuntimeException("Method {$name} does not exist");
        }

        return new $methodClass($this->factory->getClient($clientClass));
    }
1130440
protected function qualifyClass($name)
    {
        try {
            $location = $this->option('location') ?: config('modules.default_location');
        }
        catch (\Exception $e) {
            $location = config('modules.default_location');
        }

        $rootNamespace = config("modules.locations.$location.namespace");

        if (Str::startsWith($name, $rootNamespace)) {
            return $name;
        }

        $name = str_replace('/', '\\', $name);

        return $this->qualifyClass(
            $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
        );
    }
524898
public function of($class, $name = 'default')
    {
        return new FactoryBuilder($this->manager, $class, $name, $this->definitions, $this->states, $this->faker);
    }
1012099
protected function &internalGetModular(string $name) : ModularAbstract
    {
        $modularName = $this->sanitizeModularName($name);
        if (!$modularName) {
            throw new InvalidArgumentException(
                "Please insert not an empty arguments",
                E_USER_ERROR
            );
        }

        if (!$this->exist($modularName)) {
            throw new InvalidModularException(
                sprintf(
                    '%1$s %2$s has not found',
                    $this->modularParser->getName(),
                    $name
                )
            );
        }

        if (is_array($this->validModular[$modularName])) {
            $className = empty($this->validModular[$modularName][static::CLASS_NAME_KEY])
                ? null
                : (string) $this->validModular[$modularName][static::CLASS_NAME_KEY];

            if (! $className
                || ! class_exists($this->validModular[$modularName][static::CLASS_NAME_KEY])
            ) {
                throw new InvalidModularException(
                    sprintf(
                        '%1$s %2$s has not found',
                        $this->modularParser->getName(),
                        $name
                    )
                );
            }

            $modular = new $className(
                $this->modularParser->getContainer(),
                $modularName
            );

            $this->validModular[$modularName] = $modular;
        }

        if (! $this->validModular[$modularName] instanceof ModularAbstract) {
            unset($this->validModular[$modularName]);
            $e = new InvalidModularException(
                sprintf(
                    '%1$s %2$s Is not valid.',
                    $this->modularParser->getName(),
                    $name
                )
            );

            $this->invalidModular[$modularName] = $e;
            throw $e;
        }

        return $this->validModular[$modularName];
    }
567145
public function getModule($name)
    {
        if (!isset($this->modules[$name])) {
            throw new ModuleNotFoundException();
        }

        return $this->modules[$name];
    }
1169298
protected function _loadCollection($name)
    {
        if ($name === self::DEFAULT_COLLECTION) {
            $class = $this->_collectionClass;
        } else {
            $class = Inflector::camelize(str_replace('-', '_', $name));
        }

        $className = App::className($class, 'Model/Filter', 'Collection');
        if (!$className) {
            throw new InvalidArgumentException(sprintf(
                'The collection class "%sCollection" does not exist',
                $class
            ));
        }

        $instance = new $className($this);
        if (!$instance instanceof FilterCollectionInterface) {
            throw new InvalidArgumentException(sprintf(
                'The collection must be instance of FilterCollectionInterface. ' .
                'Got instance of "%s" instead',
                get_class($instance)
            ));
        }

        return $instance;
    }
304951
public function addCallback(string $name, $callback)
    {
        if (!is_object($callback)) {
            throw new \InvalidArgumentException('Given callback must be an object');
        }

        $this->callbacks[$name] = $callback;
    }
324548
private function resolveConventionClass(string $name)
    {
        if ('default' == $name) {
            return ConcordDefault::class;
        } elseif (class_exists($name)) {
            return $name;
        }

        throw new InvalidArgumentException(
            sprintf('%s is not a valid convention class', $name)
        );
    }
311476
public function a_class( $name, $content, $extends = null, $implements = null )
	{
		return $this->add( $this->closure( "class ".$name.
			( $extends ? ' extends '.$extends : '' ).
			( $implements ? ' implements '.$implements : '' ), $content ) );
	}