Passed
Push — main ( 64ea8c...cb0dfb )
by Miaad
10:02
created
src/tools/tools.php 1 patch
Braces   +30 added lines, -24 removed lines patch added patch discarded remove patch
@@ -217,8 +217,9 @@  discard block
 block discarded – undo
217 217
             if (telegram::$status) {
218 218
                 $check = $check->status;
219 219
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
220
+            } else {
221
+                $result[$id] = null;
220 222
             }
221
-            else $result[$id] = null;
222 223
         }
223 224
         return $result;
224 225
     }
@@ -260,8 +261,7 @@  discard block
 block discarded – undo
260 261
             curl_exec($ch);
261 262
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
262 263
             curl_close($ch);
263
-        }
264
-        else {
264
+        } else {
265 265
             $path = realpath($path);
266 266
             $size = file_exists($path) ? filesize($path) : false;
267 267
         }
@@ -332,8 +332,7 @@  discard block
 block discarded – undo
332 332
                     $zip->addFile($filePath, substr($filePath, $root_len));
333 333
                 }
334 334
             }
335
-        }
336
-        else {
335
+        } else {
337 336
             $zip->addFile($path, basename($path));
338 337
         }
339 338
         return $zip->close();
@@ -352,9 +351,13 @@  discard block
 block discarded – undo
352 351
      */
353 352
     public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool {
354 353
         $file = fopen($url, 'rb');
355
-        if (!$file) return false;
354
+        if (!$file) {
355
+            return false;
356
+        }
356 357
         $path = fopen($path, 'wb');
357
-        if (!$path) return false;
358
+        if (!$path) {
359
+            return false;
360
+        }
358 361
 
359 362
         $length = $chunk_size * 1024;
360 363
         while (!feof($file)){
@@ -461,8 +464,9 @@  discard block
 block discarded – undo
461 464
         foreach ($string as $k => &$v) {
462 465
             if ($diff->$v) {
463 466
                 $v = $diff->$v;
467
+            } else {
468
+                unset($string[$k]);
464 469
             }
465
-            else unset($string[$k]);
466 470
         }
467 471
         $string['status'] = $base_time < $target_time ? 'later' : 'ago';
468 472
 
@@ -528,8 +532,7 @@  discard block
 block discarded – undo
528 532
             if ($last === "\0") {
529 533
                 $new .= str_repeat($last, ord($char));
530 534
                 $last = '';
531
-            }
532
-            else {
535
+            } else {
533 536
                 $new .= $last;
534 537
                 $last = $char;
535 538
             }
@@ -613,7 +616,9 @@  discard block
 block discarded – undo
613 616
             }
614 617
             $rows = [];
615 618
             foreach ($keyboard as $row) {
616
-                if (!is_array($row)) continue;
619
+                if (!is_array($row)) {
620
+                    continue;
621
+                }
617 622
                 $buttons = [];
618 623
                 foreach ($row as $base_button) {
619 624
                     $button_info = explode('||', $base_button);
@@ -622,15 +627,12 @@  discard block
 block discarded – undo
622 627
                     if (count($button_info) > 1) {
623 628
                         if ($button_info[1] === 'con') {
624 629
                             $button->setRequest_contact(true);
625
-                        }
626
-                        elseif ($button_info[1] === 'loc') {
630
+                        } elseif ($button_info[1] === 'loc') {
627 631
                             $button->setRequest_location(true);
628
-                        }
629
-                        elseif ($button_info[1] === 'poll') {
632
+                        } elseif ($button_info[1] === 'poll') {
630 633
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
631 634
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
632
-                        }
633
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
635
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
634 636
                             $url = $button_info[2];
635 637
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
636 638
                         }
@@ -652,12 +654,10 @@  discard block
 block discarded – undo
652 654
                     if (isset($button_info[1])) {
653 655
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
654 656
                             $button->setText($button_info[0])->setUrl($button_info[1]);
655
-                        }
656
-                        else {
657
+                        } else {
657 658
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
658 659
                         }
659
-                    }
660
-                    else {
660
+                    } else {
661 661
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
662 662
                     }
663 663
                     $buttons[] = $button;
@@ -684,8 +684,12 @@  discard block
 block discarded – undo
684 684
      * @return string
685 685
      */
686 686
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
687
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
688
-        if (empty($bot_username)) $bot_username = telegram::getMe()->username;
687
+        if (empty($user_id)) {
688
+            $user_id = telegram::catchFields(fields::USER_ID);
689
+        }
690
+        if (empty($bot_username)) {
691
+            $bot_username = telegram::getMe()->username;
692
+        }
689 693
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
690 694
     }
691 695
 
@@ -752,7 +756,9 @@  discard block
 block discarded – undo
752 756
             $array[] = $num % 62;
753 757
             $num = floor($num / 62);
754 758
         }
755
-        if (count($array) < 1) $array = [0];
759
+        if (count($array) < 1) {
760
+            $array = [0];
761
+        }
756 762
         foreach ($array as &$value) {
757 763
             $value = $codes[$value];
758 764
         }
Please login to merge, or discard this patch.
src/tools/cpanel.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@
 block discarded – undo
85 85
         $create_user = self::createMysqlUser($user, $password);
86 86
         if (empty($privileges)) {
87 87
             $set_privileges = self::setMysqlPrivilegesAll($database, $user);
88
-        }
89
-        else {
88
+        } else {
90 89
             $set_privileges = self::setMysqlPrivileges($database, $user, $privileges);
91 90
         }
92 91
         return [
Please login to merge, or discard this patch.