GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 2f39ea...79b72f )
by Lanre
02:06
created

FetchAllPlans::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 8

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 18
loc 18
ccs 8
cts 8
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
4
namespace Gbowo\Adapter\Paystack\Plugin;
5
6
use Gbowo\Exception\InvalidHttpResponseException;
7
use Gbowo\Plugin\AbstractFetchAllPlans;
8
use function Gbowo\toQueryParams;
9
use Psr\Http\Message\ResponseInterface;
10
use function GuzzleHttp\json_decode;
11
12 View Code Duplication
class FetchAllPlans extends AbstractFetchAllPlans
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    const FETCH_ALL_PLANS_RELATIVE_LINK = "/plan";
15
16
    /**
17
     * @var \Gbowo\Contract\Adapter\AdapterInterface
18
     */
19
    protected $adapter;
20
21
    protected $baseUrl;
22
23 2
    public function __construct(string $baseUrl)
24
    {
25 2
        $this->baseUrl = $baseUrl;
26 2
    }
27
28
    /**
29
     * @param array $args
30
     * @return mixed
31
     * @throws \Gbowo\Exception\InvalidHttpResponseException if the HTTP response status code is not 200
32
     */
33 2
    public function handle(array $args = [])
34
    {
35 2
        $params = toQueryParams($args);
36
37
        /**
38
         * @var ResponseInterface $response
39
         */
40 2
        $response = $this->adapter->getHttpClient()
41 2
            ->get($this->baseUrl . self::FETCH_ALL_PLANS_RELATIVE_LINK . $params);
42
43 2
        if (200 !== $response->getStatusCode()) {
44 1
            throw new InvalidHttpResponseException(
45 1
                "Expected 200. Got {$response->getStatusCode()} instead"
46
            );
47
        }
48
49 1
        return json_decode($response->getBody(), true)['data'];
50
    }
51
}
52