Completed
Push — master ( d11b01...1c170b )
by Daniel
17:01 queued 13:33
created

ContentTypeExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFunctions() 0 6 1
A renderContent() 0 4 1
1
<?php
2
3
namespace Psi\Bridge\ContentType\Twig;
4
5
use Psi\Component\ContentType\View\View;
6
7
class ContentTypeExtension extends \Twig_Extension
8
{
9
    private $renderer;
10
11
    public function __construct(TwigRenderer $renderer)
12
    {
13
        $this->renderer = $renderer;
14
    }
15
16
    public function getFunctions()
17
    {
18
        return [
19
            new \Twig_SimpleFunction('psi_content_render', [$this, 'renderContent'], ['is_safe' => ['html']]),
20
        ];
21
    }
22
23
    public function renderContent(View $view)
24
    {
25
        return $this->renderer->render($view);
26
    }
27
}
28