@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init (int $log_size = 10): void { |
|
20 | + public static function init(int $log_size = 10): void { |
|
21 | 21 | self::$log_size = $log_size; |
22 | 22 | $log_file = realpath(settings::$name.'BPT.log'); |
23 | 23 | $mode = file_exists($log_file) && self::$log_size * 1024 * 1024 > filesize($log_file) ? 'a' : 'w'; |
24 | 24 | self::$handler = fopen(settings::$name.'BPT.log', $mode); |
25 | 25 | if ($mode === 'w') { |
26 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
26 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
27 | 27 | } |
28 | 28 | if (self::$waited_logs != []) { |
29 | 29 | foreach (self::$waited_logs as $log) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
46 | - $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n"; |
|
46 | + $text = date('Y/m/d H:i:s').($type !== loggerTypes::NONE ? " : ⤵\n$type" : '')." : $data\n\n"; |
|
47 | 47 | if (!is_null(self::$handler)) { |
48 | 48 | fwrite(self::$handler, $text); |
49 | 49 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return $this |
16 | 16 | */ |
17 | - public function setGlobal (array $global): self { |
|
17 | + public function setGlobal(array $global): self { |
|
18 | 18 | $this->settings['global'] = $global; |
19 | 19 | return $this; |
20 | 20 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return $this |
26 | 26 | */ |
27 | - public function setGroup (array $group): self { |
|
27 | + public function setGroup(array $group): self { |
|
28 | 28 | $this->settings['group'] = $group; |
29 | 29 | return $this; |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return $this |
36 | 36 | */ |
37 | - public function setSuperGroup (array $supergroup): self { |
|
37 | + public function setSuperGroup(array $supergroup): self { |
|
38 | 38 | $this->settings['supergroup'] = $supergroup; |
39 | 39 | return $this; |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return $this |
46 | 46 | */ |
47 | - public function setChannel (array $channel): self { |
|
47 | + public function setChannel(array $channel): self { |
|
48 | 48 | $this->settings['channel'] = $channel; |
49 | 49 | return $this; |
50 | 50 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function setUser (array $user): self { |
|
57 | + public function setUser(array $user): self { |
|
58 | 58 | $this->settings['user'] = $user; |
59 | 59 | return $this; |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return $this |
66 | 66 | */ |
67 | - public function setGroupUser (array $group_user): self { |
|
67 | + public function setGroupUser(array $group_user): self { |
|
68 | 68 | $this->settings['group_user'] = $group_user; |
69 | 69 | return $this; |
70 | 70 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function getSettings (): array { |
|
75 | + public function getSettings(): array { |
|
76 | 76 | return $this->settings; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | \ No newline at end of file |
@@ -4,17 +4,17 @@ |
||
4 | 4 | class easyIdpay { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setApiKey (string $api_key): self { |
|
7 | + public function setApiKey(string $api_key): self { |
|
8 | 8 | $this->settings['api_key'] = $api_key; |
9 | 9 | return $this; |
10 | 10 | } |
11 | 11 | |
12 | - public function setSandbox (string $sandbox): self { |
|
12 | + public function setSandbox(string $sandbox): self { |
|
13 | 13 | $this->settings['sandbox'] = $sandbox; |
14 | 14 | return $this; |
15 | 15 | } |
16 | 16 | |
17 | - public function getSettings (): array { |
|
17 | + public function getSettings(): array { |
|
18 | 18 | return $this->settings; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
4 | 4 | class easyZarinpal { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setSandbox (string $sandbox): self { |
|
7 | + public function setSandbox(string $sandbox): self { |
|
8 | 8 | $this->settings['sandbox'] = $sandbox; |
9 | 9 | return $this; |
10 | 10 | } |
11 | 11 | |
12 | - public function setZarinGate (string $zarin_gate): self { |
|
12 | + public function setZarinGate(string $zarin_gate): self { |
|
13 | 13 | $this->settings['zarin_gate'] = $zarin_gate; |
14 | 14 | return $this; |
15 | 15 | } |
16 | 16 | |
17 | - public function setMerchantId (int $merchant_id): self { |
|
17 | + public function setMerchantId(int $merchant_id): self { |
|
18 | 18 | $this->settings['merchant_id'] = $merchant_id; |
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 | |
22 | - public function getSettings (): array { |
|
22 | + public function getSettings(): array { |
|
23 | 23 | return $this->settings; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return $this |
15 | 15 | */ |
16 | - public function setHost (string $host): self { |
|
16 | + public function setHost(string $host): self { |
|
17 | 17 | $this->settings['host'] = $host; |
18 | 18 | return $this; |
19 | 19 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function setPort (string $port): self { |
|
26 | + public function setPort(string $port): self { |
|
27 | 27 | $this->settings['port'] = $port; |
28 | 28 | return $this; |
29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function setUsername (string $user): self { |
|
36 | + public function setUsername(string $user): self { |
|
37 | 37 | $this->settings['user'] = $user; |
38 | 38 | return $this; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return $this |
45 | 45 | */ |
46 | - public function setPassword (string $pass): self { |
|
46 | + public function setPassword(string $pass): self { |
|
47 | 47 | $this->settings['pass'] = $pass; |
48 | 48 | return $this; |
49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function setDBName (string $dbname): self { |
|
56 | + public function setDBName(string $dbname): self { |
|
57 | 57 | $this->settings['dbname'] = $dbname; |
58 | 58 | return $this; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function setAutoProcess (bool $auto_process): self { |
|
66 | + public function setAutoProcess(bool $auto_process): self { |
|
67 | 67 | $this->settings['auto_process'] = $auto_process; |
68 | 68 | return $this; |
69 | 69 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return $this |
75 | 75 | */ |
76 | - public function setAutoLoad (bool $auto_load): self { |
|
76 | + public function setAutoLoad(bool $auto_load): self { |
|
77 | 77 | $this->settings['auto_load'] = $auto_load; |
78 | 78 | return $this; |
79 | 79 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function getSettings (): array { |
|
84 | + public function getSettings(): array { |
|
85 | 85 | return $this->settings; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
4 | 4 | class easyCrypto { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setApiKey (string $api_key): self { |
|
7 | + public function setApiKey(string $api_key): self { |
|
8 | 8 | $this->settings['api_key'] = $api_key; |
9 | 9 | return $this; |
10 | 10 | } |
11 | 11 | |
12 | - public function setIpnSecret (string $ipn_secret): self { |
|
12 | + public function setIpnSecret(string $ipn_secret): self { |
|
13 | 13 | $this->settings['ipn_secret'] = $ipn_secret; |
14 | 14 | return $this; |
15 | 15 | } |
16 | 16 | |
17 | - public function setRoundDecimal (int $round_decimal): self { |
|
17 | + public function setRoundDecimal(int $round_decimal): self { |
|
18 | 18 | $this->settings['round_decimal'] = $round_decimal; |
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 | |
22 | - public function getSettings (): array { |
|
22 | + public function getSettings(): array { |
|
23 | 23 | return $this->settings; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | class easyPay { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setCrypto (array|easyCrypto $crypto): self { |
|
7 | + public function setCrypto(array | easyCrypto $crypto): self { |
|
8 | 8 | if (!is_array($crypto) && !empty($crypto)) { |
9 | 9 | $crypto = $crypto->getSettings(); |
10 | 10 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | return $this; |
13 | 13 | } |
14 | 14 | |
15 | - public function setIdpay (array|easyIdpay $idpay): self { |
|
15 | + public function setIdpay(array | easyIdpay $idpay): self { |
|
16 | 16 | if (!is_array($idpay) && !empty($idpay)) { |
17 | 17 | $idpay = $idpay->getSettings(); |
18 | 18 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | return $this; |
21 | 21 | } |
22 | 22 | |
23 | - public function setZarinpal (array|easyZarinpal $zarinpal): self { |
|
23 | + public function setZarinpal(array | easyZarinpal $zarinpal): self { |
|
24 | 24 | if (!is_array($zarinpal) && !empty($zarinpal)) { |
25 | 25 | $zarinpal = $zarinpal->getSettings(); |
26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return $this; |
29 | 29 | } |
30 | 30 | |
31 | - public function getSettings (): array { |
|
31 | + public function getSettings(): array { |
|
32 | 32 | return $this->settings; |
33 | 33 | } |
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * |
12 | 12 | * @return $this |
13 | 13 | */ |
14 | - public function setToken (string $token): self { |
|
14 | + public function setToken(string $token): self { |
|
15 | 15 | $this->settings['token'] = $token; |
16 | 16 | return $this; |
17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @return $this |
23 | 23 | */ |
24 | - public function setName (string $name): self { |
|
24 | + public function setName(string $name): self { |
|
25 | 25 | $this->settings['name'] = $name; |
26 | 26 | return $this; |
27 | 27 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return $this |
33 | 33 | */ |
34 | - public function setLogger (bool $logger): self { |
|
34 | + public function setLogger(bool $logger): self { |
|
35 | 35 | $this->settings['logger'] = $logger; |
36 | 36 | return $this; |
37 | 37 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return $this |
43 | 43 | */ |
44 | - public function setLogSize (int $log_size): self { |
|
44 | + public function setLogSize(int $log_size): self { |
|
45 | 45 | $this->settings['log_size'] = $log_size; |
46 | 46 | return $this; |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return $this |
53 | 53 | */ |
54 | - public function setCertificate (string|CURLFile $certificate): self { |
|
54 | + public function setCertificate(string | CURLFile $certificate): self { |
|
55 | 55 | $this->settings['certificate'] = $certificate; |
56 | 56 | return $this; |
57 | 57 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return $this |
63 | 63 | */ |
64 | - public function setHandler (bool $handler): self { |
|
64 | + public function setHandler(bool $handler): self { |
|
65 | 65 | $this->settings['handler'] = $handler; |
66 | 66 | return $this; |
67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return $this |
73 | 73 | */ |
74 | - public function setSecurity (bool $security): self { |
|
74 | + public function setSecurity(bool $security): self { |
|
75 | 75 | $this->settings['security'] = $security; |
76 | 76 | return $this; |
77 | 77 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return $this |
83 | 83 | */ |
84 | - public function setSecureFolder (bool $secure_folder): self { |
|
84 | + public function setSecureFolder(bool $secure_folder): self { |
|
85 | 85 | $this->settings['secure_folder'] = $secure_folder; |
86 | 86 | return $this; |
87 | 87 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return $this |
93 | 93 | */ |
94 | - public function setMulti (bool $multi): self { |
|
94 | + public function setMulti(bool $multi): self { |
|
95 | 95 | $this->settings['multi'] = $multi; |
96 | 96 | return $this; |
97 | 97 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return $this |
103 | 103 | */ |
104 | - public function setTelegramVerify (bool $telegram_verify): self { |
|
104 | + public function setTelegramVerify(bool $telegram_verify): self { |
|
105 | 105 | $this->settings['telegram_verify'] = $telegram_verify; |
106 | 106 | return $this; |
107 | 107 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return $this |
113 | 113 | */ |
114 | - public function setCloudflareVerify (bool $cloudflare_verify): self { |
|
114 | + public function setCloudflareVerify(bool $cloudflare_verify): self { |
|
115 | 115 | $this->settings['cloudflare_verify'] = $cloudflare_verify; |
116 | 116 | return $this; |
117 | 117 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return $this |
123 | 123 | */ |
124 | - public function setArvancloudVerify (bool $arvancloud_verify): self { |
|
124 | + public function setArvancloudVerify(bool $arvancloud_verify): self { |
|
125 | 125 | $this->settings['arvancloud_verify'] = $arvancloud_verify; |
126 | 126 | return $this; |
127 | 127 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return $this |
133 | 133 | */ |
134 | - public function setSkipOldUpdates (bool $skip_old_updates): self { |
|
134 | + public function setSkipOldUpdates(bool $skip_old_updates): self { |
|
135 | 135 | $this->settings['skip_old_updates'] = $skip_old_updates; |
136 | 136 | return $this; |
137 | 137 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return $this |
143 | 143 | */ |
144 | - public function setSecret (string $secret): self { |
|
144 | + public function setSecret(string $secret): self { |
|
145 | 145 | $this->settings['secret'] = $secret; |
146 | 146 | return $this; |
147 | 147 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return $this |
153 | 153 | */ |
154 | - public function setMaxConnection (int $max_connection): self { |
|
154 | + public function setMaxConnection(int $max_connection): self { |
|
155 | 155 | $this->settings['max_connection'] = $max_connection; |
156 | 156 | return $this; |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @return $this |
163 | 163 | */ |
164 | - public function setBaseUrl (string $base_url): self { |
|
164 | + public function setBaseUrl(string $base_url): self { |
|
165 | 165 | $this->settings['base_url'] = $base_url; |
166 | 166 | return $this; |
167 | 167 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return $this |
173 | 173 | */ |
174 | - public function setDownUrl (string $down_url): self { |
|
174 | + public function setDownUrl(string $down_url): self { |
|
175 | 175 | $this->settings['down_url'] = $down_url; |
176 | 176 | return $this; |
177 | 177 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return $this |
183 | 183 | */ |
184 | - public function setDefaultParseMode (string $default_parse_mode): self { |
|
184 | + public function setDefaultParseMode(string $default_parse_mode): self { |
|
185 | 185 | $this->settings['default_parse_mode'] = $default_parse_mode; |
186 | 186 | return $this; |
187 | 187 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return $this |
193 | 193 | */ |
194 | - public function setDefaultProtectContent (bool $default_protect_content): self { |
|
194 | + public function setDefaultProtectContent(bool $default_protect_content): self { |
|
195 | 195 | $this->settings['default_protect_content'] = $default_protect_content; |
196 | 196 | return $this; |
197 | 197 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return $this |
203 | 203 | */ |
204 | - public function setIgnoreUpdatesOlderThen (int $ignore_updates_older_then): self { |
|
204 | + public function setIgnoreUpdatesOlderThen(int $ignore_updates_older_then): self { |
|
205 | 205 | $this->settings['ignore_updates_older_then'] = $ignore_updates_older_then; |
206 | 206 | return $this; |
207 | 207 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return $this |
213 | 213 | */ |
214 | - public function setForgotTime (int $forgot_time): self { |
|
214 | + public function setForgotTime(int $forgot_time): self { |
|
215 | 215 | $this->settings['forgot_time'] = $forgot_time; |
216 | 216 | return $this; |
217 | 217 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return $this |
223 | 223 | */ |
224 | - public function setBaseTimeout (int $base_timeout): self { |
|
224 | + public function setBaseTimeout(int $base_timeout): self { |
|
225 | 225 | $this->settings['base_timeout'] = $base_timeout; |
226 | 226 | return $this; |
227 | 227 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return $this |
233 | 233 | */ |
234 | - public function setReceiver (string|null $receiver): self { |
|
234 | + public function setReceiver(string | null $receiver): self { |
|
235 | 235 | $this->settings['receiver'] = $receiver; |
236 | 236 | return $this; |
237 | 237 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return $this |
243 | 243 | */ |
244 | - public function setAllowedUpdates (array $allowed_updates): self { |
|
244 | + public function setAllowedUpdates(array $allowed_updates): self { |
|
245 | 245 | $this->settings['allowed_updates'] = $allowed_updates; |
246 | 246 | return $this; |
247 | 247 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return $this |
253 | 253 | */ |
254 | - public function setUseTypesClasses (bool $use_types_classes): self { |
|
254 | + public function setUseTypesClasses(bool $use_types_classes): self { |
|
255 | 255 | $this->settings['use_types_classes'] = $use_types_classes; |
256 | 256 | return $this; |
257 | 257 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return $this |
263 | 263 | */ |
264 | - public function setDB (array|easySQL|easyJson|null $db): self { |
|
264 | + public function setDB(array | easySQL | easyJson | null $db): self { |
|
265 | 265 | if (!is_array($db) && !empty($db)) { |
266 | 266 | $db = $db->getSettings(); |
267 | 267 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @return $this |
276 | 276 | */ |
277 | - public function setPay (array|easyPay $pay): self { |
|
277 | + public function setPay(array | easyPay $pay): self { |
|
278 | 278 | if (!is_array($pay)) { |
279 | 279 | $pay = $pay->getSettings(); |
280 | 280 | } |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | /** |
286 | 286 | * @return array |
287 | 287 | */ |
288 | - public function getSettings (): array { |
|
288 | + public function getSettings(): array { |
|
289 | 289 | return $this->settings; |
290 | 290 | } |
291 | 291 | } |
292 | 292 | \ No newline at end of file |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * If you want to use it in standalone mode , you MUST set `auto_process` to `false` |
35 | 35 | */ |
36 | - public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
36 | + public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void { |
|
37 | 37 | $host = settings::$db['host'] ?? $host; |
38 | 38 | $port = settings::$db['port'] ?? $port; |
39 | 39 | $user = settings::$db['user'] ?? settings::$db['username'] ?? $username; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | self::$db_name = $dbname; |
45 | 45 | self::$connection = new mysqli($host, $user, $pass, $dbname, $port); |
46 | 46 | if (self::$connection->connect_errno) { |
47 | - logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR); |
|
47 | + logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR); |
|
48 | 48 | throw new bptException('SQL_CONNECTION_PROBLEM'); |
49 | 49 | } |
50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | - private static function install (): void { |
|
56 | + private static function install(): void { |
|
57 | 57 | if (self::$auto_process) { |
58 | 58 | self::pureQuery(" |
59 | 59 | CREATE TABLE `users` |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | foreach ($allowed_file_names as $allowed_file_name) { |
90 | 90 | if (file_exists($allowed_file_name)) { |
91 | 91 | $mysqli->multi_query(file_get_contents($allowed_file_name)); |
92 | - while ($mysqli->next_result()){if (!$mysqli->more_results()) break;} |
|
92 | + while ($mysqli->next_result()) {if (!$mysqli->more_results()) break; } |
|
93 | 93 | $loaded = true; |
94 | 94 | } |
95 | 95 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @internal Only for BPT self usage , Don't use it in your source! |
105 | 105 | */ |
106 | - public static function process (): void { |
|
106 | + public static function process(): void { |
|
107 | 107 | if (self::$auto_process) { |
108 | 108 | if (isset(BPT::$update->message)) { |
109 | 109 | self::processMessage(BPT::$update->message); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - private static function processMessage (message $update): void { |
|
126 | + private static function processMessage(message $update): void { |
|
127 | 127 | $type = $update->chat->type; |
128 | 128 | if ($type === chatType::PRIVATE) { |
129 | 129 | $user_id = $update->from->id; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - private static function processCallbackQuery (callbackQuery $update): void { |
|
152 | + private static function processCallbackQuery(callbackQuery $update): void { |
|
153 | 153 | $type = $update->message->chat->type; |
154 | 154 | if ($type === chatType::PRIVATE) { |
155 | 155 | $user_id = $update->from->id; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - private static function processInlineQuery (inlineQuery $update): void { |
|
162 | + private static function processInlineQuery(inlineQuery $update): void { |
|
163 | 163 | $type = $update->chat_type; |
164 | 164 | if ($type === chatType::PRIVATE || $type === chatType::SENDER) { |
165 | 165 | $user_id = $update->from->id; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - private static function processMyChatMember (chatMemberUpdated $update): void { |
|
172 | + private static function processMyChatMember(chatMemberUpdated $update): void { |
|
173 | 173 | $type = $update->chat->type; |
174 | 174 | if ($type === chatType::PRIVATE) { |
175 | 175 | if ($update->new_chat_member->status === chatMemberStatus::MEMBER) { |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return bool |
194 | 194 | */ |
195 | - public static function addDefaultWhere (array $where): bool { |
|
195 | + public static function addDefaultWhere(array $where): bool { |
|
196 | 196 | if (empty(self::$default_where)) { |
197 | 197 | self::$default_where = $where; |
198 | 198 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mysqli |
209 | 209 | */ |
210 | - public static function getMysqli (): mysqli|false { |
|
210 | + public static function getMysqli(): mysqli | false { |
|
211 | 211 | return self::$connection ?? false; |
212 | 212 | } |
213 | 213 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return int|string |
220 | 220 | */ |
221 | - public static function affected_rows (): int|string { |
|
221 | + public static function affected_rows(): int | string { |
|
222 | 222 | return self::$connection->affected_rows; |
223 | 223 | } |
224 | 224 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return int|string |
231 | 231 | */ |
232 | - public static function affectedRows (): int|string { |
|
232 | + public static function affectedRows(): int | string { |
|
233 | 233 | return self::$connection->affected_rows; |
234 | 234 | } |
235 | 235 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @return int|string |
242 | 242 | */ |
243 | - public static function insert_id (): int|string { |
|
243 | + public static function insert_id(): int | string { |
|
244 | 244 | return self::$connection->insert_id; |
245 | 245 | } |
246 | 246 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return int|string |
253 | 253 | */ |
254 | - public static function insertId (): int|string { |
|
254 | + public static function insertId(): int | string { |
|
255 | 255 | return self::$connection->insert_id; |
256 | 256 | } |
257 | 257 | |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public static function escapeString (string $text): string { |
|
265 | + public static function escapeString(string $text): string { |
|
266 | 266 | return self::$connection->real_escape_string($text); |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - public static function error (): string { |
|
274 | + public static function error(): string { |
|
275 | 275 | return self::$connection->error; |
276 | 276 | } |
277 | 277 | |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return int |
282 | 282 | */ |
283 | - public static function errno (): int { |
|
283 | + public static function errno(): int { |
|
284 | 284 | return self::$connection->errno; |
285 | 285 | } |
286 | 286 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * |
292 | 292 | * @return bool |
293 | 293 | */ |
294 | - public static function setCharset (string $charset): bool { |
|
294 | + public static function setCharset(string $charset): bool { |
|
295 | 295 | return self::$connection->set_charset($charset); |
296 | 296 | } |
297 | 297 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * |
307 | 307 | * @return mysqli_result|bool |
308 | 308 | */ |
309 | - public static function pureQuery (string $query): mysqli_result|bool { |
|
309 | + public static function pureQuery(string $query): mysqli_result | bool { |
|
310 | 310 | return self::$connection->query($query); |
311 | 311 | } |
312 | 312 | |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @return mysqli_result|bool |
329 | 329 | */ |
330 | - public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool { |
|
330 | + public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool { |
|
331 | 331 | if (empty($vars)) { |
332 | 332 | return self::pureQuery($query); |
333 | 333 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | $types .= 's'; |
345 | 345 | } |
346 | 346 | } |
347 | - $prepare->bind_param($types,...$vars); |
|
347 | + $prepare->bind_param($types, ...$vars); |
|
348 | 348 | if (!$prepare->execute()) { |
349 | 349 | logger::write(loggerTypes::WARNING, $prepare->error); |
350 | 350 | return false; |
@@ -391,8 +391,8 @@ discard block |
||
391 | 391 | else { |
392 | 392 | $query .= ' AND'; |
393 | 393 | } |
394 | - $operator = substr($sub_value,0,2); |
|
395 | - $operator_value = substr($sub_value,2); |
|
394 | + $operator = substr($sub_value, 0, 2); |
|
395 | + $operator_value = substr($sub_value, 2); |
|
396 | 396 | switch ($operator) { |
397 | 397 | case '>=': |
398 | 398 | $query .= " `$name` >= ?"; |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | $sub_value = $operator_value; |
420 | 420 | break; |
421 | 421 | case '##': |
422 | - $operator = substr($operator_value,0,2); |
|
423 | - $column = substr($operator_value,2); |
|
422 | + $operator = substr($operator_value, 0, 2); |
|
423 | + $column = substr($operator_value, 2); |
|
424 | 424 | $query .= match ($operator) { |
425 | 425 | '>=' => " `$name` >= `$column`", |
426 | 426 | '<=' => " `$name` <= `$column`", |
@@ -444,17 +444,17 @@ discard block |
||
444 | 444 | return $values; |
445 | 445 | } |
446 | 446 | |
447 | - private static function groupByBuilder(string &$query, string|array $group_by = []): void { |
|
447 | + private static function groupByBuilder(string &$query, string | array $group_by = []): void { |
|
448 | 448 | if (empty($group_by)) { |
449 | 449 | return; |
450 | 450 | } |
451 | 451 | if (is_string($group_by)) { |
452 | 452 | $group_by = [$group_by]; |
453 | 453 | } |
454 | - $query .= ' GROUP BY `' . implode('`, `',$group_by) . '`'; |
|
454 | + $query .= ' GROUP BY `'.implode('`, `', $group_by).'`'; |
|
455 | 455 | } |
456 | 456 | |
457 | - private static function orderByBuilder(string &$query, string|array $order_by = []): void { |
|
457 | + private static function orderByBuilder(string &$query, string | array $order_by = []): void { |
|
458 | 458 | if (empty($order_by)) { |
459 | 459 | return; |
460 | 460 | } |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | continue; |
508 | 508 | } |
509 | 509 | |
510 | - $operator = substr($value,0,2); |
|
511 | - $operator_value = substr($value,2); |
|
510 | + $operator = substr($value, 0, 2); |
|
511 | + $operator_value = substr($value, 2); |
|
512 | 512 | switch ($operator) { |
513 | 513 | case '+=': |
514 | 514 | $query .= " `$name` = `$name` + ?"; |
@@ -541,14 +541,14 @@ discard block |
||
541 | 541 | return $values; |
542 | 542 | } |
543 | 543 | |
544 | - private static function insertBuilder(string &$query, string|array $columns, array|string $values): array { |
|
545 | - $query .= '(`' . (is_string($columns) ? $columns : implode('`, `', $columns)) . '`) VALUES ('; |
|
544 | + private static function insertBuilder(string &$query, string | array $columns, array | string $values): array { |
|
545 | + $query .= '(`'.(is_string($columns) ? $columns : implode('`, `', $columns)).'`) VALUES ('; |
|
546 | 546 | if (is_string($values)) $values = [$values]; |
547 | - $query .= '?' . str_repeat(', ?', count($values) - 1) . ')'; |
|
547 | + $query .= '?'.str_repeat(', ?', count($values) - 1).')'; |
|
548 | 548 | return $values; |
549 | 549 | } |
550 | 550 | |
551 | - private static function selectBuilder (string &$query, string|array $columns): void { |
|
551 | + private static function selectBuilder(string &$query, string | array $columns): void { |
|
552 | 552 | if ($columns == '*') { |
553 | 553 | $query .= ' * '; |
554 | 554 | return; |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | $formatted = '*'; |
568 | 568 | $column = 'all'; |
569 | 569 | } |
570 | - $query .= strtoupper($function) . "($formatted) as `{$function}_$column`"; |
|
570 | + $query .= strtoupper($function)."($formatted) as `{$function}_$column`"; |
|
571 | 571 | } |
572 | 572 | else { |
573 | 573 | $query .= "`$column`"; |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | * |
594 | 594 | * @return bool |
595 | 595 | */ |
596 | - public static function delete (string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
596 | + public static function delete(string $table, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
597 | 597 | $query = "DELETE FROM `$table`"; |
598 | 598 | $vars = self::whereBuilder($query, $where, $ignore_default_where); |
599 | 599 | self::countBuilder($query, $count, $offset); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | * |
615 | 615 | * @return bool |
616 | 616 | */ |
617 | - public static function update (string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
617 | + public static function update(string $table, array $modify, array $where = [], int $count = null, int $offset = null, bool $ignore_default_where = false): bool { |
|
618 | 618 | $query = "UPDATE `$table` SET"; |
619 | 619 | $modify_vars = self::updateBuilder($query, $modify); |
620 | 620 | $where_vars = self::whereBuilder($query, $where, $ignore_default_where); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * |
634 | 634 | * @return bool |
635 | 635 | */ |
636 | - public static function insert (string $table, string|array $columns, array|string $values): bool { |
|
636 | + public static function insert(string $table, string | array $columns, array | string $values): bool { |
|
637 | 637 | $query = "INSERT INTO `$table`"; |
638 | 638 | $values = self::insertBuilder($query, $columns, $values); |
639 | 639 | return self::query($query, $values, false); |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | * |
657 | 657 | * @return bool |
658 | 658 | */ |
659 | - public static function insertUpdate (string $table, string|array $columns, array|string $values, array $modify): bool { |
|
659 | + public static function insertUpdate(string $table, string | array $columns, array | string $values, array $modify): bool { |
|
660 | 660 | $query = "INSERT INTO `$table`"; |
661 | 661 | $values = self::insertBuilder($query, $columns, $values); |
662 | 662 | $query .= ' ON DUPLICATE KEY UPDATE'; |
@@ -682,14 +682,14 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @return mysqli_result|bool |
684 | 684 | */ |
685 | - public static function select (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): mysqli_result|bool { |
|
685 | + public static function select(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): mysqli_result | bool { |
|
686 | 686 | $query = 'SELECT'; |
687 | 687 | self::selectBuilder($query, $columns); |
688 | 688 | $query .= "FROM `$table`"; |
689 | - $var = self::whereBuilder($query,$where, $ignore_default_where); |
|
689 | + $var = self::whereBuilder($query, $where, $ignore_default_where); |
|
690 | 690 | self::groupByBuilder($query, $group_by); |
691 | 691 | self::orderByBuilder($query, $order_by); |
692 | - self::countBuilder($query,$count,$offset); |
|
692 | + self::countBuilder($query, $count, $offset); |
|
693 | 693 | return self::query($query, $var); |
694 | 694 | } |
695 | 695 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * |
708 | 708 | * @return null|bool|array |
709 | 709 | */ |
710 | - public static function selectArray (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|array|null { |
|
710 | + public static function selectArray(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | array | null { |
|
711 | 711 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
712 | 712 | if ($res) { |
713 | 713 | return $res->fetch_assoc(); |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | * |
730 | 730 | * @return null|object |
731 | 731 | */ |
732 | - public static function selectObject (string $table, array|string $columns = '*', array $where = [], array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false) { |
|
732 | + public static function selectObject(string $table, array | string $columns = '*', array $where = [], array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false) { |
|
733 | 733 | $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
734 | 734 | if ($res) { |
735 | 735 | return $res->fetch_object(); |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return bool|Generator |
756 | 756 | */ |
757 | - public static function selectEach (string $table, array|string $columns = '*', array $where = [], int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = [], bool $ignore_default_where = false): bool|Generator { |
|
757 | + public static function selectEach(string $table, array | string $columns = '*', array $where = [], int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = [], bool $ignore_default_where = false): bool | Generator { |
|
758 | 758 | $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by, ignore_default_where: $ignore_default_where); |
759 | 759 | if ($res) { |
760 | 760 | while ($row = $res->fetch_assoc()) yield $row; |
@@ -772,10 +772,10 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @return string if save is true , return file name otherwise return sql data |
774 | 774 | */ |
775 | - public static function backup (array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
775 | + public static function backup(array $wanted_tables = [], bool $table_data = true, bool $save = true, string $file_name = ''): string { |
|
776 | 776 | self::setCharset('utf8mb4'); |
777 | 777 | |
778 | - $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0); |
|
778 | + $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0); |
|
779 | 779 | if (!empty($wanted_tables)) { |
780 | 780 | $tables = array_intersect($tables, $wanted_tables); |
781 | 781 | } |
@@ -786,12 +786,12 @@ discard block |
||
786 | 786 | logger::write('No table founded for backup, if your database has table : check $wanted_tables argument', loggerTypes::WARNING); |
787 | 787 | } |
788 | 788 | foreach ($tables as $table) { |
789 | - $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n"; |
|
789 | + $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n"; |
|
790 | 790 | if ($table_data) { |
791 | 791 | $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt; |
792 | 792 | for ($i = 0; $i < $total_rows; $i = $i + 1000) { |
793 | - $sql .= 'INSERT INTO ' . $table . ' VALUES'; |
|
794 | - $result = self::select($table, '*' , [], 1000, $i); |
|
793 | + $sql .= 'INSERT INTO '.$table.' VALUES'; |
|
794 | + $result = self::select($table, '*', [], 1000, $i); |
|
795 | 795 | $field_count = $result->field_count; |
796 | 796 | $affected_rows = self::affected_rows(); |
797 | 797 | $counter = 1; |
@@ -799,12 +799,12 @@ discard block |
||
799 | 799 | $sql .= "\n("; |
800 | 800 | for ($column = 0; $column < $field_count; $column++) { |
801 | 801 | $row[$column] = str_replace("\n", "\\n", addslashes($row[$column])); |
802 | - $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""'; |
|
802 | + $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""'; |
|
803 | 803 | if ($column < $field_count - 1) { |
804 | 804 | $sql .= ','; |
805 | 805 | } |
806 | 806 | } |
807 | - $sql .= ')' . ($counter == $affected_rows ? ';' : ','); |
|
807 | + $sql .= ')'.($counter == $affected_rows ? ';' : ','); |
|
808 | 808 | $counter++; |
809 | 809 | } |
810 | 810 | } |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | } |
821 | 821 | |
822 | 822 | if (empty($file_name)) { |
823 | - $file_name = self::$db_name . time() . '.sql'; |
|
823 | + $file_name = self::$db_name.time().'.sql'; |
|
824 | 824 | } |
825 | 825 | file_put_contents($file_name, $sql); |
826 | 826 | return $file_name; |