for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DrMVC;
//use Psr\Container\ContainerInterface;
//use Psr\Container\NotFoundExceptionInterface;
use DrMVC\Config\ConfigInterface;
class App implements AppInterface
{
private $_containers = [];
public function __construct(ConfigInterface $config)
$this->setContainer('config', $config);
}
/**
* @param string $name
* @return mixed
*/
private function getContainer(string $name)
return $this->_containers[$name];
* @param object $object
* @return AppInterface
private function setContainer(string $name, $object): AppInterface
$this->_containers[$name] = $object;
return $this;
* PSR-11 set container
*
* @param string $container
* @param string $object
* @param ConfigInterface $config
public function set(string $container, string $object, ConfigInterface $config): AppInterface
$objectConfig = $config->get($object);
if (null !== $objectConfig) {
$class = '\\DrMVC\\' . $object;
$this->setContainer($container, new $class($config));
* Get container by name
public function get($name)
// TODO: NotFoundExceptionInterface
return $this->has($name) ?? $this->getContainer($name);
* Container is exist
* @return bool
public function has($name): bool
return isset($this->_containers[$name]);