Completed
Push — master ( ba7b2b...21cd4a )
by Woody
04:45
created

RedirectResponder::hasRedirect()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
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