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.

Client   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 15
dl 0
loc 69
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getContactApi() 0 3 1
A getOrderApi() 0 3 1
A getCustomerApi() 0 3 1
A __construct() 0 3 1
A getConnectionApi() 0 3 1
A getCommonClient() 0 11 1
A getAbandonedCartApi() 0 3 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
namespace CommerceLeague\ActiveCampaign\Gateway;
6
7
use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper;
8
use CommerceLeague\ActiveCampaignApi\Api\AbandonedCartApiResourceInterface;
9
use CommerceLeague\ActiveCampaignApi\Api\ConnectionApiResourceInterface;
10
use CommerceLeague\ActiveCampaignApi\Api\ContactApiResourceInterface;
11
use CommerceLeague\ActiveCampaignApi\Api\CustomerApiResourceInterface;
12
use CommerceLeague\ActiveCampaignApi\Api\OrderApiResourceInterface;
13
use CommerceLeague\ActiveCampaignApi\ClientBuilder;
14
use CommerceLeague\ActiveCampaignApi\CommonClientInterface;
15
use Http\Adapter\Guzzle6\Client as GuzzleClient;
16
use Http\Factory\Guzzle\RequestFactory as GuzzleRequestFactory;
17
use Http\Factory\Guzzle\StreamFactory as GuzzleStreamFactory;
18
19
/**
20
 * Class Client
21
 */
22
class Client
23
{
24
    /**
25
     * @var ConfigHelper
26
     */
27
    private $configHelper;
28
29
    /**
30
     * @param ConfigHelper $configHelper
31
     */
32
    public function __construct(ConfigHelper $configHelper)
33
    {
34
        $this->configHelper = $configHelper;
35
    }
36
37
    /**
38
     * @return CommonClientInterface
39
     */
40
    private function getCommonClient(): CommonClientInterface
41
    {
42
        $url = $this->configHelper->getApiUrl();
43
        $token = $this->configHelper->getApiToken();
44
45
        $clientBuilder = new ClientBuilder();
46
        $clientBuilder->setHttpClient(new GuzzleClient());
47
        $clientBuilder->setRequestFactory(new GuzzleRequestFactory());
48
        $clientBuilder->setStreamFactory(new GuzzleStreamFactory());
49
50
        return $clientBuilder->buildCommonClient($url, $token);
0 ignored issues
show
Bug introduced by
It seems like $url can also be of type null; however, parameter $baseUri of CommerceLeague\ActiveCam...er::buildCommonClient() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

50
        return $clientBuilder->buildCommonClient(/** @scrutinizer ignore-type */ $url, $token);
Loading history...
Bug introduced by
It seems like $token can also be of type null; however, parameter $token of CommerceLeague\ActiveCam...er::buildCommonClient() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

50
        return $clientBuilder->buildCommonClient($url, /** @scrutinizer ignore-type */ $token);
Loading history...
51
    }
52
53
    /**
54
     * @return AbandonedCartApiResourceInterface
55
     */
56
    public function getAbandonedCartApi(): AbandonedCartApiResourceInterface
57
    {
58
        return $this->getCommonClient()->getAbandonedCartApi();
59
    }
60
61
    /**
62
     * @return ConnectionApiResourceInterface
63
     */
64
    public function getConnectionApi(): ConnectionApiResourceInterface
65
    {
66
        return $this->getCommonClient()->getConnectionApi();
67
    }
68
69
    /**
70
     * @return ContactApiResourceInterface
71
     */
72
    public function getContactApi(): ContactApiResourceInterface
73
    {
74
        return $this->getCommonClient()->getContactApi();
75
    }
76
77
    /**
78
     * @return CustomerApiResourceInterface
79
     */
80
    public function getCustomerApi(): CustomerApiResourceInterface
81
    {
82
        return $this->getCommonClient()->getCustomerApi();
83
    }
84
85
    /**
86
     * @return OrderApiResourceInterface
87
     */
88
    public function getOrderApi(): OrderApiResourceInterface
89
    {
90
        return $this->getCommonClient()->getOrderApi();
91
    }
92
}
93