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.

IntegrationTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 23
c 1
b 0
f 0
wmc 3
lcom 0
cbo 2
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createProvider() 0 4 1
A getCacheDir() 0 4 1
A getApiKey() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\GeoIPs\Tests;
14
15
use Geocoder\IntegrationTest\ProviderIntegrationTest;
16
use Geocoder\Provider\GeoIPs\GeoIPs;
17
use Http\Client\HttpClient;
18
19
/**
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
class IntegrationTest extends ProviderIntegrationTest
23
{
24
    protected $testAddress = false;
25
26
    protected $testReverse = false;
27
28
    protected $testIpv6 = false;
29
30
    protected function createProvider(HttpClient $httpClient)
31
    {
32
        return new GeoIPs($httpClient, $this->getApiKey());
33
    }
34
35
    protected function getCacheDir()
36
    {
37
        return __DIR__.'/.cached_responses';
38
    }
39
40
    protected function getApiKey()
0 ignored issues
show
Coding Style introduced by
getApiKey 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...
41
    {
42
        return $_SERVER['GEOIPS_API_KEY'];
43
    }
44
}
45