Passed
Pull Request — master (#12)
by
unknown
05:56
created

Options::getDbName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace TBolier\RethinkQL\Connection;
5
6
class Options implements OptionsInterface
7
{
8
    /**
9
     * @var string
10
     */
11
    private $hostname;
12
13
    /**
14
     * @var int
15
     */
16
    private $port;
17
18
    /**
19
     * @var string
20
     */
21
    private $dbname;
22
23
    /**
24
     * @var string
25
     */
26
    private $user;
27
28
    /**
29
     * @var string
30
     */
31
    private $password;
32
33
    /**
34
     * @var float
35
     */
36
    private $timeout;
37
38
    /**
39
     * @var int
40
     */
41
    private $timeoutStream;
42
43
    /**
44
     * @var bool
45
     */
46
    private $ssl;
47
48
    /**
49
     * @param array $options
50
     */
51 39
    public function __construct($options = [])
52
    {
53 39
        $this->hostname = $options['hostname'] ?? 'localhost';
54 39
        $this->port = $options['port'] ?? 28015;
55 39
        $this->dbname = $options['dbname'] ?? '';
56 39
        $this->user = $options['user'] ?? '';
57 39
        $this->password = $options['password'] ?? '';
58 39
        $this->timeout = $options['timeout'] ?? 1.0;
59 39
        $this->timeoutStream = $options['timeout_stream'] ?? 3;
60 39
        $this->ssl = $options['ssl'] ?? false;
61 39
    }
62
63
    /**
64
     * @return string
65
     */
66 24
    public function getHostname(): string
67
    {
68 24
        return $this->hostname;
69
    }
70
71
    /**
72
     * @return int
73
     */
74 24
    public function getPort(): int
75
    {
76 24
        return $this->port;
77
    }
78
79
    /**
80
     * @return string
81
     */
82 37
    public function getDbName(): string
83
    {
84 37
        return $this->dbname;
85
    }
86
87
    /**
88
     * @return string
89
     */
90 28
    public function getUser(): string
91
    {
92 28
        return $this->user;
93
    }
94
95
    /**
96
     * @return string
97
     */
98 28
    public function getPassword(): string
99
    {
100 28
        return $this->password;
101
    }
102
103
    /**
104
     * @return float
105
     */
106 24
    public function getTimeout(): float
107
    {
108 24
        return $this->timeout;
109
    }
110
111
    /**
112
     * @return int
113
     */
114 24
    public function getTimeoutStream(): int
115
    {
116 24
        return $this->timeoutStream;
117
    }
118
119
    /**
120
     * @return bool
121
     */
122 24
    public function isSsl(): bool
123
    {
124 24
        return $this->ssl;
125
    }
126
127
    /**
128
     * @return bool
129
     */
130 2
    public function hasDefaultDatabase(): bool
131
    {
132 2
        return !empty($this->dbname);
133
    }
134
}
135