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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 40
loc 40
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

2 Methods

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

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\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