public function resolve($path)
{
if (rtrim($path, '\\/') !== $path) {
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw new AliasException('`:path` can not end with `/` or `\\`', ['path' => $path]);
}
if ($path[0] !== '@') {
return str_replace('\\', '/', $path);
}
if (strpos($path, '@ns.') === 0) {
$parts = explode('\\', $path, 2);
} else {
$path = str_replace('\\', '/', $path);
$parts = explode('/', $path, 2);
}
$alias = $parts[0];
if (!isset($this->_aliases[$alias])) {
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw new AliasException('`:alias` is not exists for `:path`', ['alias' => $alias, 'path' => $path]);
}
return str_replace($alias, $this->_aliases[$alias], $path);
}