ClientResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 11
c 2
b 0
f 1
dl 0
loc 31
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatusCode() 0 3 1
A __construct() 0 5 1
A getHeaders() 0 3 1
A parseJson() 0 3 1
A getBody() 0 3 1
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