Passed
Push — main ( 1e0eff...d761d2 )
by Miaad
01:42
created
src/api/request/curl.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
             $curl_handler = curl_init(settings::$base_url."/bot$token/");
36 36
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
37 37
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
38
-        }
39
-        else{
38
+        } else{
40 39
             $token = settings::$token;
41 40
             if (!isset(self::$curl_handler)){
42 41
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
@@ -58,11 +57,9 @@  discard block
 block discarded – undo
58 57
         if (isset($data['forgot'])) {
59 58
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
60 59
             unset($data['forgot']);
61
-        }
62
-        elseif ($method === 'getUpdates'){
60
+        } elseif ($method === 'getUpdates'){
63 61
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
64
-        }
65
-        else{
62
+        } else{
66 63
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 300);
67 64
         }
68 65
     }
Please login to merge, or discard this patch.
src/receiver/webhook.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,15 +16,13 @@  discard block
 block discarded – undo
16 16
     public static function init () {
17 17
         if (settings::$multi) {
18 18
             multi::init();
19
-        }
20
-        else {
19
+        } else {
21 20
             if (lock::exist('BPT-HOOK')) {
22 21
                 receiver::telegramVerify();
23 22
                 self::checkSecret();
24 23
                 logger::write('Update received , lets process it ;)');
25 24
                 receiver::processUpdate();
26
-            }
27
-            else {
25
+            } else {
28 26
                 self::processSetWebhook();
29 27
             }
30 28
         }
@@ -46,8 +44,7 @@  discard block
 block discarded – undo
46 44
         $res = telegram::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
47 45
         if (telegram::$status) {
48 46
             logger::write('Webhook was set successfully',loggerTypes::INFO);
49
-        }
50
-        else {
47
+        } else {
51 48
             logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
52 49
             BPT::exit(print_r($res,true));
53 50
         }
@@ -69,8 +66,7 @@  discard block
 block discarded – undo
69 66
             if (is_string(settings::$certificate)) {
70 67
                 if (file_exists(settings::$certificate)) {
71 68
                     settings::$certificate = new CURLFile(settings::$certificate);
72
-                }
73
-                else {
69
+                } else {
74 70
                     settings::$certificate = null;
75 71
                 }
76 72
             }
Please login to merge, or discard this patch.
src/receiver/multi/curl.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,7 @@
 block discarded – undo
17 17
     public static function init (): string|null {
18 18
         if (self::checkIP()) {
19 19
             return self::getUpdate();
20
-        }
21
-        else {
20
+        } else {
22 21
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
23 22
             BPT::exit();
24 23
             return null;
Please login to merge, or discard this patch.
src/receiver/multi/exec.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@
 block discarded – undo
30 30
             $update = file_get_contents($up);
31 31
             unlink($up);
32 32
             return $update;
33
-        }
34
-        else {
33
+        } else {
35 34
             logger::write('not authorized access denied. IP : '. $_SERVER['REMOTE_ADDR'] ?? 'unknown',loggerTypes::WARNING);
36 35
             BPT::exit();
37 36
             return null;
Please login to merge, or discard this patch.
src/receiver/receiver.php 1 patch
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
                 if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && tools::isCloudFlare($ip)) {
36 36
                     $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
37 37
                 }
38
-            }
39
-            elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) {
38
+            } elseif (settings::$arvancloud_verify && isset($_SERVER['HTTP_AR_REAL_IP']) && tools::isArvanCloud($ip)) {
40 39
                 $ip = $_SERVER['HTTP_AR_REAL_IP'];
41 40
             }
42 41
 
@@ -94,51 +93,41 @@  discard block
 block discarded – undo
94 93
                 if (self::handlerExist('message')) {
95 94
                     BPT::$handler->message(BPT::$update->message);
96 95
                 }
