Test Failed
Push — master ( f82b48...e7e248 )
by Maximo
03:08
created

RedisProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
namespace Gewaer\Providers;
4
5
use Phalcon\Di\ServiceProviderInterface;
6
use Phalcon\DiInterface;
7
use Redis;
8
use function Gewaer\Core\envValue;
9
10
class RedisProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param DiInterface $container
14
     */
15
    public function register(DiInterface $container)
16
    {
17
        $config = $container->getShared('config');
18
19
        $container->setShared(
20
            'redis',
21
            function () use ($config) {
0 ignored issues
show
Unused Code introduced by
The import $config is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
22
                //Connect to redis
23
                //for now redis normal
24
                $redis = new Redis();
25
                $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), envValue('REDIS_PORT', '6379'));
0 ignored issues
show
Bug introduced by
envValue('REDIS_PORT', '6379') of type string|boolean is incompatible with the type integer expected by parameter $port of Redis::connect(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
                $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), /** @scrutinizer ignore-type */ envValue('REDIS_PORT', '6379'));
Loading history...
26
                $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
27
                return $redis;
28
            }
29
        );
30
    }
31
}
32