Passed
Push — main ( fe7ef9...03f6f3 )
by Miaad
10:51
created
src/BPT.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -296,13 +296,13 @@  discard block
 block discarded – undo
296 296
  * @method gameHighScore[]|responseError getGameHighScores (int|array|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
297 297
  * @method gameHighScore[]|responseError getGameHigh (int|array|null $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects.
298 298
  */
299
-class BPT extends telegram{
299
+class BPT extends telegram {
300 300
     public static update $update;
301 301
 
302 302
     public static BPT $handler;
303 303
 
304 304
 
305
-    public function __construct (array|stdClass $settings) {
305
+    public function __construct(array | stdClass $settings) {
306 306
         static::$handler = &$this;
307 307
         settings::init($settings);
308 308
     }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
     }
313 313
 
314 314
     #[NoReturn]
315
-    public static function exit (string|null $message = null): void {
315
+    public static function exit (string | null $message = null): void {
316 316
         die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>");
317 317
     }
318 318
 }
Please login to merge, or discard this patch.
src/external/jdf.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @Version: 2.76 =>[ 1399/11/28 = 1442/07/04 = 2021/02/16 ]
11 11
  */
12 12
 class jdf {
13
-    public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
13
+    public static function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
14 14
         $T_sec = 0;
15 15
         if ($time_zone != 'local') {
16 16
             date_default_timezone_set(empty($time_zone) ? 'Asia/Tehran' : $time_zone);
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
                     $output .= (int) ($jalali_month / 3.1) + 1;
57 57
                     break;
58 58
                 case 'c':
59
-                    $output .= $jalali_year . '/' . $jalali_month . '/' . $jalali_day . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5];
59
+                    $output .= $jalali_year.'/'.$jalali_month.'/'.$jalali_day.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5];
60 60
                     break;
61 61
                 case 'C':
62 62
                     $output .= (int) (($jalali_year + 99) / 100);
63 63
                     break;
64 64
                 case 'd':
65
-                    $output .= $jalali_day < 10 ? '0' . $jalali_day : $jalali_day;
65
+                    $output .= $jalali_day < 10 ? '0'.$jalali_day : $jalali_day;
66 66
                     break;
67 67
                 case 'D':
68 68
                     $output .= self::jdate_words(['kh' => $date[7]], ' ');
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                     $output .= $leap_year;
99 99
                     break;
100 100
                 case 'm':
101
-                    $output .= $jalali_month > 9 ? $jalali_month : '0' . $jalali_month;
101
+                    $output .= $jalali_month > 9 ? $jalali_month : '0'.$jalali_month;
102 102
                     break;
103 103
                 case 'M':
104 104
                     $output .= self::jdate_words(['km' => $jalali_month], ' ');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     break;
132 132
                 case 'r':
133 133
                     $key = self::jdate_words(['rh' => $date[7], 'mm' => $jalali_month]);
134
-                    $output .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year;
134
+                    $output .= $date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year;
135 135
                     break;
136 136
                 case 's':
137 137
                     $output .= $date[6];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                     if ($aks == 7) {
169 169
                         $aks = 0;
170 170
                     }
171
-                    $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0' . $num : $num);
171
+                    $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0'.$num : $num);
172 172
                     break;
173 173
                 case 'y':
174 174
                     $output .= substr($jalali_year, 2, 2);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
         }
186 186
         return $tr_num != 'en' ? self::tr_num($output, 'fa', '.') : $output;
187 187
     }
188
-    public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
189
-        $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
188
+    public static function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
189
+        $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
190 190
         if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone);
191 191
         $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp));
192 192
         $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp));
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                     $output .= self::jdate_words(['rh' => $date[6]], ' ');
214 214
                     break;
215 215
                 case 'd':
216
-                    $output .= ($jalali_day < 10) ? '0' . $jalali_day : $jalali_day;
216
+                    $output .= ($jalali_day < 10) ? '0'.$jalali_day : $jalali_day;
217 217
                     break;
218 218
                 case 'e':
219
-                    $output .= ($jalali_day < 10) ? ' ' . $jalali_day : $jalali_day;
219
+                    $output .= ($jalali_day < 10) ? ' '.$jalali_day : $jalali_day;
220 220
                     break;
221 221
                 case 'j':
222 222
                     $output .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                 if ($avs < 0) $avs += 7;
233 233
                 $num = (int) (($doy + $avs) / 7) + 1;
234 234
                 if ($avs > 3 or $avs == 1) $num--;
235
-                $output .= ($num < 10) ? '0' . $num : $num;
235
+                $output .= ($num < 10) ? '0'.$num : $num;
236 236
                 break;
237 237
                 case 'V':
238 238
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
                     }
247 247
                     $aks = $avs + $leap_year;
248 248
                     if ($aks == 7) $aks = 0;
249
-                    $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num);
249
+                    $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num);
250 250
                     break;
251 251
                 case 'W':
252 252
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
253 253
                     if ($avs < 0) $avs += 7;
254 254
                     $num = (int) (($doy + $avs) / 7) + 1;
255 255
                     if ($avs > 3) $num--;
256
-                    $output .= ($num < 10) ? '0' . $num : $num;
256
+                    $output .= ($num < 10) ? '0'.$num : $num;
257 257
                     break;
258 258
                 /* Month */ case 'b':
259 259
                 case 'h':
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
                     $output .= self::jdate_words(['mm' => $jalali_month], ' ');
264 264
                     break;
265 265
                 case 'm':
266
-                    $output .= ($jalali_month > 9) ? $jalali_month : '0' . $jalali_month;
266
+                    $output .= ($jalali_month > 9) ? $jalali_month : '0'.$jalali_month;
267 267
                     break;
268 268
                 /* Year */ case 'C':
269 269
                 $tmp = (int) ($jalali_year / 100);
270
-                $output .= ($tmp > 9) ? $tmp : '0' . $tmp;
270
+                $output .= ($tmp > 9) ? $tmp : '0'.$tmp;
271 271
                 break;
272 272
                 case 'g':
273 273
                     $jdw = ($date[6] == 6) ? 0 : $date[6] + 1;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                     $output .= $date[0];
293 293
                     break;
294 294
                 case 'l':
295
-                    $output .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0];
295
+                    $output .= ($date[0] > 9) ? $date[0] : ' '.(int) $date[0];
296 296
                     break;
297 297
                 case 'M':
298 298
                     $output .= $date[2];
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
                     $output .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ';
305 305
                     break;
306 306
                 case 'r':
307
-                    $output .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر');
307
+                    $output .= $date[0].':'.$date[2].':'.$date[5].' '.(($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر');
308 308
                     break;
309 309
                 case 'R':
310
-                    $output .= $date[1] . ':' . $date[2];
310
+                    $output .= $date[1].':'.$date[2];
311 311
                     break;
312 312
                 case 'S':
313 313
                     $output .= $date[5];
314 314
                     break;
315 315
                 case 'T':
316
-                    $output .= $date[1] . ':' . $date[2] . ':' . $date[5];
316
+                    $output .= $date[1].':'.$date[2].':'.$date[5];
317 317
                     break;
318 318
                 case 'X':
319
-                    $output .= $date[0] . ':' . $date[2] . ':' . $date[5];
319
+                    $output .= $date[0].':'.$date[2].':'.$date[5];
320 320
                     break;
321 321
                 case 'z':
322 322
                     $output .= date('O', $timestamp);
@@ -326,19 +326,19 @@  discard block
 block discarded – undo
326 326
                     break;
327 327
                 /* Time and Date Stamps */ case 'c':
328 328
                 $key = self::jdate_words(['rh' => $date[6], 'mm' => $jalali_month]);
329
-                $output .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $timestamp) . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year;
329
+                $output .= $date[1].':'.$date[2].':'.$date[5].' '.date('P', $timestamp).' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year;
330 330
                 break;
331 331
                 case 'D':
332
-                    $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
332
+                    $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
333 333
                     break;
334 334
                 case 'F':
335
-                    $output .= $jalali_year . '-' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '-' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
335
+                    $output .= $jalali_year.'-'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'-'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
336 336
                     break;
337 337
                 case 's':
338 338
                     $output .= $timestamp;
339 339
                     break;
340 340
                 case 'x':
341
-                    $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
341
+                    $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
342 342
                     break;
343 343
                 /* Miscellaneous */ case 'n':
344 344
                 $output .= "\n";
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         }
356 356
         return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output;
357 357
     }
358
-    public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int {
358
+    public static function jmktime($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool | int {
359 359
         if ($timezone != 'local') date_default_timezone_set($timezone);
360 360
         if ($hour === '') {
361 361
             return time();
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 $jalali_month,
369 369
                 $jalali_day,
370 370
                 $jalali_year
371
-            ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year));
371
+            ] = explode('_', self::tr_num($hour.'_'.$minute.'_'.$second.'_'.$jalali_month.'_'.$jalali_day.'_'.$jalali_year));
372 372
             if ($minute === '') {
373 373
                 return mktime($hour);
374 374
             }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             }
414 414
         }
415 415
     }
416
-    public static function jgetdate ($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') {
416
+    public static function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') {
417 417
         $timestamp = ($timestamp === '') ? time() : self::tr_num($timestamp);
418 418
         $jdate = explode('_', self::jdate('F_G_i_j_l_n_s_w_Y_z', $timestamp, '', $timezone, $tn));
419 419
         return [
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
             0         => self::tr_num($timestamp, $tn)
431 431
         ];
432 432
     }
433
-    public static function jcheckdate ($jalali_month, $jalali_day, $jalali_year): bool {
434
-        [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month . '_' . $jalali_day . '_' . $jalali_year));
433
+    public static function jcheckdate($jalali_month, $jalali_day, $jalali_year): bool {
434
+        [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month.'_'.$jalali_day.'_'.$jalali_year));
435 435
         $l_d = ($jalali_month == 12 and ($jalali_year + 12) % 33 % 4 != 1) ? 29 : 31 - (int) ($jalali_month / 6.5);
436 436
         return !(($jalali_month > 12 or $jalali_day > $l_d or $jalali_month < 1 or $jalali_day < 1 or $jalali_year < 1));
437 437
     }
