1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* This file is part of Phpfastcache. |
5
|
|
|
* |
6
|
|
|
* @license MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* For full copyright and license information, please see the docs/CREDITS.txt and LICENCE files. |
9
|
|
|
* |
10
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
11
|
|
|
* @author Contributors https://github.com/PHPSocialNetwork/phpfastcache/graphs/contributors |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
declare(strict_types=1); |
15
|
|
|
|
16
|
|
|
namespace Phpfastcache\Drivers\Arangodb; |
17
|
|
|
|
18
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @see https://github.com/arangodb/arangodb-php/blob/devel/examples/init.php |
22
|
|
|
* @SuppressWarnings(PHPMD.TooManyFields) |
23
|
|
|
*/ |
24
|
|
|
class Config extends ConfigurationOption |
25
|
|
|
{ |
26
|
|
|
protected string $database; |
27
|
|
|
|
28
|
|
|
protected string $collection; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* HTTP ENDPOINT: ssl://localhost:8529 |
32
|
|
|
* SSL ENDPOINT: ssl://localhost:8529 |
33
|
|
|
* UNIX ENDPOINT: unix:///tmp/arangodb.sock |
34
|
|
|
* Failover ENDPOINTS: ['tcp://localhost:8529', 'tcp://another-host:8529'] |
35
|
|
|
*/ |
36
|
|
|
protected string|array $endpoint = 'tcp://127.0.0.1:8529'; |
37
|
|
|
|
38
|
|
|
protected string $connection = 'Keep-Alive'; // enum{'Close', 'Keep-Alive'} |
39
|
|
|
|
40
|
|
|
protected string $authType = 'Basic'; // enum{'Bearer', 'Basic'} |
41
|
|
|
|
42
|
|
|
protected string $authUser = ''; |
43
|
|
|
|
44
|
|
|
protected string $authPasswd = ''; |
45
|
|
|
|
46
|
|
|
protected ?string $authJwt = null; |
47
|
|
|
|
48
|
|
|
protected bool $autoCreate = false; // Do not create unknown collections automatically |
49
|
|
|
|
50
|
|
|
protected int $connectTimeout = 3; |
51
|
|
|
|
52
|
|
|
protected int $requestTimeout = 5; |
53
|
|
|
|
54
|
|
|
protected string $updatePolicy = 'last'; |
55
|
|
|
|
56
|
|
|
protected bool $verifyCert = true; |
57
|
|
|
|
58
|
|
|
protected bool $selfSigned = true; |
59
|
|
|
|
60
|
|
|
protected string $ciphers = 'DEFAULT'; // @see https://www.openssl.org/docs/manmaster/apps/ciphers.html |
61
|
|
|
|
62
|
|
|
protected ?\Closure $traceFunction = null; |
63
|
|
|
|
64
|
|
|
public function getDatabase(): string |
65
|
|
|
{ |
66
|
|
|
return $this->database; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function setDatabase(string $database): Config |
70
|
|
|
{ |
71
|
|
|
$this->database = $database; |
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getCollection(): string |
76
|
|
|
{ |
77
|
|
|
return $this->collection; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setCollection(string $collection): Config |
81
|
|
|
{ |
82
|
|
|
$this->collection = $collection; |
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function getEndpoint(): string|array |
87
|
|
|
{ |
88
|
|
|
return $this->endpoint; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function setEndpoint(string|array $endpoint): Config |
92
|
|
|
{ |
93
|
|
|
$this->endpoint = $endpoint; |
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function getConnection(): string |
98
|
|
|
{ |
99
|
|
|
return $this->connection; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function setConnection(string $connection): Config |
103
|
|
|
{ |
104
|
|
|
$this->connection = $connection; |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
public function getAuthType(): string |
109
|
|
|
{ |
110
|
|
|
return $this->authType; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function setAuthType(string $authType): Config |
114
|
|
|
{ |
115
|
|
|
$this->authType = $authType; |
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function getAuthUser(): string |
120
|
|
|
{ |
121
|
|
|
return $this->authUser; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setAuthUser(string $authUser): Config |
125
|
|
|
{ |
126
|
|
|
$this->authUser = $authUser; |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function getAuthPasswd(): string |
131
|
|
|
{ |
132
|
|
|
return $this->authPasswd; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
public function setAuthPasswd(string $authPasswd): Config |
136
|
|
|
{ |
137
|
|
|
$this->authPasswd = $authPasswd; |
138
|
|
|
return $this; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @return string|null |
143
|
|
|
*/ |
144
|
|
|
public function getAuthJwt(): ?string |
145
|
|
|
{ |
146
|
|
|
return $this->authJwt; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string|null $authJwt |
151
|
|
|
* @return Config |
152
|
|
|
*/ |
153
|
|
|
public function setAuthJwt(?string $authJwt): Config |
154
|
|
|
{ |
155
|
|
|
$this->authJwt = $authJwt; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function isAutoCreate(): bool |
160
|
|
|
{ |
161
|
|
|
return $this->autoCreate; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function setAutoCreate(bool $autoCreate): Config |
165
|
|
|
{ |
166
|
|
|
$this->autoCreate = $autoCreate; |
167
|
|
|
return $this; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
public function getConnectTimeout(): int |
171
|
|
|
{ |
172
|
|
|
return $this->connectTimeout; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function setConnectTimeout(int $connectTimeout): Config |
176
|
|
|
{ |
177
|
|
|
$this->connectTimeout = $connectTimeout; |
178
|
|
|
return $this; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
public function getRequestTimeout(): int |
182
|
|
|
{ |
183
|
|
|
return $this->requestTimeout; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
public function setRequestTimeout(int $requestTimeout): Config |
187
|
|
|
{ |
188
|
|
|
$this->requestTimeout = $requestTimeout; |
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function getUpdatePolicy(): string |
193
|
|
|
{ |
194
|
|
|
return $this->updatePolicy; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
public function setUpdatePolicy(string $updatePolicy): Config |
198
|
|
|
{ |
199
|
|
|
$this->updatePolicy = $updatePolicy; |
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
public function isVerifyCert(): bool |
204
|
|
|
{ |
205
|
|
|
return $this->verifyCert; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function setVerifyCert(bool $verifyCert): Config |
209
|
|
|
{ |
210
|
|
|
$this->verifyCert = $verifyCert; |
211
|
|
|
return $this; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
public function isSelfSigned(): bool |
215
|
|
|
{ |
216
|
|
|
return $this->selfSigned; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
public function setSelfSigned(bool $selfSigned): Config |
220
|
|
|
{ |
221
|
|
|
$this->selfSigned = $selfSigned; |
222
|
|
|
return $this; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function getCiphers(): string |
226
|
|
|
{ |
227
|
|
|
return $this->ciphers; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
public function setCiphers(string $ciphers): Config |
231
|
|
|
{ |
232
|
|
|
$this->ciphers = $ciphers; |
233
|
|
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return \Closure|null |
238
|
|
|
*/ |
239
|
|
|
public function getTraceFunction(): ?\Closure |
240
|
|
|
{ |
241
|
|
|
return $this->traceFunction; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param \Closure|null $traceFunction |
246
|
|
|
* @return Config |
247
|
|
|
*/ |
248
|
|
|
public function setTraceFunction(?\Closure $traceFunction): Config |
249
|
|
|
{ |
250
|
|
|
$this->traceFunction = $traceFunction; |
251
|
|
|
return $this; |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
|