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.
Passed
Branch master (37a03c)
by Casper
01:38
created

NStackClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 53.85%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 42
rs 10
ccs 7
cts 13
cp 0.5385
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 2
A buildPath() 0 3 1
1
<?php
2
3
namespace NStack\Clients;
4
5
use GuzzleHttp\Client;
6
use NStack\Config;
7
8
/**
9
 * Class NStackClient
10
 *
11
 * @package NStack\Clients
12
 * @author  Casper Rasmussen <[email protected]>
13
 */
14
class NStackClient
15
{
16
    protected $client;
17
18
    protected $nstackConfig;
19
20
    /**
21
     * NStackClient constructor.
22
     *
23
     * @param \NStack\Config          $nstackConfig
24
     * @param \GuzzleHttp\Client|null $client
25
     * @author Casper Rasmussen <[email protected]>
26
     */
27 15
    public function __construct(Config $nstackConfig, Client $client = null)
28
    {
29 15
        if ($client) {
30 15
            $this->client = $client;
31
        } else {
32
            $this->client = new Client(([
33
                'base_uri' => $nstackConfig->getBaseUrl(),
34
                'timeout'  => 5,
35
                'headers'  => [
36
                    'X-Application-Id' => $nstackConfig->getAppId(),
37
                    'X-Rest-Api-Key'   => $nstackConfig->getRestAppKey(),
38
                    'Content-Type'     => 'application/json',
39
                ],
40
            ]));
41
        }
42
43 15
        $this->nstackConfig = $nstackConfig;
44 15
    }
45
46
    /**
47
     * buildPath
48
     *
49
     * @param string $path
50
     * @return string
51
     * @author Casper Rasmussen <[email protected]>
52
     */
53 14
    protected function buildPath(string $path): string
54
    {
55 14
        return 'api/' . $this->nstackConfig->getVersion() . '/' . $path;
56
    }
57
}