Completed
Push — master ( 959f68...c6517b )
by Alexey
29s queued 12s
created

RedisDriver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getClient() 0 8 2
1
<?php
2
3
namespace SfCod\QueueBundle\Service;
4
5
use Predis\Client;
6
7
/**
8
 * Class RedisDriver
9
 *
10
 * @author Virchenko Maksim <[email protected]>
11
 *
12
 * @package SfCod\QueueBundle\Service
13
 */
14
class RedisDriver
15
{
16
    /**
17
     * @var Client
18
     */
19
    private $client;
20
21
    /**
22
     * @var string
23
     */
24
    private $uri;
25
26
    /**
27
     * RedisDriver constructor.
28
     *
29
     * @param string $uri
30
     */
31
    public function __construct(string $uri)
32
    {
33
        $this->uri = $uri;
34
    }
35
36
    /**
37
     * Get redis client
38
     *
39
     * @return Client
40
     */
41
    public function getClient(): Client
42
    {
43
        if (null === $this->client) {
44
            $this->client = new Client($this->uri);
45
        }
46
47
        return $this->client;
48
    }
49
}
50