97
-            }
98
-            elseif (isset(BPT::$update->edited_message)) {
96
+            } elseif (isset(BPT::$update->edited_message)) {
99 97
                 if (self::handlerExist('edited_message')) {
100 98
                     BPT::$handler->edited_message(BPT::$update->edited_message);
101 99
                 }
102
-            }
103
-            elseif (isset(BPT::$update->channel_post)) {
100
+            } elseif (isset(BPT::$update->channel_post)) {
104 101
                 if (self::handlerExist('channel_post')) {
105 102
                     BPT::$handler->channel_post(BPT::$update->channel_post);
106 103
                 }
107
-            }
108
-            elseif (isset(BPT::$update->edited_channel_post)) {
104
+            } elseif (isset(BPT::$update->edited_channel_post)) {
109 105
                 if (self::handlerExist('edited_channel_post')) {
110 106
                     BPT::$handler->edited_channel_post(BPT::$update->edited_channel_post);
111 107
                 }
112
-            }
113
-            elseif (isset(BPT::$update->inline_query)) {
108
+            } elseif (isset(BPT::$update->inline_query)) {
114 109
                 if (self::handlerExist('inline_query')) {
115 110
                     BPT::$handler->inline_query(BPT::$update->inline_query);
116 111
                 }
117
-            }
118
-            elseif (isset(BPT::$update->callback_query)) {
112
+            } elseif (isset(BPT::$update->callback_query)) {
119 113
                 if (self::handlerExist('callback_query')) {
120 114
                     BPT::$handler->callback_query(BPT::$update->callback_query);
121 115
                 }
122
-            }
123
-            elseif (isset(BPT::$update->my_chat_member)) {
116
+            } elseif (isset(BPT::$update->my_chat_member)) {
124 117
                 if (self::handlerExist('my_chat_member')) {
125 118
                     BPT::$handler->my_chat_member(BPT::$update->my_chat_member);
126 119
                 }
127
-            }
128
-            elseif (isset(BPT::$update->chat_member)) {
120
+            } elseif (isset(BPT::$update->chat_member)) {
129 121
                 if (self::handlerExist('chat_member')) {
130 122
                     BPT::$handler->chat_member(BPT::$update->chat_member);
131 123
                 }
132
-            }
133
-            elseif (isset(BPT::$update->chat_join_request)) {
124
+            } elseif (isset(BPT::$update->chat_join_request)) {
134 125
                 if (self::handlerExist('chat_join_request')) {
135 126
                     BPT::$handler->chat_join_request(BPT::$update->chat_join_request);
136 127
                 }
137
-            }
138
-            elseif (self::handlerExist('something_else')) {
128
+            } elseif (self::handlerExist('something_else')) {
139 129
                 BPT::$handler->something_else(BPT::$update);
140
-            }
141
-            else {
130
+            } else {
142 131
                 logger::write('Update received but handlers does not set',loggerTypes::WARNING);
143 132
             }
144 133
         }
Please login to merge, or discard this patch.
src/settings.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,11 +78,9 @@  discard block
 block discarded – undo
78 78
                     $value = 'bots_files/'.$value.'/';
79 79
                 }
80 80
                 self::$$setting = $value;
81
-            }
82
-            catch (TypeError){
81
+            } catch (TypeError){
83 82
                 logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
84
-            }
85
-            catch (Error){
83
+            } catch (Error){
86 84
                 logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
87 85
             }
88 86
         }
@@ -99,13 +97,11 @@  discard block
 block discarded – undo
99 97
                 if (!empty(self::$receiver)) {
100 98
                     self::$receiver !== receiver::GETUPDATES ? webhook::init() : self::getUpdates();
101 99
                 }
102
-            }
103
-            else {
100
+            } else {
104 101
                 logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
105 102
                 throw new bptException('TOKEN_NOT_TRUE');
106 103
             }
107
-        }
108
-        else {
104
+        } else {
109 105
             logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
110 106
             throw new bptException('TOKEN_NOT_FOUND');
111 107
         }
@@ -159,8 +155,7 @@  discard block
 block discarded – undo
