src/Managers/Modules.php
public function detect(string $class): Module
    {
        if (array_key_exists($class, $this->detect)) {
            return $this->get($this->detect[$class]);
        }

        if ($this->namespaces === null) {
            $this->namespaces = $this->all()->map(function (Module $module) {
                return $module->getNamespace();
            });
            arsort($this->namespaces);
        }

        foreach ($this->namespaces as $name => $namespace) {
            if (strpos($class, $namespace) === 0) {
                $this->detect[$class] = $name;

                return $this->get($name);
            }
        }
        throw new ModuleNotFoundException("Module for class '$class' not found.");
    }
public function detect(string $class): Module
    {
        if (array_key_exists($class, $this->detect)) {
            return $this->get($this->detect[$class]);
        }

        if ($this->namespaces === null) {
            $this->namespaces = $this->all()->map(function (Module $module) {
                return $module->getNamespace();
            });
            arsort($this->namespaces);
        }

        foreach ($this->namespaces as $name => $namespace) {
            if (strpos($class, $namespace) === 0) {
                $this->detect[$class] = $name;

                return $this->get($name);
            }
        }
        throw new ModuleNotFoundException("Module for class '$class' not found.");
    }
@param string $class

@return Module
@throws ModuleNotFoundException