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

src/Response/Handler/RedirectResponseHandler.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\RedirectResponse;
8
use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse;
9
use Symfony\Component\HttpFoundation\Response;
10
use Symfony\Component\Routing\RouterInterface;
11
12
/**
13
 * Class RedirectResponseHandler.
14
 */
15
final class RedirectResponseHandler extends AbstractLazyResponseHandler
16
{
17
    /**
18
     * @var \Symfony\Component\Routing\RouterInterface
19
     */
20
    private $router;
21
22 4
    public function __construct(RouterInterface $router)
23
    {
24 4
        $this->router = $router;
25 4
    }
26
27 3
    protected function isSupported(LazyResponseInterface $controllerResult): bool
28
    {
29 3
        return $controllerResult instanceof RedirectResponse;
30
    }
31
32
    /**
33
     * @param RedirectResponse $controllerResult
34
     *
35
     * @psalm-suppress MoreSpecificImplementedParamType
36
     */
37 3
    protected function generateResponse(LazyResponseInterface $controllerResult): Response
38
    {
39 3
        return new SymfonyRedirectResponse(
40 3
            $this->router->generate(
41 3
                $controllerResult->getRouteName(),
42 3
                $controllerResult->getRouteParams()
43
            ),
44 3
            $controllerResult->getStatusCode(),
0 ignored issues
show
The method getStatusCode() 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\RedirectResponse. ( Ignorable by Annotation )

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

44
            $controllerResult->/** @scrutinizer ignore-call */ 
45
                               getStatusCode(),
Loading history...
45 3
            $controllerResult->getHeaders()
46
        );
47
    }
48
}
49