159 155
     private static function getUpdates(): void {
160 156
         if (self::$handler) {
161 157
             getUpdates::init();
162
-        }
163
-        else {
158
+        } else {
164 159
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
165 160
             throw new bptException('GETUPDATE_NEED_HANDLER');
166 161
         }
Please login to merge, or discard this patch.
src/database/json.php 1 patch
Braces   +43 added lines, -56 removed lines patch added patch discarded remove patch
@@ -195,17 +195,13 @@  discard block
 block discarded – undo
195 195
     public static function process (): void {
196 196
         if (isset(BPT::$update->message)) {
197 197
             self::processMessage(BPT::$update->message);
198
-        }
199
-        elseif (isset(BPT::$update->edited_message)) {
198
+        } elseif (isset(BPT::$update->edited_message)) {
200 199
             self::processMessage(BPT::$update->edited_message);
201
-        }
202
-        elseif (isset(BPT::$update->callback_query)) {
200
+        } elseif (isset(BPT::$update->callback_query)) {
203 201
             self::processCallbackQuery(BPT::$update->callback_query);
204
-        }
205
-        elseif (isset(BPT::$update->inline_query)) {
202
+        } elseif (isset(BPT::$update->inline_query)) {
206 203
             self::processInlineQuery(BPT::$update->inline_query);
207
-        }
208
-        elseif (isset(BPT::$update->chat_member)) {
204
+        } elseif (isset(BPT::$update->chat_member)) {
209 205
             self::processChatMember(BPT::$update->chat_member);
210 206
         }
211 207
     }
@@ -230,8 +226,7 @@  discard block
 block discarded – undo
230 226
             if (empty(self::$group)) {
231 227
                 $category = 'supergroups';
232 228
                 $group_id = self::$supergroup_id;
233
-            }
234
-            else {
229
+            } else {
235 230
                 $category = 'groups';
236 231
                 $group_id = self::$group_id;
237 232
             }
@@ -247,8 +242,7 @@  discard block
 block discarded – undo
247 242
             if (empty(self::$group)) {
248 243
                 $category = 'supergroups';
249 244
                 $group_id = self::$supergroup_id;
250
-            }
251
-            else {
245
+            } else {
252 246
                 $category = 'groups';
253 247
                 $group_id = self::$group_id;
254 248
             }
@@ -265,8 +259,7 @@  discard block
 block discarded – undo
265 259
                 self::$user = self::read($category . '/' . self::$user_id);
266 260
                 self::$old_user = clone self::$user;
267 261
                 self::$user->last_active = time();
268
-            }
269
-            else {
262
+            } else {
270 263
                 self::$ids[$category][] = self::$user_id;
271 264
                 self::$user = (object) self::$user_default_data;
272 265
                 self::$user->first_active = self::$user->last_active = time();
@@ -279,19 +272,16 @@  discard block
 block discarded – undo
279 272
                     }
280 273
                 }
281 274
             }
282
-        }
283
-        elseif ($type === chatType::CHANNEL) {
275
+        } elseif ($type === chatType::CHANNEL) {
284 276
             self::$channel_id = $update->chat->id;
285 277
             if (in_array(self::$channel_id,self::$ids[$category])) {
286 278
                 self::$channel = self::read($category . '/' . self::$channel_id);
287 279
                 self::$old_channel = clone self::$channel;
288
-            }
289
-            else {
280
+            } else {
290 281
                 self::$ids[$category][] = self::$channel_id;
291 282
                 self::$channel = (object) self::$channel_default_data;
292 283
             }
293
-        }
294
-        else {
284
+        } else {
295 285
             self::$user_id = $update->from->id;
296 286
             self::$group_user_id = self::$user_id;
297 287
             $chat_id = $update->chat->id;
@@ -302,22 +292,19 @@  discard block
 block discarded – undo
302 292
                     self::$old_supergroup = clone self::$supergroup;
303 293
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
304 294
                     self::$old_group_ids = clone self::$group_ids;
305
-                }
306
-                else {
295
+                } else {
307 296
                     self::$ids[$category][] = $chat_id;
308 297
                     self::$supergroup = (object) self::$supergroup_default_data;
309 298
                     self::$group_ids = [];
310 299
                 }
311
-            }
312
-            else {
300
+            } else {
313 301
                 self::$group_id = $update->chat->id;
314 302
                 if (in_array($chat_id,self::$ids[$category])) {
315 303
                     self::$group = self::read($category . '/' . $chat_id);
316 304
                     self::$old_group = clone self::$group;
317 305
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
318 306
                     self::$old_group_ids = clone self::$group_ids;
319
-                }
320
-                else {
307
+                } else {
321 308
                     self::$ids[$category][] = $chat_id;
322 309
                     self::$group = (object) self::$group_default_data;
323 310
                     self::$group_ids = [];
@@ -327,15 +314,16 @@  discard block
 block discarded – undo
327 314
             if (in_array(self::$user_id,self::$group_ids)) {
328 315
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$user_id);
329 316
                 self::$old_group_user = clone self::$group_user;
330
-            }
331
-            else {
317
+            } else {
332 318
                 self::$group_ids[] = self::$user_id;
333 319
                 self::$group_user = (object) self::$group_user_default_data;
334 320
             }
335 321
 
336 322
             self::$user = self::read($category.'/'.self::$user_id);
337 323
             self::$old_user = clone self::$user;
338
-            if (!empty(self::$user)) self::$user->last_active = time();
324
+            if (!empty(self::$user)) {
325
+                self::$user->last_active = time();
326
+            }
339 327
         }
340 328
     }
