Test Failed
Push — master ( 7c58bc...b4c459 )
by Maximo
02:09
created

SessionProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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