Test Failed
Pull Request — master (#9)
by Maximo
03:26
created

RedisProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 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 4
    public function register(DiInterface $container)
16
    {
17 4
        $config = $container->getShared('config');
18
19 4
        $container->setShared(
20 4
            '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 1
                $redis = new Redis();
24 1
                $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

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