AbstractResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A decodeResponse() 0 4 1
parseResponse() 0 1 ?
A getResponse() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Response;
6
7
use Psr\Http\Message\ResponseInterface;
8
9
abstract class AbstractResponse
10
{
11
    /**
12
     * @var \Psr\Http\Message\ResponseInterface
13
     */
14
    protected $response;
15
16
    /**
17
     * AbstractResponse constructor.
18
     */
19 28
    public function __construct(ResponseInterface $response)
20
    {
21 28
        $this->response = $response;
22
23 28
        $this->parseResponse($this->decodeResponse($response));
24 28
    }
25
26 28
    private function decodeResponse(ResponseInterface $response): array
27
    {
28 28
        return json_decode((string) $response->getBody(), true);
29
    }
30
31
    abstract protected function parseResponse(array $response): void;
32
33 1
    public function getResponse(): ResponseInterface
34
    {
35 1
        return $this->response;
36
    }
37
}
38