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
Pull Request — master (#26)
by
unknown
05:57
created

Client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 93.33%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 29
ccs 14
cts 15
cp 0.9333
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 2
1
<?php namespace Vindi\Http;
2
3
use GuzzleHttp\Client as Guzzle;
4
use Vindi\Vindi;
5
6
class Client extends Guzzle
7
{
8
    /**
9
     * Client constructor.
10
     */
11 428
    public function __construct(array $config = [])
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
12
    {
13 428
        $vindi = new Vindi;
14
15 428
        $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
16
17 428
        $config = array_merge([
18 428
            'base_uri'        => Vindi::getApiBase(),
19 428
            'auth'            => [$vindi->getApiKey(), '', 'BASIC'],
20
            'headers' => [
21 428
                'Content-Type' => 'application/json',
22 428
                'User-Agent'   => trim('Vindi-PHP/' . Vindi::$sdkVersion . "; {$host}"),
23 428
            ],
24 428
            'verify'  => $vindi->getCertPath(),
25 428
            'timeout' => 60,
26
            'curl.options' => [
27 428
                'CURLOPT_SSLVERSION' => 'CURL_SSLVERSION_TLSv1_2',
28
            ]
29 428
        ], $config);
30
31
32 428
        parent::__construct($config);
33
    }
34
}
35