Completed
Push — spike ( 20d8a1...1c889c )
by Akihito
06:40
created

StorageRedisCacheProvider::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the BEAR.QueryRepository package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\QueryRepository;
8
9
use Doctrine\Common\Cache\RedisCache;
10
use Ray\Di\Di\Named;
11
use Ray\Di\ProviderInterface;
12
13
class StorageRedisCacheProvider implements ProviderInterface
14
{
15
    /**
16
     * redis server
17
     *
18
     * @var array
19
     */
20
    private $server;
21
22
    /**
23
     * @Named("redis_server")
24
     */
25
    public function __construct(array $server)
26
    {
27
        $this->server = $server;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function get()
34
    {
35
        $redis = new \Redis();
36
        $host = $this->server[0];
37
        $port = $this->server[1];
38
        $redis->connect($host, $port);
39
        $redisCache = new RedisCache();
40
        $redisCache->setRedis($redis);
41
42
        return $redisCache;
43
    }
44
}
45