ClientResponse::getStatusCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace EasyHttp\LayerContracts\Tests\Unit\Example;
4
5
use EasyHttp\LayerContracts\Contracts\HttpClientResponse;
6
7
class ClientResponse implements HttpClientResponse
8
{
9
    protected array $headers;
10
    protected int $status;
11
    protected string $body;
12
13
    public function __construct(array $response)
14
    {
15
        $this->headers = $response['headers'];
16
        $this->status = $response['status'];
17
        $this->body = $response['body'];
18
    }
19
20
    public function getStatusCode(): int
21
    {
22
        return $this->status;
23
    }
24
25
    public function getHeaders(): array
26
    {
27
        return $this->headers;
28
    }
29
30
    public function getBody(): string
31
    {
32
        return $this->body;
33
    }
34
35
    public function parseJson(): array
36
    {
37
        return (array) json_decode($this->body) ?? [];
38
    }
39
}
40