Response   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusCode() 0 3 1
A getReasonPhrase() 0 3 1
A withStatus() 0 5 1
1
<?php
2
3
namespace kalanis\RemoteRequestPsr\Content;
4
5
6
use kalanis\RemoteRequestPsr\Traits\TBody;
7
use kalanis\RemoteRequestPsr\Traits\THeaders;
8
use kalanis\RemoteRequestPsr\Traits\TProtocol;
9
use Psr\Http\Message\ResponseInterface;
10
11
12
/**
13
 * Class Response
14
 * @package kalanis\RemoteRequestPsr\Content
15
 * Note: Contrary the PSR requirements this class does not offer immutability
16
 * That's because you need to change request properties before you set them to RemoteRequest
17
 */
18
class Response implements ResponseInterface
19
{
20
    use THeaders;
21
    use TBody;
22
    use TProtocol;
23
24
    protected int $status = 0;
25
    protected string $reason = 'KO';
26
27 1
    public function getStatusCode(): int
28
    {
29 1
        return $this->status;
30
    }
31
32 1
    public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface
33
    {
34 1
        $this->status = $code;
35 1
        $this->reason = $reasonPhrase;
36 1
        return $this;
37
    }
38
39 1
    public function getReasonPhrase(): string
40
    {
41 1
        return $this->reason;
42
    }
43
}
44