WebTestCase   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createApplication() 0 6 1
1
<?php
2
namespace Kineo\Test;
3
4
use Silex\WebTestCase as BaseWebTestCase;
5
6
class WebTestCase extends BaseWebTestCase
7
{
8
    public function createApplication()
0 ignored issues
show
Coding Style introduced by
createApplication 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...
9
    {
10
        $app = require $_SERVER['APP_DIR'] . '/src/app.php';
11
12
        return $app;
13
    }
14
}