Passed
Branch main (405ee4)
by Miaad
02:11
created
settings.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     public static int $log_size = 10;
23 23
 
24
-    public static string|CURLFile|null $certificate = null;
24
+    public static string | CURLFile | null $certificate = null;
25 25
 
26 26
     public static bool $handler = true;
27 27
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 
46 46
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
47 47
 
48
-    public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
48
+    public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
49 49
 
50 50
 
51
-    public static function init (array|stdClass $settings) {
51
+    public static function init(array | stdClass $settings) {
52 52
         $settings = (array) $settings;
53 53
 
54 54
         if (!(isset($settings['logger']) && $settings['logger'] == false)) {
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
         }
57 57
 
58 58
         foreach ($settings as $setting => $value) {
59
-            try{
59
+            try {
60 60
                 self::$$setting = $value;
61 61
             }
62
-            catch (TypeError){
63
-                logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
62
+            catch (TypeError) {
63
+                logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING);
64 64
             }
65
-            catch (Error){
66
-                logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
65
+            catch (Error) {
66
+                logger::write("$setting setting is not one of library settings", loggerTypes::WARNING);
67 67
             }
68 68
         }
69 69
 
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
                 }
78 78
             }
79 79
             else {
80
-                logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
80
+                logger::write('token format is not right, check it and try again', loggerTypes::ERROR);
81 81
                 throw new bptException('TOKEN_NOT_TRUE');
82 82
             }
83 83
         }
84 84
         else {
85
-            logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
85
+            logger::write('You must specify token parameter in settings', loggerTypes::ERROR);
86 86
             throw new bptException('TOKEN_NOT_FOUND');
87 87
         }
88 88
     }
89 89
 
90 90
     public static function done() {
91 91
         if (self::$logger) {
92
-            $estimated = round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2);
92
+            $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2);
93 93
             $status_message = match (true) {
94 94
                 $estimated < 100 => 'Excellent',
95 95
                 $estimated < 500 => 'Very good',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         if (self::$secure_folder) {
122 122
             $address = explode('/', $_SERVER['REQUEST_URI']);
123 123
             unset($address[count($address) - 1]);
124
-            $address = implode('/', $address) . '/BPT.php';
124
+            $address = implode('/', $address).'/BPT.php';
125 125
             $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n  Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n    Order Allow,Deny\n    Allow from all\n</Files>";
126 126
             if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
127 127
                 file_put_contents('.htaccess', $text);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             getUpdates::init();
141 141
         }
142 142
         else {
143
-            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
143
+            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
144 144
             throw new bptException('GETUPDATE_NEED_HANDLER');
145 145
         }
146 146
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,11 +58,9 @@  discard block
 block discarded – undo
58 58
         foreach ($settings as $setting => $value) {
59 59
             try{
60 60
                 self::$$setting = $value;
61
-            }
62
-            catch (TypeError){
61
+            } catch (TypeError){
63 62
                 logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
64
-            }
65
-            catch (Error){
63
+            } catch (Error){
66 64
                 logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
67 65
             }
68 66
         }
@@ -75,13 +73,11 @@  discard block
 block discarded – undo
75 73
                 if (!empty(self::$receiver)) {
76 74
                     self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates();
77 75
                 }
78
-            }
79
-            else {
76
+            } else {
80 77
                 logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
81 78
                 throw new bptException('TOKEN_NOT_TRUE');
82 79
             }
83
-        }
84
-        else {
80
+        } else {
85 81
             logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
86 82
             throw new bptException('TOKEN_NOT_FOUND');
87 83
         }
@@ -138,8 +134,7 @@  discard block
 block discarded – undo
138 134
     private static function getUpdates() {
139 135
         if (self::$handler) {
140 136
             getUpdates::init();
141
-        }
142
-        else {
137
+        } else {
143 138
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
144 139
             throw new bptException('GETUPDATE_NEED_HANDLER');
145 140
         }
Please login to merge, or discard this patch.
tools/generator.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @return string
30 30
      */
31
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
31
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
32 32
         $rand_string = '';
33 33
         $char_len = strlen($characters) - 1;
34
-        for ($i = 0; $i < $length; $i ++) {
34
+        for ($i = 0; $i < $length; $i++) {
35 35
             $rand_string .= $characters[rand(0, $char_len)];
36 36
         }
37 37
         return $rand_string;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline
61 61
      * @throws bptException
62 62
      */
63
-    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup {
63
+    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup {
64 64
         if (!empty($keyboard)) {
65 65
             $keyboard_object = new replyKeyboardMarkup();
66 66
             $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true);
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             return $keyboard_object;
120 120
         }
121 121
         else {
122
-            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
122
+            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR);
123 123
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
124 124
         }
125 125
     }
Please login to merge, or discard this patch.
Braces   +10 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
                 $keyboard_object->setOne_time_keyboard($keyboard['one_time']);
69 69
             }
70 70
             foreach ($keyboard as $row) {
71
-                if (!is_array($row)) continue;
71
+                if (!is_array($row)) {
72
+                    continue;
73
+                }
72 74
                 $buttons = [];
73 75
                 foreach ($row as $base_button) {
74 76
                     $button_info = explode('||', $base_button);
@@ -77,15 +79,12 @@  discard block
 block discarded – undo
77 79
                     if (count($button_info) > 1) {
78 80
                         if ($button_info[1] === 'con') {
79 81
                             $button->setRequest_contact(true);
80
-                        }
81
-                        elseif ($button_info[1] === 'loc') {
82
+                        } elseif ($button_info[1] === 'loc') {
82 83
                             $button->setRequest_location(true);
83
-                        }
84
-                        elseif ($button_info[1] === 'poll') {
84
+                        } elseif ($button_info[1] === 'poll') {
85 85
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
86 86
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
87
-                        }
88
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
87
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
89 88
                             $url = $button_info[2];
90 89
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
91 90
                         }
@@ -95,8 +94,7 @@  discard block
 block discarded – undo
95 94
                 $keyboard_object->setKeyboard([$buttons]);
96 95
             }
97 96
             return $keyboard_object;
98
-        }
99
-        elseif (!empty($inline)) {
97
+        } elseif (!empty($inline)) {
100 98
             $keyboard_object = new inlineKeyboardMarkup();
101 99
             foreach ($inline as $row) {
102 100
                 $buttons = [];
@@ -105,20 +103,17 @@  discard block
 block discarded – undo
105 103
                     if (isset($button_info[1])) {
106 104
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
107 105
                             $button->setText($button_info[0])->setUrl($button_info[1]);
108
-                        }
109
-                        else {
106
+                        } else {
110 107
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
111 108
                         }
112
-                    }
113
-                    else {
109
+                    } else {
114 110
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
115 111
                     }
116 112
                 }
117 113
                 $keyboard_object->setInline_keyboard([$buttons]);
118 114
             }
119 115
             return $keyboard_object;
120
-        }
121
-        else {
116
+        } else {
122 117
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
123 118
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
124 119
         }
Please login to merge, or discard this patch.