for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Spiral\Core\Internal\Proxy;
use Spiral\Core\ContainerScope;
use Spiral\Core\Exception\Container\ContainerException;
/**
* @internal
*/
final class Resolver
{
public static function resolve(string $alias): object
$c = ContainerScope::getContainer() ?? throw new ContainerException('Proxy is out of scope.');
try {
$result = $c->get($alias) ?? throw new ContainerException(
'Resolved `null` from the container.',
);
} catch (ContainerException $e) {
throw new ContainerException(
// todo : find required scope
\sprintf('Unable to resolve `%s` in a Proxy.', $alias),
previous: $e,
}
return $result;