RedisProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 20
rs 10
ccs 10
cts 10
cp 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 2
1
<?php
2
3
namespace Canvas\Providers;
4
5
use function Canvas\Core\envValue;
6
use Phalcon\Di\ServiceProviderInterface;
0 ignored issues
show
Bug introduced by
The type Phalcon\Di\ServiceProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Phalcon\DiInterface;
0 ignored issues
show
Bug introduced by
The type Phalcon\DiInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Redis;
9
10
class RedisProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param DiInterface $container
14
     */
15 1
    public function register(DiInterface $container)
16
    {
17 1
        $app = envValue('GEWAER_APP_ID', 1);
18 1
19 1
        $container->setShared(
20
            'redis',
21 1
            function (bool $prefix = true) use ($app) {
22 1
                //Connect to redis
23 1
                $redis = new Redis();
24 1
                $redis->connect(envValue('REDIS_HOST', '127.0.0.1'), (int) envValue('REDIS_PORT', 6379));
25 1
                if ($prefix) {
26
                    $redis->setOption(Redis::OPT_PREFIX, $app . ':'); // use custom prefix on all keys
27 1
                }
28
                $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
29
                return $redis;
30
            }
31
        );
32
    }
33
}
34