PsrContainerRenderer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Midnight\Block\Renderer;
5
6
use Midnight\Block\BlockInterface;
7
use Psr\Container\ContainerExceptionInterface;
8
use Psr\Container\ContainerInterface;
9
10
class PsrContainerRenderer implements RendererInterface
11
{
12
    /** @var ContainerInterface */
13
    private $container;
14
15
    public function __construct(ContainerInterface $container)
16
    {
17
        $this->container = $container;
18
    }
19
20
    /**
21
     * @throws ContainerExceptionInterface
22
     */
23
    public function render(BlockInterface $block): string
24
    {
25
        return $this->container->get($block->getTypeName())->render($block);
26
    }
27
}
28