AuraCliConfiguration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 5 1
A getStdio() 0 4 1
A getContext() 0 4 1
1
<?php
2
3
namespace Equip\RedisQueue\Configuration;
4
5
use Aura\Cli\CliFactory;
6
use Aura\Cli\Context;
7
use Aura\Cli\Stdio;
8
use Auryn\Injector;
9
use Equip\Configuration\ConfigurationInterface;
10
11
class AuraCliConfiguration implements ConfigurationInterface
12
{
13 2
    public function apply(Injector $injector)
14
    {
15 2
        $injector->delegate(Stdio::class, [$this, 'getStdio']);
16 2
        $injector->delegate(Context::class, [$this, 'getContext']);
17 2
    }
18
19 1
    public function getStdio(CliFactory $cli)
20
    {
21 1
        return $cli->newStdio();
22
    }
23
24 1
    public function getContext(CliFactory $cli)
0 ignored issues
show
Coding Style introduced by
getContext 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 1
        return $cli->newContext($GLOBALS);
27
    }
28
}
29