438
-    public static function tr_num ($string, $mod = 'en', $mf = '٫'): array|string {
438
+    public static function tr_num($string, $mod = 'en', $mf = '٫'): array | string {
439 439
         $english_number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'];
440 440
         $persian_number = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf];
441 441
         return $mod == 'fa' ? str_replace($english_number, $persian_number, $string) : str_replace($persian_number, $english_number, $string);
442 442
     }
443
-    public static function jdate_words ($array, $splitter = '') {
443
+    public static function jdate_words($array, $splitter = '') {
444 444
         foreach ($array as $type => $num) {
445 445
             $num = (int) self::tr_num($num);
446 446
             switch ($type) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
                                 'هزار و چهارصد',
479 479
                                 'هزار و نهصد',
480 480
                                 'دوهزار'
481
-                            ], substr($num, 0, 2)) . (substr($num, 2, 2) == '00' ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4;
481
+                            ], substr($num, 0, 2)).(substr($num, 2, 2) == '00' ? '' : ' و ') : '').$h3.$p34.$h34.$h4;
482 482
                     break;
483 483
                 case 'mm':
484 484
                     $array[$type] = [
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
         }
595 595
         return $splitter === '' ? $array : implode($splitter, $array);
596 596
     }
597
-    public static function gregorian_to_jalali ($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array|string {
598
-        [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year . '_' . $gregorian_month . '_' . $gregorian_day));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */
597
+    public static function gregorian_to_jalali($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array | string {
598
+        [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year.'_'.$gregorian_month.'_'.$gregorian_day)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */
599 599
         $g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
600 600
         $gregorian_year2 = ($gregorian_month > 2) ? ($gregorian_year + 1) : $gregorian_year;
601 601
         $days = 355666 + (365 * $gregorian_year) + ((int) (($gregorian_year2 + 3) / 4)) - ((int) (($gregorian_year2 + 99) / 100)) + ((int) (($gregorian_year2 + 399) / 400)) + $gregorian_day + $g_d_m[$gregorian_month - 1];
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
             $jalali_month = 7 + (int) (($days - 186) / 30);
616 616
             $jalali_day = 1 + (($days - 186) % 30);
617 617
         }
618
-        return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year . $splitter . $jalali_month . $splitter . $jalali_day;
618
+        return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year.$splitter.$jalali_month.$splitter.$jalali_day;
619 619
     }
620
-    public static function jalali_to_gregorian ($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array|string {
621
-        [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year . '_' . $jalali_month . '_' . $jalali_day));
620
+    public static function jalali_to_gregorian($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array | string {
621
+        [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year.'_'.$jalali_month.'_'.$jalali_day));
622 622
         $jalali_year += 1595;
623 623
         $days = -355668 + (365 * $jalali_year) + (((int) ($jalali_year / 33)) * 8) + ((int) ((($jalali_year % 33) + 3) / 4)) + $jalali_day + (($jalali_month < 7) ? ($jalali_month - 1) * 31 : (($jalali_month - 7) * 30) + 186);
624 624
         $gregorian_year = 400 * (int) ($days / 146097);
@@ -655,6 +655,6 @@  discard block
 block discarded – undo
655 655
         for ($gregorian_month = 0; $gregorian_month < 13 and $gregorian_day > $month_days[$gregorian_month]; $gregorian_month++) {
656 656
             $gregorian_day -= $month_days[$gregorian_month];
657 657
         }
658
-        return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year . $splitter . $gregorian_month . $splitter . $gregorian_day;
658
+        return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year.$splitter.$gregorian_month.$splitter.$gregorian_day;
659 659
     }
660 660
 }
661 661
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +38 added lines, -31 removed lines patch added patch discarded remove patch
@@ -156,12 +156,13 @@  discard block
 block discarded – undo
156 156
                     break;
157 157
                 case 'W':
158 158
                     $avs = ($date[7] == 6 ? 0 : $date[7] + 1) - $doy % 7;
159
-                    if ($avs < 0) $avs += 7;
159
+                    if ($avs < 0) {
160
+                        $avs += 7;
161
+                    }
160 162
                     $num = (int) (($doy + $avs) / 7);
161 163
                     if ($avs < 4) {
162 164
                         $num++;
163
-                    }
164
-                    elseif ($num < 1) {
165
+                    } elseif ($num < 1) {
165 166
                         $num = ($avs == 4 or $avs == ($jalali_year % 33 % 4 - 2 == (int) ($jalali_year % 33 * 0.05) ? 5 : 4)) ? 53 : 52;
166 167
                     }
167 168
                     $aks = $avs + $leap_year;
@@ -187,7 +188,9 @@  discard block
 block discarded – undo
187 188
     }
188 189
     public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
189 190
         $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
190
-        if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone);
191
+        if ($time_zone != 'local') {
192
+            date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone);
193
+        }
191 194
         $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp));
192 195
         $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp));
193 196
         [$jalali_year, $jalali_month, $jalali_day] = self::gregorian_to_jalali($date[7], $date[4], $date[3]);
@@ -199,8 +202,7 @@  discard block
 block discarded – undo
199 202
             $sub = substr($format, $i, 1);
