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
Push — master ( c42cfc...29c08b )
by Casper
04:31 queued 02:06
created

NStackClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildPath() 0 3 1
A __construct() 0 17 2
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 28
    public function __construct(Config $nstackConfig, Client $client = null)
28
    {
29 28
        if ($client) {
30 27
            $this->client = $client;
31
        } else {
32 1
            $this->client = new Client(([
33 1
                'base_uri' => $nstackConfig->getBaseUrl(),
34 1
                'timeout'  => 5,
35
                'headers'  => [
36 1
                    'X-Application-Id' => $nstackConfig->getAppId(),
37 1
                    'X-Rest-Api-Key'   => $nstackConfig->getRestApiKey(),
38 1
                    'Content-Type'     => 'application/json',
39
                ],
40
            ]));
41
        }
42
43 28
        $this->nstackConfig = $nstackConfig;
44 28
    }
45
46
    /**
47
     * buildPath
48
     *
49
     * @param string $path
50
     * @return string
51
     * @author Casper Rasmussen <[email protected]>
52
     */
53 26
    protected function buildPath(string $path): string
54
    {
55 26
        return 'api/' . $this->nstackConfig->getVersion() . '/' . $path;
56
    }
57
}
58