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 ( 65dc27...4e2c47 )
by Lanre
05:32
created

FetchPlan::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\Plugin\AbstractFetchPlan;
7
use function GuzzleHttp\json_decode;
8
use Psr\Http\Message\ResponseInterface;
9
use Gbowo\Exception\InvalidHttpResponseException;
10
11
/**
12
 * @author Lanre Adelowo <[email protected]>
13
 * Class FetchPlan
14
 * @package Gbowo\Adapter\Paystack\Plugin
15
 */
16
class FetchPlan extends AbstractFetchPlan
17
{
18
19
    /**
20
     * @var string The relative link for fetching a certain plan
21
     */
22
    const FETCH_PLAN_LINK = '/plan/:identifier';
23
24
    /**
25
     * @var string Paystack's base Url
26
     */
27
    protected $baseUrl;
28
29 2
    public function __construct(string $baseUrl)
30
    {
31 2
        $this->baseUrl = $baseUrl;
32 2
    }
33
34
    /**
35
     * @param string $planIdentifier The unique plan identifier
36
     * @return mixed
37
     * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned
38
     */
39 2 View Code Duplication
    public function handle(string $planIdentifier)
1 ignored issue
show
Duplication introduced by
This method 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...
40
    {
41 2
        $link = $this->baseUrl . str_replace(":identifier", $planIdentifier, self::FETCH_PLAN_LINK);
42
43
        /**
44
         * @var ResponseInterface $response
45
         */
46 2
        $response = $this->adapter->getHttpClient()
47 2
            ->get($link);
48
49 2
        if (200 !== $response->getStatusCode()) {
50 1
            throw new InvalidHttpResponseException(
51 1
                "Expected 200. Got {$response->getStatusCode()} instead"
52
            );
53
        }
54
55 1
        return json_decode($response->getBody(), true)['data'];
56
    }
57
}
58