1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BPT\settings; |
4
|
|
|
|
5
|
|
|
use CURLFile; |
6
|
|
|
class easySettings { |
7
|
|
|
private array $settings = []; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @param string $token |
11
|
|
|
* |
12
|
|
|
* @return $this |
13
|
|
|
*/ |
14
|
|
|
public function setToken (string $token): self { |
15
|
|
|
$this->settings['token'] = $token; |
16
|
|
|
return $this; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @param string $name |
21
|
|
|
* |
22
|
|
|
* @return $this |
23
|
|
|
*/ |
24
|
|
|
public function setName (string $name): self { |
25
|
|
|
$this->settings['name'] = $name; |
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param bool $logger |
31
|
|
|
* |
32
|
|
|
* @return $this |
33
|
|
|
*/ |
34
|
|
|
public function setLogger (bool $logger): self { |
35
|
|
|
$this->settings['logger'] = $logger; |
36
|
|
|
return $this; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param int $log_size |
41
|
|
|
* |
42
|
|
|
* @return $this |
43
|
|
|
*/ |
44
|
|
|
public function setLogSize (int $log_size): self { |
45
|
|
|
$this->settings['log_size'] = $log_size; |
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string|CURLFile $certificate |
51
|
|
|
* |
52
|
|
|
* @return $this |
53
|
|
|
*/ |
54
|
|
|
public function setCertificate (string|CURLFile $certificate): self { |
55
|
|
|
$this->settings['certificate'] = $certificate; |
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param bool $handler |
61
|
|
|
* |
62
|
|
|
* @return $this |
63
|
|
|
*/ |
64
|
|
|
public function setHandler (bool $handler): self { |
65
|
|
|
$this->settings['handler'] = $handler; |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param bool $security |
71
|
|
|
* |
72
|
|
|
* @return $this |
73
|
|
|
*/ |
74
|
|
|
public function setSecurity (bool $security): self { |
75
|
|
|
$this->settings['security'] = $security; |
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param bool $secure_folder |
81
|
|
|
* |
82
|
|
|
* @return $this |
83
|
|
|
*/ |
84
|
|
|
public function setSecureFolder (bool $secure_folder): self { |
85
|
|
|
$this->settings['secure_folder'] = $secure_folder; |
86
|
|
|
return $this; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @param bool $multi |
91
|
|
|
* |
92
|
|
|
* @return $this |
93
|
|
|
*/ |
94
|
|
|
public function setMulti (bool $multi): self { |
95
|
|
|
$this->settings['multi'] = $multi; |
96
|
|
|
return $this; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @param bool $telegram_verify |
101
|
|
|
* |
102
|
|
|
* @return $this |
103
|
|
|
*/ |
104
|
|
|
public function setTelegramVerify (bool $telegram_verify): self { |
105
|
|
|
$this->settings['telegram_verify'] = $telegram_verify; |
106
|
|
|
return $this; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @param bool $cloudflare_verify |
111
|
|
|
* |
112
|
|
|
* @return $this |
113
|
|
|
*/ |
114
|
|
|
public function setCloudflareVerify (bool $cloudflare_verify): self { |
115
|
|
|
$this->settings['cloudflare_verify'] = $cloudflare_verify; |
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @param bool $arvancloud_verify |
121
|
|
|
* |
122
|
|
|
* @return $this |
123
|
|
|
*/ |
124
|
|
|
public function setArvancloudVerify (bool $arvancloud_verify): self { |
125
|
|
|
$this->settings['arvancloud_verify'] = $arvancloud_verify; |
126
|
|
|
return $this; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param bool $skip_old_updates |
131
|
|
|
* |
132
|
|
|
* @return $this |
133
|
|
|
*/ |
134
|
|
|
public function setSkipOldUpdates (bool $skip_old_updates): self { |
135
|
|
|
$this->settings['skip_old_updates'] = $skip_old_updates; |
136
|
|
|
return $this; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string $secret |
141
|
|
|
* |
142
|
|
|
* @return $this |
143
|
|
|
*/ |
144
|
|
|
public function setSecret (string $secret): self { |
145
|
|
|
$this->settings['secret'] = $secret; |
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param int $max_connection |
151
|
|
|
* |
152
|
|
|
* @return $this |
153
|
|
|
*/ |
154
|
|
|
public function setMaxConnection (int $max_connection): self { |
155
|
|
|
$this->settings['max_connection'] = $max_connection; |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param string $base_url |
161
|
|
|
* |
162
|
|
|
* @return $this |
163
|
|
|
*/ |
164
|
|
|
public function setBaseUrl (string $base_url): self { |
165
|
|
|
$this->settings['base_url'] = $base_url; |
166
|
|
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @param string $down_url |
171
|
|
|
* |
172
|
|
|
* @return $this |
173
|
|
|
*/ |
174
|
|
|
public function setDownUrl (string $down_url): self { |
175
|
|
|
$this->settings['down_url'] = $down_url; |
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param string $default_parse_mode |
181
|
|
|
* |
182
|
|
|
* @return $this |
183
|
|
|
*/ |
184
|
|
|
public function setDefaultParseMode (string $default_parse_mode): self { |
185
|
|
|
$this->settings['default_parse_mode'] = $default_parse_mode; |
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* @param bool $default_protect_content |
191
|
|
|
* |
192
|
|
|
* @return $this |
193
|
|
|
*/ |
194
|
|
|
public function setDefaultProtectContent (bool $default_protect_content): self { |
195
|
|
|
$this->settings['default_protect_content'] = $default_protect_content; |
196
|
|
|
return $this; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param int $ignore_updates_older_then |
201
|
|
|
* |
202
|
|
|
* @return $this |
203
|
|
|
*/ |
204
|
|
|
public function setIgnoreUpdatesOlderThen (int $ignore_updates_older_then): self { |
205
|
|
|
$this->settings['ignore_updates_older_then'] = $ignore_updates_older_then; |
206
|
|
|
return $this; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @param int $forgot_time |
211
|
|
|
* |
212
|
|
|
* @return $this |
213
|
|
|
*/ |
214
|
|
|
public function setForgotTime (int $forgot_time): self { |
215
|
|
|
$this->settings['forgot_time'] = $forgot_time; |
216
|
|
|
return $this; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @param int $base_timeout |
221
|
|
|
* |
222
|
|
|
* @return $this |
223
|
|
|
*/ |
224
|
|
|
public function setBaseTimeout (int $base_timeout): self { |
225
|
|
|
$this->settings['base_timeout'] = $base_timeout; |
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* @param string|null $receiver |
231
|
|
|
* |
232
|
|
|
* @return $this |
233
|
|
|
*/ |
234
|
|
|
public function setReceiver (string|null $receiver): self { |
235
|
|
|
$this->settings['receiver'] = $receiver; |
236
|
|
|
return $this; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* @param array $allowed_updates |
241
|
|
|
* |
242
|
|
|
* @return $this |
243
|
|
|
*/ |
244
|
|
|
public function setAllowedUpdates (array $allowed_updates): self { |
245
|
|
|
$this->settings['allowed_updates'] = $allowed_updates; |
246
|
|
|
return $this; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @param bool $use_types_classes |
251
|
|
|
* |
252
|
|
|
* @return $this |
253
|
|
|
*/ |
254
|
|
|
public function setUseTypesClasses (bool $use_types_classes): self { |
255
|
|
|
$this->settings['use_types_classes'] = $use_types_classes; |
256
|
|
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
/** |
260
|
|
|
* @param null|array|easySQL|easyJson $db |
261
|
|
|
* |
262
|
|
|
* @return $this |
263
|
|
|
*/ |
264
|
|
|
public function setDB (array|easySQL|easyJson|null $db): self { |
265
|
|
|
if (!is_array($db) && !empty($db)) { |
|
|
|
|
266
|
|
|
$db = $db->getSettings(); |
267
|
|
|
} |
268
|
|
|
$this->settings['db'] = $db; |
269
|
|
|
return $this; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @param array|easyPay $pay |
274
|
|
|
* |
275
|
|
|
* @return $this |
276
|
|
|
*/ |
277
|
|
|
public function setPay (array|easyPay $pay): self { |
278
|
|
|
if (!is_array($pay)) { |
|
|
|
|
279
|
|
|
$pay = $pay->getSettings(); |
280
|
|
|
} |
281
|
|
|
$this->settings['pay'] = $pay; |
282
|
|
|
return $this; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @return array |
287
|
|
|
*/ |
288
|
|
|
public function getSettings (): array { |
289
|
|
|
return $this->settings; |
290
|
|
|
} |
291
|
|
|
} |