AuraCliConfiguration::apply()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 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