1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: Geolim4 |
5
|
|
|
* Date: 12/02/2018 |
6
|
|
|
* Time: 23:10 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Phpfastcache\Drivers\Couchdb; |
10
|
|
|
|
11
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
12
|
|
|
|
13
|
|
|
class Config extends ConfigurationOption |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $host = '127.0.0.1'; |
19
|
|
|
/** |
20
|
|
|
* @var int |
21
|
|
|
*/ |
22
|
|
|
protected $port = 5984; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $path = '/'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $username = ''; |
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $password = ''; |
37
|
|
|
/** |
38
|
|
|
* @var bool |
39
|
|
|
*/ |
40
|
|
|
protected $ssl = false; |
41
|
|
|
/** |
42
|
|
|
* @var int |
43
|
|
|
*/ |
44
|
|
|
protected $timeout = 10; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $database = Driver::COUCHDB_DEFAULT_DB_NAME; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return string |
53
|
|
|
*/ |
54
|
|
|
public function getDatabase(): string |
55
|
|
|
{ |
56
|
|
|
return $this->database; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string $database |
61
|
|
|
* @return Config |
62
|
|
|
*/ |
63
|
|
|
public function setDatabase(string $database): Config |
64
|
|
|
{ |
65
|
|
|
$this->database = $database; |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return string |
71
|
|
|
*/ |
72
|
|
|
public function getHost(): string |
73
|
|
|
{ |
74
|
|
|
return $this->host; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param string $host |
79
|
|
|
* @return self |
80
|
|
|
*/ |
81
|
|
|
public function setHost(string $host): self |
82
|
|
|
{ |
83
|
|
|
$this->host = $host; |
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return int |
89
|
|
|
*/ |
90
|
|
|
public function getPort(): int |
91
|
|
|
{ |
92
|
|
|
return $this->port; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param int $port |
97
|
|
|
* @return self |
98
|
|
|
*/ |
99
|
|
|
public function setPort(int $port): self |
100
|
|
|
{ |
101
|
|
|
$this->port = $port; |
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
|
|
public function getUsername(): string |
109
|
|
|
{ |
110
|
|
|
return $this->username; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param string $username |
115
|
|
|
* @return self |
116
|
|
|
*/ |
117
|
|
|
public function setUsername(string $username): self |
118
|
|
|
{ |
119
|
|
|
$this->username = $username; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
public function getPassword(): string |
127
|
|
|
{ |
128
|
|
|
return $this->password; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @param string $password |
133
|
|
|
* @return self |
134
|
|
|
*/ |
135
|
|
|
public function setPassword(string $password): self |
136
|
|
|
{ |
137
|
|
|
$this->password = $password; |
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return bool |
143
|
|
|
*/ |
144
|
|
|
public function isSsl(): bool |
145
|
|
|
{ |
146
|
|
|
return $this->ssl; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param bool $ssl |
151
|
|
|
* @return self |
152
|
|
|
*/ |
153
|
|
|
public function setSsl(bool $ssl): self |
154
|
|
|
{ |
155
|
|
|
$this->ssl = $ssl; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @return int |
161
|
|
|
*/ |
162
|
|
|
public function getTimeout(): int |
163
|
|
|
{ |
164
|
|
|
return $this->timeout; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* @param int $timeout |
169
|
|
|
* @return self |
170
|
|
|
*/ |
171
|
|
|
public function setTimeout(int $timeout): self |
172
|
|
|
{ |
173
|
|
|
$this->timeout = $timeout; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
} |