src/Samurai/Component/Core/Namespacer.php
public static function pickRootDir($path)
    {
        // when relational path.
        if ($path[0] !== '/') return $path;
        
        $f = function($names, $count) {
            for ($i = 0; $i < $count; $i++) {
                array_pop($names);
            }
            return $names;
        };

        $root = null;
        foreach (self::$namespaces as $p => $ns) {
            $d = join(DS, $f(explode(DS, $p), count(explode('\\', $ns))));
            if (strpos($path, $d) === 0) {
                if ($root === null || strlen($root) < strlen($d)) $root = $d;
            }
        }

        return $root ? $root : $path;
    }
public static function pickRootDir($path)
    {
        // when relational path.
        if ($path[0] !== '/') return $path;
        
        $f = function($names, $count) {
            for ($i = 0; $i < $count; $i++) {
                array_pop($names);
            }
            return $names;
        };

        $root = null;
        foreach (self::$namespaces as $p => $ns) {
            $d = join(DS, $f(explode(DS, $p), count(explode('\\', $ns))));
            if (strpos($path, $d) === 0) {
                if ($root === null || strlen($root) < strlen($d)) $root = $d;
            }
        }

        return $root ? $root : $path;
    }
public static function pickRootDir ( $ path ) { // when relational path. if ( $ path [ 0 ] !== '/' ) return $ path ; $ f = function ( $ names , $ count ) { for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { array_pop ( $ names ) ; } return $ names ; } ; $ root = null ; foreach ( self :: $ namespaces as $ p => $ ns ) { $ d = join ( DS , $ f ( explode ( DS , $ p ) , count ( explode ( '\\' , $ ns ) ) ) ) ; if ( strpos ( $ path , $ d ) === 0 ) { if ( $ root === null || strlen ( $ root ) < strlen ( $ d ) ) $ root = $ d ; } } return $ root ? $ root : $ path ; }
pick the root dir from some path.

@access  public
@param   string  $path
@return  string
pick the root dir from some path .