RedisConfig::getPort()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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