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

StorageRedisCacheProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 32
ccs 0
cts 11
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 11 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
    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