AbstractResponse::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 6
ccs 2
cts 4
cp 0.5
rs 10
cc 2
nc 2
nop 0
crap 2.5
1
<?php
2
3
namespace PaymentGateway\PayPalSdk\Responses;
4
5
use EasyHttp\LayerContracts\Contracts\HttpClientResponse;
6
use EasyHttp\LayerContracts\Exceptions\ImpossibleToParseJsonException;
7
use PaymentGateway\PayPalSdk\Contracts\PayPalResponse;
8
9
abstract class AbstractResponse implements PayPalResponse
10
{
11
    protected HttpClientResponse $response;
12
13 10
    public function __construct(HttpClientResponse $response)
14
    {
15 10
        $this->response = $response;
16 10
    }
17
18 10
    public function getResponse(): HttpClientResponse
19
    {
20 10
        return $this->response;
21
    }
22
23 10
    public function toArray(): array
24
    {
25
        try {
26 10
            return $this->response->parseJson();
27
        } catch (ImpossibleToParseJsonException $e) {
28
            return [];
29
        }
30
    }
31
}
32