RedisConfig   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 59
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
A getHost() 0 4 1
A getPort() 0 4 1
A getProtocol() 0 4 1
A getDbIndex() 0 4 1
A getConnectionName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\RedisSentinel;
6
7
final class RedisConfig
8
{
9
    /** @var string */
10
    private $host;
11
12
    /** @var int */
13
    private $port;
14
15
    /** @var string */
16
    private $protocol;
17
18
    /** @var int */
19
    private $dbIndex;
20
21
    /** @var string|null */
22
    private $connectionName;
23
24 6
    public function __construct(array $options = [])
25
    {
26 6
        $options = array_merge([
27 6
            'host' => null,
28
            'port' => 6379,
29
            'protocol' => 'tcp',
30
            'dbIndex' => 0,
31
            'connectionName' => null,
32 6
        ], $options);
33
34 6
        $this->host = $options['host'];
35 6
        $this->port = (int) $options['port'];
36 6
        $this->protocol = $options['protocol'];
37 6
        $this->dbIndex = (int) $options['dbIndex'];
38 6
        $this->connectionName = $options['connectionName'];
39 6
    }
40
41 6
    public function getHost(): string
42
    {
43 6
        return $this->host;
44
    }
45
46 6
    public function getPort(): int
47
    {
48 6
        return $this->port;
49
    }
50
51 6
    public function getProtocol(): string
52
    {
53 6
        return $this->protocol;
54
    }
55
56 6
    public function getDbIndex(): int
57
    {
58 6
        return $this->dbIndex;
59
    }
60
61 6
    public function getConnectionName(): ?string
62
    {
63 6
        return $this->connectionName;
64
    }
65
}
66