PredisConfiguration   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 4 1
A getClient() 0 11 3
1
<?php
2
3
namespace Equip\RedisQueue\Configuration;
4
5
use Aura\Cli\Context;
6
use Auryn\Injector;
7
use Equip\Configuration\ConfigurationInterface;
8
use Predis\Client;
9
10
class PredisConfiguration implements ConfigurationInterface
11
{
12
    /** 
13
     * @param Injector $injector
14
     */
15 1
    public function apply(Injector $injector)
16
    {
17 1
        $injector->delegate(Client::class, [$this, 'getClient']);
18 1
    }
19
20
    /**
21
     * @param Context $context
22
     */
23 1
    public function getClient(Context $context)
24
    {
25 1
        $env = $context->env;
26 1
        $host = $env->get('REDIS_HOST') ?: '127.0.0.1';
27 1
        $port = $env->get('REDIS_PORT') ?: 6379;
28 1
        return new Client([
29 1
            'scheme' => 'tcp',
30 1
            'host' => $host,
31 1
            'port' => $port,
32 1
        ]);
33
    }
34
}
35