Passed
Push — master ( af5995...9e02f8 )
by Ole
02:03
created

src/Response/Handler/TwigResponseHandler.php (1 issue)

Labels
Severity
1
<?php
2
declare(strict_types=1);
3
4
namespace Basster\LazyResponseBundle\Response\Handler;
5
6
use Basster\LazyResponseBundle\Response\LazyResponseInterface;
7
use Basster\LazyResponseBundle\Response\TemplateResponse;
8
use Symfony\Component\HttpFoundation\Response;
9
use Twig\Environment;
10
11
/**
12
 * Class TemplateResponseHandler.
13
 */
14
final class TwigResponseHandler extends AbstractLazyResponseHandler
15
{
16
    /**
17
     * @var \Twig\Environment
18
     */
19
    private $twig;
20
21 4
    public function __construct(Environment $twig)
22
    {
23 4
        $this->twig = $twig;
24 4
    }
25
26 3
    protected function isSupported(LazyResponseInterface $controllerResult): bool
27
    {
28 3
        return $controllerResult instanceof TemplateResponse;
29
    }
30
31
    /**
32
     * @param TemplateResponse $controllerResult
33
     *
34
     * @psalm-suppress MoreSpecificImplementedParamType
35
     *
36
     * @throws \Twig\Error\LoaderError
37
     * @throws \Twig\Error\RuntimeError
38
     * @throws \Twig\Error\SyntaxError
39
     */
40 3
    protected function generateResponse(LazyResponseInterface $controllerResult): Response
41
    {
42 3
        return new Response($this->twig->render($controllerResult->getTemplate(), $controllerResult->getData()), $controllerResult->getStatus(), $controllerResult->getHeaders());
0 ignored issues
show
The method getStatus() does not exist on Basster\LazyResponseBund...e\LazyResponseInterface. It seems like you code against a sub-type of Basster\LazyResponseBund...e\LazyResponseInterface such as Basster\LazyResponseBund...bstractLazyHttpResponse. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
        return new Response($this->twig->render($controllerResult->getTemplate(), $controllerResult->getData()), $controllerResult->/** @scrutinizer ignore-call */ getStatus(), $controllerResult->getHeaders());
Loading history...
43
    }
44
}
45