FixedResponseHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Nimo\Handlers;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Server\RequestHandlerInterface;
9
10
/**
11
 * Handler that always return fixed response.
12
 */
13
class FixedResponseHandler extends AbstractHandler
14
{
15
    protected $fixedResponse;
16
17
    /**
18
     * @param ResponseInterface $response The fixed response.
19
     */
20 1
    public function __construct(ResponseInterface $response)
21
    {
22 1
        $this->fixedResponse = $response;
23 1
    }
24
25 1
    public static function wrap(ResponseInterface $response): RequestHandlerInterface
26
    {
27 1
        return new static($response);
28
    }
29
30 1
    protected function main(): ResponseInterface
31
    {
32 1
        return $this->fixedResponse;
33
    }
34
}
35