200 203
             if ($sub == '%') {
201 204
                 $sub = substr($format, ++$i, 1);
202
-            }
203
-            else {
205
+            } else {
204 206
                 $output .= $sub;
205 207
                 continue;
206 208
             }
@@ -229,30 +231,41 @@  discard block
 block discarded – undo
229 231
                     break;
230 232
                 /* Week */ case 'U':
231 233
                 $avs = (($date[6] < 5) ? $date[6] + 2 : $date[6] - 5) - ($doy % 7);
232
-                if ($avs < 0) $avs += 7;
234
+                if ($avs < 0) {
235
+                    $avs += 7;
236
+                }
233 237
                 $num = (int) (($doy + $avs) / 7) + 1;
234
-                if ($avs > 3 or $avs == 1) $num--;
238
+                if ($avs > 3 or $avs == 1) {
239
+                    $num--;
240
+                }
235 241
                 $output .= ($num < 10) ? '0' . $num : $num;
236 242
                 break;
237 243
                 case 'V':
238 244
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
239
-                    if ($avs < 0) $avs += 7;
245
+                    if ($avs < 0) {
246
+                        $avs += 7;
247
+                    }
240 248
                     $num = (int) (($doy + $avs) / 7);
241 249
                     if ($avs < 4) {
242 250
                         $num++;
243
-                    }
244
-                    elseif ($num < 1) {
251
+                    } elseif ($num < 1) {
245 252
                         $num = ($avs == 4 or $avs == ((((($jalali_year % 33) % 4) - 2) == ((int) (($jalali_year % 33) * 0.05))) ? 5 : 4)) ? 53 : 52;
246 253
                     }
247 254
                     $aks = $avs + $leap_year;
248
-                    if ($aks == 7) $aks = 0;
255
+                    if ($aks == 7) {
256
+                        $aks = 0;
257
+                    }
249 258
                     $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num);
250 259
                     break;
251 260
                 case 'W':
252 261
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
253
-                    if ($avs < 0) $avs += 7;
262
+                    if ($avs < 0) {
263
+                        $avs += 7;
264
+                    }
254 265
                     $num = (int) (($doy + $avs) / 7) + 1;
255
-                    if ($avs > 3) $num--;
266
+                    if ($avs > 3) {
267
+                        $num--;
268
+                    }
256 269
                     $output .= ($num < 10) ? '0' . $num : $num;
257 270
                     break;
258 271
                 /* Month */ case 'b':
@@ -356,11 +369,12 @@  discard block
 block discarded – undo
356 369
         return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output;
357 370
     }
