Phprest\Service\Logger\Service::register PHP Method

register() public method

public register ( League\Container\ContainerInterface $container, Phprest\Service\Configurable $config ) : void
$container League\Container\ContainerInterface
$config Phprest\Service\Configurable
return void
    public function register(ContainerInterface $container, Configurable $config)
    {
        if (!$config instanceof Config) {
            throw new \InvalidArgumentException('Wrong Config object');
        }
        $logger = new Logger($config->name, $config->handlers);
        $container->add($config->getServiceName(), $logger);
    }

Usage Example

Example #1
0
 public function testGetter()
 {
     $service = new Service();
     $service->register($this->continer, new Config('anotherLoggerName'));
     $this->assertEquals('anotherLoggerName', $this->serviceLogger()->getName());
 }
Service