PredisConfiguration::getClient()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

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