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 file. |
9
|
|
|
* |
10
|
|
|
* @author Khoa Bui (khoaofgod) <[email protected]> https://www.phpfastcache.com |
11
|
|
|
* @author Georges.L (Geolim4) <[email protected]> |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
declare(strict_types=1); |
16
|
|
|
|
17
|
|
|
namespace Phpfastcache\Drivers\Predis; |
18
|
|
|
|
19
|
|
|
use Phpfastcache\Config\ConfigurationOption; |
20
|
|
|
|
21
|
|
|
class Config extends ConfigurationOption |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $host = '127.0.0.1'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var int |
30
|
|
|
*/ |
31
|
|
|
protected $port = 6379; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
protected $password = ''; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var int |
40
|
|
|
*/ |
41
|
|
|
protected $database = 0; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var \Predis\Client |
|
|
|
|
45
|
|
|
*/ |
46
|
|
|
protected $predisClient; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
*/ |
51
|
|
|
protected $optPrefix = ''; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
protected $timeout = 5; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return string |
60
|
|
|
*/ |
61
|
|
|
public function getHost(): string |
62
|
|
|
{ |
63
|
|
|
return $this->host; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param string $host |
68
|
|
|
* @return Config |
69
|
|
|
*/ |
70
|
|
|
public function setHost(string $host): self |
71
|
|
|
{ |
72
|
|
|
$this->host = $host; |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return int |
78
|
|
|
*/ |
79
|
|
|
public function getPort(): int |
80
|
|
|
{ |
81
|
|
|
return $this->port; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param int $port |
86
|
|
|
* @return Config |
87
|
|
|
*/ |
88
|
|
|
public function setPort(int $port): self |
89
|
|
|
{ |
90
|
|
|
$this->port = $port; |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return null |
96
|
|
|
*/ |
97
|
|
|
public function getPassword() |
98
|
|
|
{ |
99
|
|
|
return $this->password; |
|
|
|
|
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param null $password |
|
|
|
|
104
|
|
|
* @return self |
105
|
|
|
*/ |
106
|
|
|
public function setPassword(string $password): self |
107
|
|
|
{ |
108
|
|
|
$this->password = $password; |
109
|
|
|
return $this; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return int |
114
|
|
|
*/ |
115
|
|
|
public function getDatabase(): int |
116
|
|
|
{ |
117
|
|
|
return $this->database; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param int $database |
122
|
|
|
* @return Config |
123
|
|
|
*/ |
124
|
|
|
public function setDatabase(int $database): self |
125
|
|
|
{ |
126
|
|
|
$this->database = $database; |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return array |
132
|
|
|
*/ |
133
|
|
|
public function getPredisConfigArray(): array |
134
|
|
|
{ |
135
|
|
|
return [ |
136
|
|
|
'host' => $this->getHost(), |
137
|
|
|
'port' => $this->getPort(), |
138
|
|
|
'password' => $this->getPassword() ?: null, |
|
|
|
|
139
|
|
|
'database' => $this->getDatabase(), |
140
|
|
|
'timeout' => $this->getTimeout(), |
141
|
|
|
]; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @return \Predis\Client|null |
146
|
|
|
*/ |
147
|
|
|
public function getPredisClient() |
148
|
|
|
{ |
149
|
|
|
return $this->predisClient; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @param \Predis\Client $predisClient |null |
154
|
|
|
* @return Config |
155
|
|
|
*/ |
156
|
|
|
public function setPredisClient(\Predis\Client $predisClient = null): Config |
157
|
|
|
{ |
158
|
|
|
$this->predisClient = $predisClient; |
159
|
|
|
return $this; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @return string |
164
|
|
|
* @since 7.0.2 |
165
|
|
|
*/ |
166
|
|
|
public function getOptPrefix(): string |
167
|
|
|
{ |
168
|
|
|
return $this->optPrefix; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* @param string $optPrefix |
173
|
|
|
* @return Config |
174
|
|
|
* @since 7.0.2 |
175
|
|
|
*/ |
176
|
|
|
public function setOptPrefix(string $optPrefix): Config |
177
|
|
|
{ |
178
|
|
|
$this->optPrefix = trim($optPrefix); |
179
|
|
|
return $this; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return int |
184
|
|
|
*/ |
185
|
|
|
public function getTimeout(): int |
186
|
|
|
{ |
187
|
|
|
return $this->timeout; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @param int $timeout |
192
|
|
|
* @return self |
193
|
|
|
*/ |
194
|
|
|
public function setTimeout(int $timeout): self |
195
|
|
|
{ |
196
|
|
|
$this->timeout = $timeout; |
197
|
|
|
return $this; |
198
|
|
|
} |
199
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths