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 ( b894a5...1d1821 )
by Lanre
10s
created

src/Gbowo/Adapter/Paystack/Plugin/FetchPlan.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
class FetchPlan extends AbstractFetchPlan
12
{
13
14
    /**
15
     * @var string The relative link for fetching a certain plan
16
     */
17
    const FETCH_PLAN_LINK = '/plan/:identifier';
18
19
    protected $baseUrl;
20
21
    public function __construct(string $baseUrl)
22
    {
23
        $this->baseUrl = $baseUrl;
24
    }
25
26
    /**
27
     * @param array ...$args
28
     * @return mixed
29
     * @throws \Gbowo\Exception\InvalidHttpResponseException if ann http response of 200 isn't returned
30
     */
31 View Code Duplication
    public function handle(...$args)
0 ignored issues
show
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...
32
    {
33
34
        $link = $this->baseUrl . str_replace(":identifier", $args[0], self::FETCH_PLAN_LINK);
35
36
        /**
37
         * @var ResponseInterface $response
38
         */
39
        $response = $this->adapter->getHttpClient()
40
            ->get($link);
41
42
        if (200 !== $response->getStatusCode()) {
43
            throw new InvalidHttpResponseException(
44
                "Expected 200. Got {$response->getStatusCode()} instead"
45
            );
46
        }
47
48
        return json_decode($response->getBody(), true)['data'];
49
    }
50
}
51