Test Failed
Push — master ( faf677...e3d7a5 )
by Maximo
02:02
created

RedisProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 1
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 boolean|string 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