Completed
Push — cache ( ce1318 )
by Akihito
11s
created

StorageRedisCacheProvider::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1
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 1
    public function __construct(array $server)
26
    {
27 1
        $this->server = $server;
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function get()
34
    {
35 1
        $redis = new \Redis();
36 1
        $host = $this->server[0];
37 1
        $port = $this->server[1];
38 1
        $redis->connect($host, $port);
39 1
        $redisCache = new RedisCache();
40 1
        $redisCache->setRedis($redis);
41
42 1
        return $redisCache;
43
    }
44
}
45