341 329
 
@@ -349,15 +337,13 @@  discard block
 block discarded – undo
349 337
                 self::$old_user = clone self::$user;
350 338
                 self::$user->last_active = time();
351 339
             }
352
-        }
353
-        elseif ($type === chatType::CHANNEL) {
340
+        } elseif ($type === chatType::CHANNEL) {
354 341
             self::$channel_id = $update->message->chat->id;
355 342
             if (in_array(self::$channel_id,self::$ids[$category])) {
356 343
                 self::$channel = self::read($category . '/' . self::$channel_id);
357 344
                 self::$old_channel = clone self::$channel;
358 345
             }
359
-        }
360
-        else {
346
+        } else {
361 347
             self::$user_id = $update->from->id;
362 348
             $chat_id = $update->message->chat->id;
363 349
             if (in_array($chat_id,self::$ids[$category])) {
@@ -365,8 +351,7 @@  discard block
 block discarded – undo
365 351
                     self::$supergroup_id = $update->message->chat->id;
366 352
                     self::$supergroup = self::read($category . '/' . $chat_id);
367 353
                     self::$old_supergroup = clone self::$supergroup;
368
-                }
369
-                else {
354
+                } else {
370 355
                     self::$group_id = $update->message->chat->id;
371 356
                     self::$group = self::read($category . '/' . $chat_id);
372 357
                     self::$old_group = clone self::$group;
@@ -383,7 +368,9 @@  discard block
 block discarded – undo
383 368
 
384 369
             self::$user = self::read($category.'/'.self::$user_id);
385 370
             self::$old_user = clone self::$user;
386
-            if (!empty(self::$user)) self::$user->last_active = time();
371
+            if (!empty(self::$user)) {
372
+                self::$user->last_active = time();
373
+            }
387 374
         }
388 375
     }
389 376
 
@@ -409,13 +396,11 @@  discard block
 block discarded – undo
409 396
             if (in_array(self::$channel_id,self::$ids[$category])) {
410 397
                 self::$channel = self::read($category . '/' . self::$channel_id);
411 398
                 self::$old_channel = clone self::$channel;
412
-            }
413
-            else {
399
+            } else {
414 400
                 self::$ids[$category][] = self::$channel_id;
415 401
                 self::$channel = (object) self::$channel_default_data;
416 402
             }
417
-        }
418
-        else {
403
+        } else {
419 404
             $chat_id = $update->chat->id;
420 405
             $by_id = $update->from->id;
421 406
             $old_user = $update->old_chat_member;
@@ -431,22 +416,19 @@  discard block
 block discarded – undo
431 416
                     self::$old_supergroup = clone self::$supergroup;
432 417
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
433 418
                     self::$old_group_ids = clone self::$group_ids;
434
-                }
435
-                else {
419
+                } else {
436 420
                     self::$ids[$category][] = $chat_id;
437 421
                     self::$supergroup = (object) self::$supergroup_default_data;
438 422
                     self::$group_ids = [];
439 423
                 }
440
-            }
441
-            elseif ($type === chatType::GROUP) {
424
+            } elseif ($type === chatType::GROUP) {
442 425
                 self::$group_id = $chat_id;
443 426
                 if (in_array($chat_id,self::$ids[$category])) {
444 427
                     self::$group = self::read($category . '/' . $chat_id);
445 428
                     self::$old_group = clone self::$group;
446 429
                     self::$group_ids = self::read($category . '/' . $chat_id . '/users');
447 430
                     self::$old_group_ids = clone self::$group_ids;
448
-                }
449
-                else {
431
+                } else {
450 432
                     self::$ids[$category][] = $chat_id;
451 433
                     self::$group = (object) self::$group_default_data;
452 434
                     self::$group_ids = [];
@@ -456,8 +438,7 @@  discard block
 block discarded – undo
456 438
             if (!in_array($user_id,self::$group_ids)) {
457 439
                 self::$group_ids[] = $user_id;
458 440
                 self::$group_user = (object) self::$group_user_default_data;
459
-            }
460
-            else {
441
+            } else {
461 442
                 self::$group_user_id = $by_id == $user_id ? $user_id : $by_id;
462 443
                 self::$group_user = self::read($category . '/' . $chat_id . '/' . self::$group_user_id);
463 444
             }
@@ -470,8 +451,7 @@  discard block
 block discarded – undo
470 451
                         self::$group_user->removed_by = $by_id;
471 452
                     }
472 453
                 }
