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;
}