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::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 16
ccs 7
cts 7
cp 1
crap 2
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
4
namespace Gbowo\Adapter\Amplifypay\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
    protected $baseUrl;
14
15
    protected $apiKeys;
16
17
    const FETCH_PLAN_RELATIVE_LINK = "/plan";
18
19 2
    public function __construct(string $baseUrl, array $apiKeys)
20
    {
21 2
        $this->baseUrl = $baseUrl;
22 2
        $this->apiKeys= $apiKeys;
23 2
    }
24
25
    /**
26
     * @param string $planId
27
     * @return mixed
28
     * @throws \Gbowo\Exception\InvalidHttpResponseException if the response code is not 200
29
     */
30 2
    public function handle(string $planId)
31
    {
32 2
        $link = $this->baseUrl.self::FETCH_PLAN_RELATIVE_LINK."?PlanId={$planId}";
33
34
        /**
35
         * @var ResponseInterface $response
36
         */
37 2
        $response = $this->adapter->getHttpClient()
38 2
            ->get($link);
39
40 2
        if ($response->getStatusCode() !== 200) {
41 1
            throw InvalidHttpResponseException::createFromResponse($response);
42
        }
43
44 1
        return json_decode($response->getBody(), true);
45
    }
46
}
47