Passed
Push — 2.x ( a91047...1175b5 )
by Darío
58s queued 14s
created

AbstractResponse   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 8
c 1
b 0
f 1
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponse() 0 3 1
A __construct() 0 3 1
A toArray() 0 6 2
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 18
    public function __construct(HttpClientResponse $response)
14
    {
15 18
        $this->response = $response;
16 18
    }
17
18 15
    public function getResponse(): HttpClientResponse
19
    {
20 15
        return $this->response;
21
    }
22
23 14
    public function toArray(): array
24
    {
25
        try {
26 14
            return $this->response->parseJson();
27 3
        } catch (ImpossibleToParseJsonException $e) {
28 3
            return [];
29
        }
30
    }
31
}
32