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 ( e54f5d...f19941 )
by Erico
03:51
created

Client::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
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 366
    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 366
        $vindi = new Vindi;
14
15 366
        $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
16
17 366
        $config = array_merge([
18 366
            'base_uri'        => Vindi::$apiBase,
19 366
            'auth'            => [$vindi->getApiKey(), '', 'BASIC'],
20
            'headers' => [
21 366
                'Content-Type' => 'application/json',
22 366
                'User-Agent'   => trim('Vindi-PHP/' . Vindi::$sdkVersion . "; {$host}"),
23 366
            ],
24 366
            'verify'  => $vindi->getCertPath(),
25 366
            'timeout' => 60,
26
            'curl.options' => [
27 366
                'CURLOPT_SSLVERSION' => 'CURL_SSLVERSION_TLSv1_2',
28
            ]
29 366
        ], $config);
30
31
32 366
        parent::__construct($config);
33 366
    }
34
}
35