Passed
Push — master ( 6db8b4...45291c )
by David
01:08
created

AbstractClientTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
1
<?php
2
namespace FlexyProject\GitHub\Tests;
3
4
use FlexyProject\GitHub\Client;
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * Class AbstractTest
9
 *
10
 * @package FlexyProject\GitHub\Tests
11
 */
12
abstract class AbstractClientTest extends TestCase
13
{
14
    /** @var Client */
15
    protected $client;
16
17
    /**
18
     * AbstractTest constructor.
19
     *
20
     * @param null   $name
21
     * @param array  $data
22
     * @param string $dataName
23
     */
24
    public function __construct($name = null, array $data = [], $dataName = '')
0 ignored issues
show
Coding Style introduced by
__construct uses the super-global variable $GLOBALS 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...
25
    {
26
        // Create a client object
27
        $this->client = new Client();
28
29
        // Set auth credentials
30
        $this->client->setHttpAuth($GLOBALS['USERNAME'], $GLOBALS['PASSWORD']);
31
32
        parent::__construct($name, $data, $dataName);
33
    }
34
}