for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Everlution\Navigation;
use Everlution\Navigation\Item\RegistrableItemInterface;
/**
* Class Registry.
*
* @author Ivan Barlog <[email protected]>
*/
class Registry
{
/** @var MutableContainerInterface[] */
private $registry = [];
* @param MutableContainerInterface $container
* @throws ContainerAlreadyRegisteredException
public function addContainer(MutableContainerInterface $container): void
$containerName = get_class($container);
if (array_key_exists($containerName, $this->registry)) {
throw new ContainerAlreadyRegisteredException($containerName);
}
$this->registry[$containerName] = $container;
public function register(RegistrableItemInterface $item): void
foreach ($item->getRegisteredContainerNames() as $containerName) {
if (false === array_key_exists($containerName, $this->registry)) {
continue;
$this->registry[$containerName]->add($item);
* @param string $containerName
* @return MutableContainerInterface
* @throws ContainerIsNotRegisteredException
public function getContainer(string $containerName): MutableContainerInterface
throw new ContainerIsNotRegisteredException($containerName);
return $this->registry[$containerName];