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.

FetchPlan   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 37
loc 37
c 0
b 0
f 0
wmc 2
lcom 1
cbo 5
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A handle() 14 14 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
4
namespace Gbowo\Adapter\Paystack\Plugin;
5
6
use Gbowo\Adapter\Paystack\Traits\VerifyHttpStatusResponseCode;
7
use Gbowo\Plugin\AbstractFetchPlan;
8
use function GuzzleHttp\json_decode;
9
use Psr\Http\Message\ResponseInterface;
10
11 View Code Duplication
class FetchPlan extends AbstractFetchPlan
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...
12
{
13
14
    use VerifyHttpStatusResponseCode;
15
16
    /**
17
     * @var string The relative link for fetching a certain plan
18
     */
19
    const FETCH_PLAN_LINK = '/plan/:identifier';
20
21
    protected $baseUrl;
22
23 2
    public function __construct(string $baseUrl)
24
    {
25 2
        $this->baseUrl = $baseUrl;
26 2
    }
27
28
    /**
29
     * @param string|int $identifier
30
     * @return mixed
31
     * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned
32
     */
33 2
    public function handle($identifier)
34
    {
35 2
        $link = $this->baseUrl . str_replace(":identifier", $identifier, self::FETCH_PLAN_LINK);
36
37
        /**
38
         * @var ResponseInterface $response
39
         */
40 2
        $response = $this->adapter->getHttpClient()
41 2
            ->get($link);
42
43 2
        $this->verifyResponse($response);
44
45 1
        return json_decode($response->getBody(), true)['data'];
46
    }
47
}
48