Jamm\Autoload\Autoloader::find_in_namespaces PHP Method

find_in_namespaces() private method

Find path to the file of class in registered namespaces (root namespace is registered automatically)
private find_in_namespaces ( string $class ) : boolean | string
$class string
return boolean | string
    private function find_in_namespaces($class)
    {
        if (empty($this->namespaces_dirs)) {
            return false;
        }
        $pos = strrpos($class, '\\');
        if ($pos !== false) {
            $namespace = substr($class, 0, $pos + 1);
            $class_name = str_replace('_', DIRECTORY_SEPARATOR, substr($class, $pos + 1));
        } else {
            $class_name = str_replace('_', DIRECTORY_SEPARATOR, $class);
            $pos = strrpos($class_name, DIRECTORY_SEPARATOR);
            $namespace = str_replace(DIRECTORY_SEPARATOR, '\\', substr($class_name, 0, $pos + 1));
            $class_name = substr($class_name, $pos + 1);
        }
        if (count($this->namespaces_dirs) > 1) {
            foreach ($this->namespaces_dirs as $ns => $dir) {
                if (stripos($namespace, $ns) === 0) {
                    $filepath = $this->lookFileInNamespaceDir($namespace, $ns, $class_name, $dir);
                    if (!empty($filepath)) {
                        return $filepath;
                    }
                }
            }
        }
        $dir = $this->namespaces_dirs[''];
        $filepath = $this->lookFileInNamespaceDir($namespace, '', $class_name, $dir);
        if (!empty($filepath)) {
            return $filepath;
        }
        return false;
    }