Kahlan\Jit\Interceptor::findPath PHP Method

findPath() public method

Returns the path of a namespace or fully namespaced class name.
public findPath ( string $namespace, boolean $forceDir = false ) : string | null
$namespace string A namespace.
$forceDir boolean Only consider directories paths.
return string | null Returns the found path or `null` if not path is found.
    public function findPath($namespace, $forceDir = false)
    {
        $loader = static::originalInstance();
        $paths = static::getPrefixes();
        $logicalPath = trim(strtr($namespace, '\\', DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
        foreach ($paths as $prefix => $dirs) {
            if (strpos($namespace, $prefix) !== 0) {
                continue;
            }
            foreach ($dirs as $dir) {
                $root = $dir . DIRECTORY_SEPARATOR . substr($logicalPath, strlen($prefix));
                if ($path = $this->_path($root, $forceDir)) {
                    return realpath($path);
                }
            }
        }
    }