358 371
     public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int {
359
-        if ($timezone != 'local') date_default_timezone_set($timezone);
372
+        if ($timezone != 'local') {
373
+            date_default_timezone_set($timezone);
374
+        }
360 375
         if ($hour === '') {
361 376
             return time();
362
-        }
363
-        else {
377
+        } else {
364 378
             [
365 379
                 $hour,
366 380
                 $minute,
@@ -371,16 +385,13 @@  discard block
 block discarded – undo
371 385
             ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year));
372 386
             if ($minute === '') {
373 387
                 return mktime($hour);
374
-            }
375
-            else {
388
+            } else {
376 389
                 if ($second === '') {
377 390
                     return mktime($hour, $minute);
378
-                }
379
-                else {
391
+                } else {
380 392
                     if ($jalali_month === '') {
381 393
                         return mktime($hour, $minute, $second);
382
-                    }
383
-                    else {
394
+                    } else {
384 395
                         $jdate = explode('_', self::jdate('Y_j', '', '', $timezone, 'en'));
385 396
                         if ($jalali_day === '') {
386 397
                             [
@@ -389,8 +400,7 @@  discard block
 block discarded – undo
389 400
                                 $gregorian_day
390 401
                             ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jdate[1]);
391 402
                             return mktime($hour, $minute, $second, $gregorian_month);
392
-                        }
393
-                        else {
403
+                        } else {
394 404
                             if ($jalali_year === '') {
395 405
                                 [
396 406
                                     $gregorian_year,
@@ -398,8 +408,7 @@  discard block
 block discarded – undo
398 408
                                     $gregorian_day
399 409
                                 ] = self::jalali_to_gregorian($jdate[0], $jalali_month, $jalali_day);
400 410
                                 return mktime($hour, $minute, $second, $gregorian_month, $gregorian_day);
401
-                            }
402
-                            else {
411
+                            } else {
403 412
                                 [
404 413
                                     $gregorian_year,
405 414
                                     $gregorian_month,
@@ -463,8 +472,7 @@  discard block
 block discarded – undo
463 472
                             'نوزده'
464 473
                         ];
465 474
                         $h34 = $k34[substr($num, 2 - $length, 2) - 10];
466
-                    }
467
-                    else {
475
+                    } else {
468 476
                         $xy4 = substr($num, 3 - $length, 1);
469 477
                         $p34 = ($xy3 == 0 or $xy4 == 0) ? '' : ' و ';
470 478
                         $k3 = ['', '', 'بیست', 'سی', 'چهل', 'پنجاه', 'شصت', 'هفتاد', 'هشتاد', 'نود'];
@@ -610,8 +618,7 @@  discard block
 block discarded – undo
610 618
         if ($days < 186) {
611 619
             $jalali_month = 1 + (int) ($days / 31);
612 620
             $jalali_day = 1 + ($days % 31);
613
-        }
614
-        else {
621
+        } else {
615 622
             $jalali_month = 7 + (int) (($days - 186) / 30);
616 623
             $jalali_day = 1 + (($days - 186) % 30);
617 624
         }
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,6 +49,6 @@
 block discarded – undo
49 49
  *
50 50
  * @return array|string
51 51
  */
52
-function strReplace(array $replacements, string|array $subject): array|string {
52
+function strReplace(array $replacements, string | array $subject): array | string {
53 53
     return str_replace(array_keys($replacements), array_values($replacements), $subject);
54 54
 }
55 55
\ No newline at end of file
Please login to merge, or discard this patch.
src/database/mysql.php 2 patches
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * If you want to use it in standalone mode , you MUST set `auto_process` to `false`
31 31
      */
32
-    public static function init (string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void {
32
+    public static function init(string $host = 'localhost', string $username = 'root', string $password = '', string $dbname = '', bool $auto_process = null, int $port = 3306): void {
33 33
         $host = settings::$db['host'] ?? $host;
34 34
         $port = settings::$db['port'] ?? $port;
35 35
         $user = settings::$db['user'] ?? settings::$db['username'] ?? $username;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         self::$db_name = $dbname;
40 40
         self::$connection = new mysqli($host, $user, $pass, $dbname, $port);
41 41
         if (self::$connection->connect_errno) {
42
-            logger::write('SQL connection has problem : ' . self::$connection->connect_error, loggerTypes::ERROR);
42
+            logger::write('SQL connection has problem : '.self::$connection->connect_error, loggerTypes::ERROR);
43 43
             throw new bptException('SQL_CONNECTION_PROBLEM');
44 44
         }
45 45
         if (self::$auto_process && !lock::exist('BPT-MYSQL')) {
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
     }
49 49
 
50
-    private static function install (): void {
50
+    private static function install(): void {
51 51
         self::pureQuery("
52 52
 CREATE TABLE `users`
53 53
 (
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     /**
69 69
      * @internal Only for BPT self usage , Don't use it in your source!
70 70
      */
71
-    public static function process (): void {
71
+    public static function process(): void {
72 72
         if (self::$auto_process) {
73 73
             if (isset(BPT::$update->message)) {
74 74
                 self::processMessage(BPT::$update->message);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         }
89 89
     }
90 90
 
91
-    private static function processMessage (message $update): void {
91
+    private static function processMessage(message $update): void {
92 92
         $type = $update->chat->type;
93 93
         if ($type === chatType::PRIVATE) {
94 94
             $user_id = $update->from->id;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         }
115 115
     }
116 116
 
117
-    private static function processCallbackQuery (callbackQuery $update): void {
117
+    private static function processCallbackQuery(callbackQuery $update): void {
118 118
         $type = $update->message->chat->type;
119 119
         if ($type === chatType::PRIVATE) {
120 120
             $user_id = $update->from->id;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         }
125 125
     }
126 126
 
127
-    private static function processInlineQuery (inlineQuery $update): void {
127
+    private static function processInlineQuery(inlineQuery $update): void {
128 128
         $type = $update->chat_type;
129 129
         if ($type === chatType::PRIVATE || $type === chatType::SENDER) {
130 130
             $user_id = $update->from->id;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         }
135 135
     }
136 136
 
137
-    private static function processMyChatMember (chatMemberUpdated $update): void {
137
+    private static function processMyChatMember(chatMemberUpdated $update): void {
138 138
         $type = $update->chat->type;
139 139
         if ($type === chatType::PRIVATE) {
140 140
             if ($update->new_chat_member->status === chatMemberStatus::MEMBER) {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
      *
152 152
      * @return mysqli
153 153
      */
154
-    public static function getMysqli (): mysqli {
154
+    public static function getMysqli(): mysqli {
155 155
         return self::$connection;
156 156
     }
157 157
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      *
163 163
      * @return int|string
164 164
      */
165
-    public static function affected_rows (): int|string {
165
+    public static function affected_rows(): int | string {
166 166
         return self::$connection->affected_rows;
167 167
     }
168 168
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      *
174 174
      * @return int|string
175 175
      */
176
-    public static function affectedRows (): int|string {
176
+    public static function affectedRows(): int | string {
177 177
         return self::$connection->affected_rows;
178 178
     }
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      *
185 185
      * @return int|string
186 186
      */
187
-    public static function insert_id (): int|string {
187
+    public static function insert_id(): int | string {
188 188
         return self::$connection->insert_id;
189 189
     }
190 190
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
      *
196 196
      * @return int|string
197 197
      */
198
-    public static function insertId (): int|string {
198
+    public static function insertId(): int | string {
199 199
         return self::$connection->insert_id;
200 200
     }
201 201
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      *
207 207
      * @return string
208 208
      */
209
-    public static function escapeString (string $text): string {
209
+    public static function escapeString(string $text): string {
210 210
         return self::$connection->real_escape_string($text);
211 211
     }
212 212
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
      *
216 216
      * @return string
217 217
      */
218
-    public static function error (): string {
218
+    public static function error(): string {
219 219
         return self::$connection->error;
220 220
     }
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      *
225 225
      * @return int
226 226
      */
227
-    public static function errno (): int {
227
+    public static function errno(): int {
228 228
         return self::$connection->errno;
229 229
     }
230 230
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      *
236 236
      * @return bool
237 237
      */
238
-    public static function setCharset (string $charset): bool {
238
+    public static function setCharset(string $charset): bool {
239 239
         return self::$connection->set_charset($charset);
240 240
     }
241 241
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
      *
251 251
      * @return mysqli_result|bool
252 252
      */
253
-    public static function pureQuery (string $query): mysqli_result|bool {
253
+    public static function pureQuery(string $query): mysqli_result | bool {
254 254
         return self::$connection->query($query);
255 255
     }
256 256
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      *
272 272
      * @return mysqli_result|bool
273 273
      */
274
-    public static function query (string $query, array $vars = [], bool $need_result = true): mysqli_result|bool {
274
+    public static function query(string $query, array $vars = [], bool $need_result = true): mysqli_result | bool {
275 275
         if (empty($vars)) {
276 276
             return self::pureQuery($query);
277 277
         }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                 $types .= 's';
289 289
             }
290 290
         }
291
-        $prepare->bind_param($types,...$vars);
291
+        $prepare->bind_param($types, ...$vars);
292 292
         if (!$prepare->execute()) {
293 293
             logger::write(loggerTypes::WARNING, $prepare->error);
294 294
             return false;
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
                 continue;
320 320
             }
321 321
 
322
-            $operator = substr($value,0,2);
323
-            $operator_value = substr($value,2);
322
+            $operator = substr($value, 0, 2);
323
+            $operator_value = substr($value, 2);
324 324
             switch ($operator) {
325 325
                 case '>=':
326 326
                     $query .= " `$name` >= ?";
@@ -357,17 +357,17 @@  discard block
 block discarded – undo
357 357
         return $values;
358 358
     }
359 359
 
360
-    private static function groupByBuilder(string &$query, string|array $group_by = []): void {
360
+    private static function groupByBuilder(string &$query, string | array $group_by = []): void {
361 361
         if (empty($group_by)) {
362 362
             return;
363 363
         }
364 364
         if (is_string($group_by)) {
365 365
             $group_by = [$group_by];
366 366
         }
367
-        $query .= ' GROUP BY `' . implode('`, `',$group_by) . '`';
367
+        $query .= ' GROUP BY `'.implode('`, `', $group_by).'`';
368 368
     }
369 369
 
370
-    private static function orderByBuilder(string &$query, string|array $order_by = []): void {
370
+    private static function orderByBuilder(string &$query, string | array $order_by = []): void {
371 371
         if (empty($order_by)) {
372 372
             return;
373 373
         }
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
                 continue;
421 421
             }
422 422
 
423
-            $operator = substr($value,0,2);
424
-            $operator_value = substr($value,2);
423
+            $operator = substr($value, 0, 2);
424
+            $operator_value = substr($value, 2);
425 425
             switch ($operator) {
426 426
                 case '+=':
427 427
                     $query .= " `$name` = `$name` + ?";
@@ -454,14 +454,14 @@  discard block
 block discarded – undo
454 454
         return $values;
455 455
     }
456 456
 
457
-    private static function insertBuilder(string &$query, string|array $columns, array|string $values): array {
458
-        $query .= '(`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES (';
457
+    private static function insertBuilder(string &$query, string | array $columns, array | string $values): array {
458
+        $query .= '(`'.(is_string($columns) ? $columns : implode('`,`', $columns)).'`) VALUES (';
459 459
         if (is_string($values)) $values = [$values];
460
-        $query .= '?' . str_repeat(',?', count($values) - 1) . ')';
460
+        $query .= '?'.str_repeat(',?', count($values) - 1).')';
461 461
         return $values;
462 462
     }
463 463
 
464
-    private static function selectBuilder (string &$query, string|array $columns): void {
464
+    private static function selectBuilder(string &$query, string | array $columns): void {
465 465
         if ($columns == '*') {
466 466
             $query .= " * ";
467 467
             return;
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
                     $formatted = '*';
481 481
                     $column = 'all';
482 482
                 }
483
-                $query .= strtoupper($function) . "($formatted) as `{$function}_$column`";
483
+                $query .= strtoupper($function)."($formatted) as `{$function}_$column`";
484 484
             }
485 485
             else {
486 486
                 $query .= "`$column`";
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
      *
506 506
      * @return bool
507 507
      */
508
-    public static function delete (string $table, array $where = null, int $count = null, int $offset = null): bool {
508
+    public static function delete(string $table, array $where = null, int $count = null, int $offset = null): bool {
509 509
         $query = "DELETE FROM `$table`";
510 510
         $vars = self::whereBuilder($query, $where);
511 511
         return self::query($query, $vars, false);
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
      *
525 525
      * @return bool
526 526
      */
527
-    public static function update (string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool {
527
+    public static function update(string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool {
528 528
         $query = "UPDATE `$table` SET";
529 529
         $modify_vars = self::updateBuilder($query, $modify);
530 530
         $where_vars = self::whereBuilder($query, $where);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
      *
544 544
      * @return bool
545 545
      */
546
-    public static function insert (string $table, string|array $columns, array|string $values): bool {
546
+    public static function insert(string $table, string | array $columns, array | string $values): bool {
547 547
         $query = "INSERT INTO `$table`";
548 548
         $values = self::insertBuilder($query, $columns, $values);
549 549
         return self::query($query, $values, false);
@@ -566,14 +566,14 @@  discard block
 block discarded – undo
566 566
      *
567 567
      * @return mysqli_result|bool
568 568
      */
569
-    public static function select (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = []): mysqli_result|bool {
569
+    public static function select(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = []): mysqli_result | bool {
570 570
         $query = "SELECT";
571 571
         self::selectBuilder($query, $columns);
572 572
         $query .= "FROM `$table`";
573
-        $var = self::whereBuilder($query,$where);
573
+        $var = self::whereBuilder($query, $where);
574 574
         self::groupByBuilder($query, $group_by);
575 575
         self::orderByBuilder($query, $order_by);
576
-        self::countBuilder($query,$count,$offset);
576
+        self::countBuilder($query, $count, $offset);
577 577
         return self::query($query, $var);
578 578
     }
579 579
 
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
      *
591 591
      * @return null|bool|array
592 592
      */
593
-    public static function selectArray (string $table, array|string $columns = '*', array $where = null, array|string $group_by = [], array|string $order_by = []): bool|array|null {
593
+    public static function selectArray(string $table, array | string $columns = '*', array $where = null, array | string $group_by = [], array | string $order_by = []): bool | array | null {
594 594
         $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by);
595 595
         if ($res) {
596 596
             return $res->fetch_assoc();
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
      * @param array|string $group_by group result based on these columns
610 610
      * @param array|string $order_by order result based on these columns
611 611
      */
612
-    public static function selectObject (string $table, array|string $columns = '*', array $where = null, array|string $group_by = [], array|string $order_by = []) {
612
+    public static function selectObject(string $table, array | string $columns = '*', array $where = null, array | string $group_by = [], array | string $order_by = []) {
613 613
         $res = self::select($table, $columns, $where, 1, 0, $group_by, $order_by);
614 614
         if ($res) {
615 615
             return $res->fetch_object();
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
      *
634 634
      * @return bool|Generator
635 635
      */
636
-    public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = []): bool|Generator {
636
+    public static function selectEach(string $table, array | string $columns = '*', array $where = null, int $count = null, int $offset = null, array | string $group_by = [], array | string $order_by = []): bool | Generator {
637 637
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by);
638 638
         if ($res) {
639 639
             while ($row = $res->fetch_assoc()) yield $row;
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
      *
652 652
      * @return string if save is true , return file name otherwise return sql data
653 653
      */
654
-    public static function backup (array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string {
654
+    public static function backup(array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string {
655 655
         self::setCharset('utf8mb4');
656 656
 
657
-        $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0);
657
+        $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0);
658 658
         if (!empty($wanted_tables)) {
659 659
             $tables = array_intersect($tables, $wanted_tables);
660 660
         }
@@ -665,12 +665,12 @@  discard block
 block discarded – undo
665 665
             logger::write('No table founded for backup, if your database has table : check $wanted_tables argument', loggerTypes::WARNING);
666 666
         }
667 667
         foreach ($tables as $table) {
668
-            $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n";
668
+            $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n";
669 669
             if ($table_data) {
670 670
                 $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt;
671 671
                 for ($i = 0; $i < $total_rows; $i = $i + 1000) {
672
-                    $sql .= "INSERT INTO " . $table . " VALUES";
673
-                    $result = self::select($table, '*' , null, 1000, $i);
672
+                    $sql .= "INSERT INTO ".$table." VALUES";
673
+                    $result = self::select($table, '*', null, 1000, $i);
674 674
                     $field_count = $result->field_count;
675 675
                     $affected_rows = self::affected_rows();
676 676
                     $counter = 1;
@@ -678,12 +678,12 @@  discard block
 block discarded – undo
678 678
                         $sql .= "\n(";
679 679
                         for ($column = 0; $column < $field_count; $column++) {
680 680
                             $row[$column] = str_replace("\n", "\\n", addslashes($row[$column]));
681
-                            $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""';
681
+                            $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""';
682 682
                             if ($column < $field_count - 1) {
683 683
                                 $sql .= ',';
684 684
                             }
685 685
                         }
686
-                        $sql .= ')' . ($counter == $affected_rows ? ';' : ',');
686
+                        $sql .= ')'.($counter == $affected_rows ? ';' : ',');
687 687
                         $counter++;
688 688
                     }
689 689
                 }
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
         }
700 700
 
701 701
         if (empty($file_name)) {
702
-            $file_name = self::$db_name . time() . '.sql';
702
+            $file_name = self::$db_name.time().'.sql';
703 703
         }
704 704
         file_put_contents($file_name, $sql);
705 705
         return $file_name;
Please login to merge, or discard this patch.
Braces   +20 added lines, -27 removed lines patch added patch discarded remove patch
@@ -72,17 +72,13 @@  discard block
 block discarded – undo
72 72
         if (self::$auto_process) {
73 73
             if (isset(BPT::$update->message)) {
74 74
                 self::processMessage(BPT::$update->message);
75
-            }
76
-            elseif (isset(BPT::$update->edited_message)) {
75
+            } elseif (isset(BPT::$update->edited_message)) {
77 76
                 self::processMessage(BPT::$update->edited_message);
78
-            }
79
-            elseif (isset(BPT::$update->callback_query)) {
77
+            } elseif (isset(BPT::$update->callback_query)) {
80 78
                 self::processCallbackQuery(BPT::$update->callback_query);
81
-            }
82
-            elseif (isset(BPT::$update->inline_query)) {
79
+            } elseif (isset(BPT::$update->inline_query)) {
83 80
                 self::processInlineQuery(BPT::$update->inline_query);
84
-            }
85
-            elseif (isset(BPT::$update->my_chat_member)) {
81
+            } elseif (isset(BPT::$update->my_chat_member)) {
86 82
                 self::processMyChatMember(BPT::$update->my_chat_member);
87 83
             }
88 84
         }
@@ -139,8 +135,7 @@  discard block
 block discarded – undo
139 135
         if ($type === chatType::PRIVATE) {
140 136
             if ($update->new_chat_member->status === chatMemberStatus::MEMBER) {
141 137
                 self::update('users', ['blocked' => false], ['id' => $update->from->id], 1);
142
-            }
143
-            else {
138
+            } else {
144 139
                 self::update('users', ['blocked' => true], ['id' => $update->from->id], 1);
145 140
             }
146 141
         }
@@ -280,11 +275,9 @@  discard block
 block discarded – undo
280 275
         foreach ($vars as $var) {
281 276
             if (is_int($var)) {
282 277
                 $types .= 'i';
283
-            }
284
-            elseif (is_double($var)) {
278
+            } elseif (is_double($var)) {
285 279
                 $types .= 'd';
286
-            }
287
-            else {
280
+            } else {
288 281
                 $types .= 's';
289 282
             }
290 283
         }
@@ -308,8 +301,7 @@  discard block
 block discarded – undo
308 301
         foreach ($where as $name => $value) {
309 302
             if ($first) {
310 303
                 $first = false;
311
-            }
312
-            else {
304
+            } else {
313 305
                 $query .= ' AND';
314 306
             }
315 307
 
@@ -381,8 +373,7 @@  discard block
 block discarded – undo
381 373
         foreach ($order_by as $key => $mode) {
382 374
             if ($first) {
383 375
                 $first = false;
384
-            }
385
-            else {
376
+            } else {
386 377
                 $query .= ', ';
387 378
             }
388 379
             if (is_numeric($key)) {
@@ -396,8 +387,7 @@  discard block
 block discarded – undo
396 387
     private static function countBuilder(string &$query, int $count = null, int $offset = null): void {
397 388
         if (!empty($count)) {
398 389
             $query .= !empty($offset) ? " LIMIT $offset,$count" : " LIMIT $count";
399
-        }
400
-        elseif (!empty($offset)) {
390
+        } elseif (!empty($offset)) {
401 391
             $query .= " OFFSET $offset";
402 392
         }
403 393
     }
@@ -409,8 +399,7 @@  discard block
 block discarded – undo
409 399
         foreach ($modify as $name => $value) {
410 400
             if ($first) {
411 401
                 $first = false;
412
-            }
413
-            else {
402
+            } else {
414 403
                 $query .= ' ,';
415 404
             }
416 405
 
@@ -456,7 +445,9 @@  discard block
 block discarded – undo
456 445
 
457 446
     private static function insertBuilder(string &$query, string|array $columns, array|string $values): array {
458 447
         $query .= '(`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES (';
459
-        if (is_string($values)) $values = [$values];
448
+        if (is_string($values)) {
449
+            $values = [$values];
450
+        }
460 451
         $query .= '?' . str_repeat(',?', count($values) - 1) . ')';
461 452
         return $values;
462 453
     }
@@ -481,8 +472,7 @@  discard block
 block discarded – undo
481 472
                     $column = 'all';
482 473
                 }
483 474
                 $query .= strtoupper($function) . "($formatted) as `{$function}_$column`";
484
-            }
485
-            else {
475
+            } else {
486 476
                 $query .= "`$column`";
487 477
             }
488 478
 
@@ -636,9 +626,12 @@  discard block
 block discarded – undo
636 626
     public static function selectEach (string $table, array|string $columns = '*', array $where = null, int $count = null, int $offset = null, array|string $group_by = [], array|string $order_by = []): bool|Generator {
637 627
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by);
638 628
         if ($res) {
639
-            while ($row = $res->fetch_assoc()) yield $row;
629
+            while ($row = $res->fetch_assoc()) {
630
+                yield $row;
631
+            }
632
+        } else {
633
+            return $res;
640 634
         }
641
-        else return $res;
642 635
     }
643 636
 
644 637
     /**
Please login to merge, or discard this patch.