RedirectResponder::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
namespace Equip\Responder;
4
5
use Equip\Adr\PayloadInterface;
6
use Equip\Adr\ResponderInterface;
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
10
class RedirectResponder implements ResponderInterface
11
{
12
    /**
13
     * @inheritDoc
14
     */
15 5
    public function __invoke(
16
        ServerRequestInterface $request,
17
        ResponseInterface $response,
18
        PayloadInterface $payload
19
    ) {
20 5
        $location = $payload->getSetting('redirect');
21
22 5
        if (!empty($location)) {
23 1
            $response = $response->withHeader('Location', $location);
24 1
        }
25
26 5
        return $response;
27
    }
28
}
29