1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* This file is part of Phpfastcache. |
6
|
|
|
* |
7
|
|
|
* @license MIT License (MIT) |
8
|
|
|
* |
9
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files. |
10
|
|
|
* |
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
12
|
|
|
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
declare(strict_types=1); |
16
|
|
|
|
17
|
|
|
namespace Phpfastcache\Drivers\Cassandra; |
18
|
|
|
|
19
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
20
|
|
|
use Phpfastcache\Exceptions\PhpfastcacheLogicException; |
21
|
|
|
|
22
|
|
|
class Config extends ConfigurationOption |
23
|
|
|
{ |
24
|
|
|
protected string $host = '127.0.0.1'; |
25
|
|
|
|
26
|
|
|
protected int $port = 9042; |
27
|
|
|
|
28
|
|
|
protected int $timeout = 2; |
29
|
|
|
|
30
|
|
|
protected string $username = ''; |
31
|
|
|
|
32
|
|
|
protected string $password = ''; |
33
|
|
|
|
34
|
|
|
protected bool $sslEnabled = false; |
35
|
|
|
|
36
|
|
|
protected bool $sslVerify = false; |
37
|
|
|
|
38
|
|
|
protected bool $useLegacyExecutionOptions = false; |
39
|
|
|
|
40
|
|
|
public function getHost(): string |
41
|
|
|
{ |
42
|
|
|
return $this->host; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param string $host |
47
|
|
|
* @return self |
48
|
|
|
* @throws PhpfastcacheLogicException |
49
|
|
|
*/ |
50
|
|
|
public function setHost(string $host): static |
51
|
|
|
{ |
52
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
53
|
|
|
$this->host = $host; |
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return int |
59
|
|
|
*/ |
60
|
|
|
public function getPort(): int |
61
|
|
|
{ |
62
|
|
|
return $this->port; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param int $port |
67
|
|
|
* @return self |
68
|
|
|
* @throws PhpfastcacheLogicException |
69
|
|
|
*/ |
70
|
|
|
public function setPort(int $port): static |
71
|
|
|
{ |
72
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
73
|
|
|
$this->port = $port; |
74
|
|
|
return $this; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return int |
79
|
|
|
*/ |
80
|
|
|
public function getTimeout(): int |
81
|
|
|
{ |
82
|
|
|
return $this->timeout; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param int $timeout |
87
|
|
|
* @return self |
88
|
|
|
* @throws PhpfastcacheLogicException |
89
|
|
|
*/ |
90
|
|
|
public function setTimeout(int $timeout): static |
91
|
|
|
{ |
92
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
93
|
|
|
$this->timeout = $timeout; |
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
public function getUsername(): string |
101
|
|
|
{ |
102
|
|
|
return $this->username; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $username |
107
|
|
|
* @return self |
108
|
|
|
* @throws PhpfastcacheLogicException |
109
|
|
|
*/ |
110
|
|
|
public function setUsername(string $username): static |
111
|
|
|
{ |
112
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
113
|
|
|
$this->username = $username; |
114
|
|
|
return $this; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* @return string |
119
|
|
|
*/ |
120
|
|
|
public function getPassword(): string |
121
|
|
|
{ |
122
|
|
|
return $this->password; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param string $password |
127
|
|
|
* @return self |
128
|
|
|
* @throws PhpfastcacheLogicException |
129
|
|
|
*/ |
130
|
|
|
public function setPassword(string $password): static |
131
|
|
|
{ |
132
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
133
|
|
|
$this->password = $password; |
134
|
|
|
return $this; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return bool |
139
|
|
|
*/ |
140
|
|
|
public function isSslEnabled(): bool |
141
|
|
|
{ |
142
|
|
|
return $this->sslEnabled; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param bool $sslEnabled |
147
|
|
|
* @return self |
148
|
|
|
* @throws PhpfastcacheLogicException |
149
|
|
|
*/ |
150
|
|
|
public function setSslEnabled(bool $sslEnabled): static |
151
|
|
|
{ |
152
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
153
|
|
|
$this->sslEnabled = $sslEnabled; |
154
|
|
|
return $this; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @return bool |
159
|
|
|
*/ |
160
|
|
|
public function isSslVerify(): bool |
161
|
|
|
{ |
162
|
|
|
return $this->sslVerify; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param bool $sslVerify |
167
|
|
|
* @return self |
168
|
|
|
* @throws PhpfastcacheLogicException |
169
|
|
|
*/ |
170
|
|
|
public function setSslVerify(bool $sslVerify): static |
171
|
|
|
{ |
172
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
173
|
|
|
$this->sslVerify = $sslVerify; |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return bool |
179
|
|
|
*/ |
180
|
|
|
public function isUseLegacyExecutionOptions(): bool |
181
|
|
|
{ |
182
|
|
|
return $this->useLegacyExecutionOptions; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param bool $useLegacyExecutionOptions |
187
|
|
|
* @return $this |
188
|
|
|
* @throws PhpfastcacheLogicException |
189
|
|
|
*/ |
190
|
|
|
public function setUseLegacyExecutionOptions(bool $useLegacyExecutionOptions): static |
191
|
|
|
{ |
192
|
|
|
$this->enforceLockedProperty(__FUNCTION__); |
193
|
|
|
$this->useLegacyExecutionOptions = $useLegacyExecutionOptions; |
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
|