Passed
Push — main ( 4cb247...21f878 )
by Miaad
10:47
created
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/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.
src/tools/file.php 1 patch
Braces   +16 added lines, -13 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
             curl_exec($ch);
36 36
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
37 37
             curl_close($ch);
38
-        }
39
-        else {
38
+        } else {
40 39
             $size = file_exists($path) ? filesize($path) : false;
41 40
         }
42 41
         if (isset($size) && is_numeric($size)) {
43 42
             return $format ? tools::byteFormat($size) : $size;
43
+        } else {
44
+            return false;
44 45
         }
45
-        else return false;
46 46
     }
47 47
 
48 48
     /**
@@ -68,15 +68,16 @@  discard block
 block discarded – undo
68 68
                         $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
69 69
                     }
70 70
                     return rmdir($path);
71
-                }
72
-                else {
71
+                } else {
73 72
                     logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
74 73
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
75 74
                 }
75
+            } else {
76
+                return rmdir($path);
76 77
             }
77
-            else return rmdir($path);
78
+        } else {
79
+            return unlink($path);
78 80
         }
79
-        else return unlink($path);
80 81
     }
81 82
 
82 83
     /**
@@ -104,13 +105,11 @@  discard block
 block discarded – undo
104 105
                         $zip->addFile($filePath, substr($filePath, $root_len));
105 106
                     }
106 107
                 }
107
-            }
108
-            else {
108
+            } else {
109 109
                 $zip->addFile($path, basename($path));
110 110
             }
111 111
             return $zip->close();
112
-        }
113
-        else {
112
+        } else {
114 113
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
115 114
             throw new bptException('ZIP_EXTENSION_MISSING');
116 115
         }
@@ -129,9 +128,13 @@  discard block
 block discarded – undo
129 128
      */
130 129
     public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool {
131 130
         $file = fopen($url, 'rb');
132
-        if (!$file) return false;
131
+        if (!$file) {
132
+            return false;
133
+        }
133 134
         $path = fopen($path, 'wb');
134
-        if (!$path) return false;
135
+        if (!$path) {
136
+            return false;
137
+        }
135 138
 
136 139
         $length = $chunk_size * 1024;
137 140
         while (!feof($file)){
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
@@ -709,16 +709,14 @@  discard block
 block discarded – undo
709 709
             self::setDefaults($action,$arguments);
710 710
             if (isset($arguments['answer'])) {
711 711
                 return answer::init($action,$arguments);
712
-            }
713
-            else {
712
+            } else {
714 713
                 $result = curl::init($action,$arguments);
715 714
                 if (is_object($result)) {
716 715
                     return self::processResponse($action,$result);
717 716
                 }
718 717
                 return false;
719 718
             }
720
-        }
721
-        else {
719
+        } else {
722 720
             logger::write("$name method is not supported",loggerTypes::ERROR);
723 721
             throw new bptException('METHOD_NOT_FOUND');
724 722
         }
@@ -744,8 +742,7 @@  discard block
 block discarded – undo
744 742
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
745 743
                 }
746 744
             }
747
-        }
748
-        elseif ($file_params = self::methodFile($name)) {
745
+        } elseif ($file_params = self::methodFile($name)) {
749 746
             foreach ($file_params as $param) {
750 747
                 if (isset($arguments[$param]) && file_exists($arguments[$param])) {
751 748
                     $arguments[$param] = new CURLFile($arguments[$param]);
@@ -767,12 +764,10 @@  discard block
 block discarded – undo
767 764
                     $value = new ($return[0]) ($value);
768 765
                 }
769 766
                 return $response;
770
-            }
771
-            else {
767
+            } else {
772 768
                 return new ($return) ($response->result);
773 769
             }
774
-        }
775
-        else {
770
+        } else {
776 771
             return $response->result;
777 772
         }
778 773
     }
@@ -784,8 +779,7 @@  discard block
 block discarded – undo
784 779
                 if (!isset($arguments[$default])){
785 780
                     $arguments[$default] = self::catchFields($default);
786 781
                 }
787
-            }
788
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
782
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
789 783
                 foreach ($default as $def) {
790 784
                     if (!isset($arguments[$def])){
791 785
                         $arguments[$def] = self::catchFields($def);
@@ -801,8 +795,7 @@  discard block
 block discarded – undo
801 795
             self::$status = true;
802 796
             self::$pure_response = $response;
803 797
             return self::methodReturn($name,$response);
804
-        }
805
-        else {
798
+        } else {
806 799
             self::$status = false;
807 800
             self::$pure_response = $response;
808 801
             return new responseError($response);
@@ -845,9 +838,13 @@  discard block
 block discarded – undo
845 838
                     default => false
846 839
                 };
847 840
             case fields::FILE_ID :
848
-                if (isset(BPT::$update->message)) $type = 'message';
849
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
850
-                else return false;
841
+                if (isset(BPT::$update->message)) {
842
+                    $type = 'message';
843
+                } elseif (isset(BPT::$update->edited_message)) {
844
+                    $type = 'edited_message';
845
+                } else {
846
+                    return false;
847
+                }
851 848
 
852 849
                 return match(true) {
853 850
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.
src/api/request/curl.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
             $curl_handler = curl_init(settings::$base_url."/bot$token/");
42 42
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
43 43
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
44
-        }
45
-        else{
44
+        } else{
46 45
             $token = settings::$token;
47 46
             if (!isset(self::$curl_handler)){
48 47
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
@@ -64,11 +63,9 @@  discard block
 block discarded – undo
64 63
         if (isset($data['forgot'])) {
65 64
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
66 65
             unset($data['forgot']);
67
-        }
68
-        elseif ($method === 'getUpdates' || $method === 'setWebhook'){
66
+        } elseif ($method === 'getUpdates' || $method === 'setWebhook'){
69 67
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
70
-        }
71
-        else{
68
+        } else{
72 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
73 70
         }
74 71
     }
Please login to merge, or discard this patch.
src/api/telegram.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@
 block discarded – undo
31 31
         if (isset($file->file_path)) {
32 32
             $file_path = settings::$down_url . 'bot' . settings::$token . '/' . $file->file_path;
33 33
             return tools::downloadFile($file_path, $destination);
34
-        }
35
-        else {
34
+        } else {
36 35
             return false;
37 36
         }
38 37
     }
Please login to merge, or discard this patch.