Response::getStatusCode()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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