RedirectResponseHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSupported() 0 3 1
A generateResponse() 0 9 1
A __construct() 0 2 1
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 4
    public function __construct(private RouterInterface $router)
0 ignored issues
show
Unused Code introduced by
The parameter $router is not used and could be removed. ( Ignorable by Annotation )

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

17
    public function __construct(/** @scrutinizer ignore-unused */ private RouterInterface $router)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19 4
    }
20
21 3
    protected function isSupported(LazyResponseInterface $controllerResult): bool
22
    {
23 3
        return $controllerResult instanceof RedirectResponse;
24
    }
25
26
    /**
27
     * @param RedirectResponse $controllerResult
28
     *
29
     * @psalm-suppress MoreSpecificImplementedParamType
30
     */
31 3
    protected function generateResponse(LazyResponseInterface $controllerResult): Response
32
    {
33 3
        return new SymfonyRedirectResponse(
34 3
            $this->router->generate(
35 3
                $controllerResult->getRouteName(),
0 ignored issues
show
Bug introduced by
The method getRouteName() 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

35
                $controllerResult->/** @scrutinizer ignore-call */ 
36
                                   getRouteName(),
Loading history...
36 3
                $controllerResult->getRouteParams()
0 ignored issues
show
Bug introduced by
The method getRouteParams() 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

36
                $controllerResult->/** @scrutinizer ignore-call */ 
37
                                   getRouteParams()
Loading history...
37
            ),
38 3
            $controllerResult->getStatusCode(),
39 3
            $controllerResult->getHeaders()
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

39
            $controllerResult->/** @scrutinizer ignore-call */ 
40
                               getHeaders()
Loading history...
40
        );
41
    }
42
}
43