Basster /
lazy-response-bundle
| 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 | 5 | public function __construct(private Environment $twig) |
|||||||
|
0 ignored issues
–
show
|
|||||||||
| 17 | { |
||||||||
| 18 | 5 | } |
|||||||
| 19 | |||||||||
| 20 | 4 | protected function isSupported(LazyResponseInterface $controllerResult): bool |
|||||||
| 21 | { |
||||||||
| 22 | 4 | return $controllerResult instanceof TemplateResponse; |
|||||||
| 23 | } |
||||||||
| 24 | |||||||||
| 25 | /** |
||||||||
| 26 | * @param TemplateResponse $controllerResult |
||||||||
| 27 | * |
||||||||
| 28 | * @psalm-suppress MoreSpecificImplementedParamType |
||||||||
| 29 | * |
||||||||
| 30 | * @throws \Twig\Error\LoaderError |
||||||||
| 31 | * @throws \Twig\Error\RuntimeError |
||||||||
| 32 | * @throws \Twig\Error\SyntaxError |
||||||||
| 33 | */ |
||||||||
| 34 | 4 | protected function generateResponse(LazyResponseInterface $controllerResult): Response |
|||||||
| 35 | { |
||||||||
| 36 | 4 | return new Response($this->twig->render($controllerResult->getTemplate(), $controllerResult->getData()), $controllerResult->getStatusCode(), $controllerResult->getHeaders()); |
|||||||
|
0 ignored issues
–
show
The method
getHeaders() does not exist on Basster\LazyResponseBund...e\LazyResponseInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Basster\LazyResponseBund...e\LazyResponseInterface.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
getTemplate() 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...sponse\TemplateResponse.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The method
getData() 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...sponse\TemplateResponse or Basster\LazyResponseBund...e\JsonSerializeResponse.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||||
| 37 | } |
||||||||
| 38 | } |
||||||||
| 39 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.