473
-            }
474
-            else {
454
+            } else {
475 455
                 if ($old_user->status === chatMemberStatus::LEFT || $old_user->status === chatMemberStatus::KICKED) {
476 456
                     self::$group_user->presence = true;
477 457
                     self::$group_user->removed = false;
@@ -481,8 +461,7 @@  discard block
 block discarded – undo
481 461
                         if (!empty($invite_link)) {
482 462
                             self::$group_user->accepted_by = $by_id;
483 463
                             self::$group_user->invited_by = null;
484
-                        }
485
-                        else {
464
+                        } else {
486 465
                             self::$group_user->invited_by = $by_id;
487 466
                             self::$group_user->accepted_by = null;
488 467
                         }
@@ -501,7 +480,9 @@  discard block
 block discarded – undo
501 480
      * @throws bptException
502 481
      */
503 482
     public static function deleteUser (int $user_id = null): bool {
504
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
483
+        if (empty($user_id)) {
484
+            $user_id = telegram::catchFields(fields::USER_ID);
485
+        }
505 486
         if (file_exists(self::$folder . '/privates/' . $user_id . '.json')) {
506 487
             unset(self::$ids['privates'][array_search($user_id, self::$ids['privates'])]);
507 488
             sort(self::$ids['privates']);
@@ -522,7 +503,9 @@  discard block
 block discarded – undo
522 503
      * @throws bptException
523 504
      */
524 505
     public static function deleteGroup (int $group_id = null): bool {
525
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
506
+        if (empty($group_id)) {
507
+            $group_id = telegram::catchFields(fields::CHAT_ID);
508
+        }
526 509
         if (file_exists(self::$folder . '/groups/' . $group_id . '.json')) {
527 510
             unset(self::$ids['groups'][array_search($group_id, self::$ids['groups'])]);
528 511
             sort(self::$ids['groups']);
@@ -544,7 +527,9 @@  discard block
 block discarded – undo
544 527
      * @throws bptException
545 528
      */
546 529
     public static function deleteSuperGroup (int $group_id = null): bool {
547
-        if (empty($group_id)) $group_id = telegram::catchFields(fields::CHAT_ID);
530
+        if (empty($group_id)) {
531
+            $group_id = telegram::catchFields(fields::CHAT_ID);
532
+        }
548 533
         if (file_exists(self::$folder . '/supergroups/' . $group_id . '.json')) {
549 534
             unset(self::$ids['supergroups'][array_search($group_id, self::$ids['supergroups'])]);
550 535
             sort(self::$ids['supergroups']);
@@ -566,7 +551,9 @@  discard block
 block discarded – undo
566 551
      * @throws bptException
567 552
      */
568 553
     public static function deleteChannel (int $channel_id = null): bool {
569
-        if (empty($channel_id)) $channel_id = telegram::catchFields(fields::CHAT_ID);
554
+        if (empty($channel_id)) {
555
+            $channel_id = telegram::catchFields(fields::CHAT_ID);
556
+        }
570 557
         if (file_exists(self::$folder . '/channels/' . $channel_id . '.json')) {
571 558
             unset(self::$ids['channels'][array_search($channel_id, self::$ids['channels'])]);
572 559
             sort(self::$ids['channels']);
Please login to merge, or discard this patch.
src/api/request.php 1 patch
Braces   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -704,12 +704,10 @@  discard block
 block discarded – undo
704 704
             self::setDefaults($action,$arguments);
705 705
             if (isset($arguments['answer'])) {
706 706
                 return answer::init($action,$arguments);
707
-            }
708
-            else {
707
+            } else {
709 708
                 return self::processResponse($action,curl::init($action,$arguments));
710 709
             }
711
-        }
712
-        else {
710
+        } else {
713 711
             logger::write("$name method is not supported",loggerTypes::ERROR);
714 712
             throw new bptException('METHOD_NOT_FOUND');
715 713
         }
@@ -735,8 +733,7 @@  discard block
 block discarded – undo
735 733
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
736 734
                 }
737 735
             }
738
-        }
739
-        elseif ($file_params = self::methodFile($name)) {
736
+        } elseif ($file_params = self::methodFile($name)) {
740 737
             foreach ($file_params as $param) {
741 738
                 if (isset($arguments[$param]) && file_exists($arguments[$param])) {
742 739
                     $arguments[$param] = new CURLFile($arguments[$param]);
@@ -758,12 +755,10 @@  discard block
 block discarded – undo
758 755
                     $value = new ($return[0]) ($value);
759 756
                 }
760 757
                 return $response;
761
-            }
762
-            else {
758
+            } else {
763 759
                 return new ($return) ($response->result);
764 760
             }
765
-        }
766
-        else {
761
+        } else {
767 762
             return $response->result;
768 763
         }
769 764
     }
@@ -775,8 +770,7 @@  discard block
 block discarded – undo
775 770
                 if (!isset($arguments[$default])){
776 771
                     $arguments[$default] = self::catchFields($default);
777 772
                 }
778
-            }
779
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
773
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
780 774
                 foreach ($default as $def) {
781 775
                     if (!isset($arguments[$def])){
782 776
                         $arguments[$def] = self::catchFields($def);
@@ -792,8 +786,7 @@  discard block
 block discarded – undo
792 786
             self::$status = true;
793 787
             self::$pure_response = $response;
794 788
             return self::methodReturn($name,$response);
795
-        }
796
-        else {
789
+        } else {
797 790
             self::$status = false;
798 791
             self::$pure_response = $response;
799 792
             return new responseError($response);
@@ -836,9 +829,13 @@  discard block
 block discarded – undo
836 829
                     default => false
837 830
                 };
838 831
             case fields::FILE_ID :
839
-                if (isset(BPT::$update->message)) $type = 'message';
840
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
841
-                else return false;
832
+                if (isset(BPT::$update->message)) {
833
+                    $type = 'message';
834
+                } elseif (isset(BPT::$update->edited_message)) {
835
+                    $type = 'edited_message';
836
+                } else {
837
+                    return false;
838
+                }
842 839
 
843 840
                 return match(true) {
844 841
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.
src/tools/generator.php 1 patch
Braces   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
             }
73 73
             $rows = [];
74 74
             foreach ($keyboard as $row) {
75
-                if (!is_array($row)) continue;
75
+                if (!is_array($row)) {
76
+                    continue;
77
+                }
76 78
                 $buttons = [];
77 79
                 foreach ($row as $base_button) {
78 80
                     $button_info = explode('||', $base_button);
@@ -81,15 +83,12 @@  discard block
 block discarded – undo
81 83
                     if (count($button_info) > 1) {
82 84
                         if ($button_info[1] === 'con') {
83 85
                             $button->setRequest_contact(true);
84
-                        }
85
-                        elseif ($button_info[1] === 'loc') {
86
+                        } elseif ($button_info[1] === 'loc') {
86 87
                             $button->setRequest_location(true);
87
-                        }
88
-                        elseif ($button_info[1] === 'poll') {
88
+                        } elseif ($button_info[1] === 'poll') {
89 89
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
90 90
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
91
-                        }
92
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
91
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
93 92
                             $url = $button_info[2];
94 93
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
95 94
                         }
@@ -100,8 +99,7 @@  discard block
 block discarded – undo
100 99
             }
101 100
             $keyboard_object->setKeyboard($rows);
102 101
             return $keyboard_object;
103
-        }
104
-        elseif (!empty($inline)) {
102
+        } elseif (!empty($inline)) {
105 103
             $keyboard_object = new inlineKeyboardMarkup();
106 104
             $rows = [];
107 105
             foreach ($inline as $row) {
@@ -111,12 +109,10 @@  discard block
 block discarded – undo
111 109
                     if (isset($button_info[1])) {
112 110
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
113 111
                             $button->setText($button_info[0])->setUrl($button_info[1]);
114
-                        }
115
-                        else {
112
+                        } else {
116 113
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
117 114
                         }
118
-                    }
119
-                    else {
115
+                    } else {
120 116
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
121 117
                     }
122 118
                     $buttons[] = $button;
@@ -125,8 +121,7 @@  discard block
 block discarded – undo
125 121
             }
126 122
             $keyboard_object->setInline_keyboard($rows);
127 123
             return $keyboard_object;
128
-        }
129
-        else {
124
+        } else {
130 125
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
131 126
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
132 127
         }
@@ -145,8 +140,12 @@  discard block
 block discarded – undo
145 140
      * @return string
146 141
      */
147 142
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
148
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
149
-        if (empty($bot_username)) $bot_username = telegram::getMe()->username;
143
+        if (empty($user_id)) {
144
+            $user_id = telegram::catchFields(fields::USER_ID);
145
+        }
146
+        if (empty($bot_username)) {
147
+            $bot_username = telegram::getMe()->username;
148
+        }
150 149
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
151 150
     }
152 151
 }
153 152
\ No newline at end of file
Please login to merge, or discard this patch.