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 ( c85033...38e2ef )
by Kevin
01:10
created

BolComRetailerService::reauthenticateIfNeeded()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace HomeDesignShops\LaravelBolComRetailer;
4
5
use HomeDesignShops\LaravelBolComRetailer\Models\TransportData;
6
use HomeDesignShops\LaravelBolComRetailer\Models\TransportItem;
7
use Picqer\BolRetailer\Client as BolRetailerClient;
8
9
class BolComRetailerService
10
{
11
    /**
12
     * @var BolComRetailerClient
13
     */
14
    protected $client;
15
16
    /**
17
     * BolComRetailer constructor.
18
     */
19
    public function __construct()
20
    {
21
        BolRetailerClient::setDemoMode(config('bol-com-retailer.use_demo_mode'));
22
        BolRetailerClient::setCredentials(
23
            config('bol-com-retailer.client_id'),
24
            config('bol-com-retailer.client_secret')
25
        );
26
27
        $this->client = new BolComRetailerClient();
28
    }
29
30
    /**
31
     * Reauthenticate if needed.
32
     */
33
    public function reauthenticateIfNeeded(): void
34
    {
35
        if(BolRetailerClient::isAuthenticated() === false) {
36
            BolRetailerClient::setCredentials(
37
                config('bol-com-retailer.client_id'),
38
                config('bol-com-retailer.client_secret')
39
            );
40
        }
41
    }
42
43
    /**
44
     * Redirect all calls to the client
45
     *
46
     * @param string $name Name of the method to call
47
     * @param mixed $arguments Arguments of the method to call
48
     * @return mixed
49
     */
50
    public function __call($name, $arguments)
51
    {
52
        $this->reauthenticateIfNeeded();
53
54
        return $this->client->$name(...$arguments);
55
    }
56
57
}
58