Passed
Push — master ( 331ba5...3c8b93 )
by Arnold
11:07
created

Twig   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 1
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A view() 0 3 1
1
<?php
2
3
namespace Jasny\Controller\Traits;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Psr\Http\Message\ServerRequestInterface;
7
use Jasny\Controller\View\Twig as JasnyTwig;
8
use Slim\Views\Twig as SlimTwig;
9
use Twig\Error\LoaderError;
10
use Twig\Error\RuntimeError;
11
use Twig\Error\SyntaxError;
12
13
trait Twig
14
{
15
    private JasnyTwig|SlimTwig $twig;
16
17
    abstract protected function getResponse(): ResponseInterface;
18
19
    /**
20
     * Output rendered Twig template
21
     *
22
     * @throws RuntimeError
23
     * @throws SyntaxError
24
     * @throws LoaderError
25
     */
26
    protected function view(string $template, array $data = []): ResponseInterface
27
    {
28
        return $this->twig->render($this->getResponse(), $template, $data);
29
    }
30
}
31