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\Common;
use Spiral\Core\Config;
use Spiral\Core\Options;
/**
* @internal
*/
final class Registry
{
* @param array<string, object> $objects
public function __construct(
private Config $config,
private array $objects = [],
private Options $options = new Options(),
) {
}
public function set(string $name, object $value): void
$this->objects[$name] = $value;
* @template T
*
* @param class-string<T> $interface
class-string<T>
0
* @return T
public function get(string $name, string $interface): object
$className = $this->config->$name;
$result = $this->objects[$name] ?? new $className($this);
\assert($result instanceof $interface);
return $result;
public function getOptions(): Options
return $this->options;