public function getClassByPath($file, $namespace)
    {
        $absPath    = realpath($file);
        $namespaces = explode('/', $absPath);
        $start      = false;
        $i          = 0;
        $chunk      = explode('\\', $namespace);
        $namespace  = array_shift($chunk);

        while ($namespaces[$i] != $namespace) {
            unset($namespaces[$i]);

            if (!array_key_exists(++$i, $namespaces)) {
                break;
            }
        }

        $className = str_replace('.php', null, array_pop($namespaces));

        return '\\'. implode('\\', $namespaces) . '\\' . $className;
    }
public function getClassByPath($file, $namespace)
    {
        $absPath    = realpath($file);
        $namespaces = explode('/', $absPath);
        $start      = false;
        $i          = 0;
        $chunk      = explode('\\', $namespace);
        $namespace  = array_shift($chunk);

        while ($namespaces[$i] != $namespace) {
            unset($namespaces[$i]);

            if (!array_key_exists(++$i, $namespaces)) {
                break;
            }
        }

        $className = str_replace('.php', null, array_pop($namespaces));

        return '\\'. implode('\\', $namespaces) . '\\' . $className;
    }
public function getClassByPath ( $ file , $ namespace ) { $ absPath = realpath ( $ file ) ; $ namespaces = explode ( '/' , $ absPath ) ; $ start = false ; $ i = 0 ; $ chunk = explode ( '\\' , $ namespace ) ; $ namespace = array_shift ( $ chunk ) ; while ( $ namespaces [ $ i ] != $ namespace ) { unset ( $ namespaces [ $ i ] ) ; if ( ! array_key_exists ( ++ $ i , $ namespaces ) ) { break ; } } $ className = str_replace ( '.php' , null , array_pop ( $ namespaces ) ) ; return '\\' . implode ( '\\' , $ namespaces ) . '\\' . $ className ; }
Returns the fully qualified name of a class by its path

@param  string $file
@param  string $namespace
@return string
Returns the fully qualified name of a class by its path