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

SessionProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 32
ccs 3
cts 12
cp 0.25
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 27 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 function Gewaer\Core\envValue;
6
use Phalcon\Di\ServiceProviderInterface;
7
use Phalcon\DiInterface;
8
use Memcached;
9
use Phalcon\Session\Adapter\Libmemcached;
10
11
class SessionProvider implements ServiceProviderInterface
12
{
13
    /**
14
     * @param DiInterface $container
15
     */
16 4
    public function register(DiInterface $container)
17
    {
18 4
        $container->setShared(
19 4
            'session',
20
            function () {
21
                $backOptions = [
22
                    'servers' => [
23
                        0 => [
24
                            'host' => envValue('DATA_API_MEMCACHED_HOST', '127.0.0.1'),
25
                            'port' => envValue('DATA_API_MEMCACHED_PORT', 11211),
26
                            'weight' => envValue('DATA_API_MEMCACHED_WEIGHT', 100),
27
                        ],
28
                    ],
29
                    'client' => [
30
                        Memcached::OPT_HASH => Memcached::HASH_MD5,
31
                        Memcached::OPT_PREFIX_KEY => 'bakasession-',
32
                    ],
33
                    'lifetime' => 8600,
34
                    'prefix' => $prefix . '-',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $prefix seems to be never defined.
Loading history...
35
                    'persistent' => false
36
                ];
37
38
                $memcache = new Libmemcached($backOptions);
39
40
                $memcache->start();
41
42
                return $memcache;
43 4
            }
44
        );
45 4
    }
46
}
47