Passed
Push — main ( 1e3b41...5f13e5 )
by Miaad
11:27
created
src/types/document.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,23 +22,23 @@  discard block
 block discarded – undo
22 22
     public string $file_unique_id;
23 23
 
24 24
     /** Optional. Document thumbnail as defined by sender */
25
-    public null|photoSize $thumbnail = null;
25
+    public null | photoSize $thumbnail = null;
26 26
 
27 27
     /** Optional. Original filename as defined by sender */
28
-    public null|string $file_name = null;
28
+    public null | string $file_name = null;
29 29
 
30 30
     /** Optional. MIME type of the file as defined by sender */
31
-    public null|string $mime_type = null;
31
+    public null | string $mime_type = null;
32 32
 
33 33
     /**
34 34
      * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
35 35
      * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
36 36
      * integer or double-precision float type are safe for storing this value.
37 37
      */
38
-    public null|int $file_size = null;
38
+    public null | int $file_size = null;
39 39
 
40 40
 
41
-    public function __construct(stdClass|null $object = null) {
41
+    public function __construct(stdClass | null $object = null) {
42 42
         if ($object != null) {
43 43
             parent::__construct($object, self::subs);
44 44
         }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @return bool|string string will be returned when destination doesn't set
61 61
      */
62
-    public function download(string|null $destination = null): bool|string {
63
-        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.txt',$this->file_id);
62
+    public function download(string | null $destination = null): bool | string {
63
+        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.txt', $this->file_id);
64 64
     }
65 65
 
66 66
     public function link(): string {
Please login to merge, or discard this patch.
src/types/botDescription.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
     public string $description;
19 19
 
20 20
 
21
-    public function __construct(stdClass|null $object = null) {
21
+    public function __construct(stdClass | null $object = null) {
22 22
         if ($object != null) {
23 23
             parent::__construct($object, self::subs);
24 24
         }
Please login to merge, or discard this patch.
src/types/sticker.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -38,34 +38,34 @@  discard block
 block discarded – undo
38 38
     public int $height;
39 39
 
40 40
     /** True, if the sticker is animated */
41
-    public null|bool $is_animated = null;
41
+    public null | bool $is_animated = null;
42 42
 
43 43
     /** True, if the sticker is a video sticker */
44
-    public null|bool $is_video = null;
44
+    public null | bool $is_video = null;
45 45
 
46 46
     /** Optional. Sticker thumbnail in the .WEBP or .JPG format */
47
-    public null|photoSize $thumbnail = null;
47
+    public null | photoSize $thumbnail = null;
48 48
 
49 49
     /** Optional. Emoji associated with the sticker */
50
-    public null|string $emoji = null;
50
+    public null | string $emoji = null;
51 51
 
52 52
     /** Optional. Name of the sticker set to which the sticker belongs */
53
-    public null|string $set_name = null;
53
+    public null | string $set_name = null;
54 54
 
55 55
     /** Optional. Premium animation for the sticker, if the sticker is premium */
56
-    public null|file $premium_animation = null;
56
+    public null | file $premium_animation = null;
57 57
 
58 58
     /** Optional. For mask stickers, the position where the mask should be placed */
59
-    public null|maskPosition $mask_position = null;
59
+    public null | maskPosition $mask_position = null;
60 60
 
61 61
     /** Optional. For custom emoji stickers, unique identifier of the custom emoji */
62
-    public null|string $custom_emoji_id = null;
62
+    public null | string $custom_emoji_id = null;
63 63
 
64 64
     /** Optional. File size in bytes */
65
-    public null|int $file_size = null;
65
+    public null | int $file_size = null;
66 66
 
67 67
 
68
-    public function __construct(stdClass|null $object = null) {
68
+    public function __construct(stdClass | null $object = null) {
69 69
         if ($object != null) {
70 70
             parent::__construct($object, self::subs);
71 71
         }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
      *
87 87
      * @return bool|string string will be returned when destination doesn't set
88 88
      */
89
-    public function download(string|null $destination = null): bool|string {
90
-        return telegram::downloadFile($destination ?? 'unknown.png',$this->file_id);
89
+    public function download(string | null $destination = null): bool | string {
90
+        return telegram::downloadFile($destination ?? 'unknown.png', $this->file_id);
91 91
     }
92 92
 
93 93
     public function link(): string {
Please login to merge, or discard this patch.
src/telegram/request.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -812,30 +812,30 @@  discard block
 block discarded – undo
812 812
         'getGameHighScores'               => ['BPT\types\gameHighScore']
813 813
     ];
814 814
 
815
-    public static function __callStatic (string $name, array $arguments) {
815
+    public static function __callStatic(string $name, array $arguments) {
816 816
         if (!$action = self::methodAction($name)) {
817
-            logger::write("$name method is not supported",loggerTypes::ERROR);
817
+            logger::write("$name method is not supported", loggerTypes::ERROR);
818 818
             throw new bptException('METHOD_NOT_FOUND');
819 819
         }
820 820
         self::checkArguments($arguments);
821
-        self::keysName($action,$arguments);
822
-        self::readyFile($action,$arguments);
821
+        self::keysName($action, $arguments);
822
+        self::readyFile($action, $arguments);
823 823
         self::cleanArguments($arguments);
824
-        self::setDefaults($action,$arguments);
824
+        self::setDefaults($action, $arguments);
825 825
 
826 826
         if (isset($arguments['answer']) && $arguments['answer'] === true) {
827 827
             unset($arguments['answer']);
828 828
             if (!answer::isAnswered()) {
829
-                return answer::init($action,$arguments);
829
+                return answer::init($action, $arguments);
830 830
             }
831
-            logger::write('you can use answer mode only once for each webhook update, Others will be called like normal',loggerTypes::WARNING);
831
+            logger::write('you can use answer mode only once for each webhook update, Others will be called like normal', loggerTypes::WARNING);
832 832
         }
833
-        $result = curl::init($action,$arguments);
833
+        $result = curl::init($action, $arguments);
834 834
         if (!is_object($result)) {
835
-            logger::write("Telegram $action method failed : " . $result, loggerTypes::WARNING);
835
+            logger::write("Telegram $action method failed : ".$result, loggerTypes::WARNING);
836 836
             return false;
837 837
         }
838
-        return self::processResponse($action,$result);
838
+        return self::processResponse($action, $result);
839 839
     }
840 840
 
841 841
     private static function checkArguments(array &$arguments): void {
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
         }
845 845
     }
846 846
 
847
-    private static function keysName (string $name, array &$arguments): void {
847
+    private static function keysName(string $name, array &$arguments): void {
848 848
         foreach ($arguments as $key => $argument) {
849 849
             if (is_numeric($key) && isset(self::METHODS_KEYS[$name][$key])) {
850 850
                 $arguments[self::METHODS_KEYS[$name][$key]] = $argument;
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
         }
854 854
     }
855 855
 
856
-    private static function methodAction(string $name): string|false {
856
+    private static function methodAction(string $name): string | false {
857 857
         return self::METHODS_ACTION[str_replace('_', '', strtolower($name))] ?? false;
858 858
     }
859 859
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
         }
887 887
     }
888 888
 
889
-    private static function methodFile(string $name): array|false {
889
+    private static function methodFile(string $name): array | false {
890 890
         return self::METHODS_WITH_FILE[$name] ?? false;
891 891
     }
892 892
 
893
-    private static function methodReturn(string $name,stdClass $response) {
893
+    private static function methodReturn(string $name, stdClass $response) {
894 894
         if (!isset(self::METHODS_RETURN[$name])) {
895 895
             return $response->result;
896 896
         }
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
         $defaults = self::METHODS_EXTRA_DEFAULTS[$name];
910 910
         foreach ($defaults as $key => $default) {
911 911
             if (is_numeric($key)) {
912
-                if (!isset($arguments[$default])){
912
+                if (!isset($arguments[$default])) {
913 913
                     $arguments[$default] = self::catchFields($default);
914 914
                 }
915 915
             }
916 916
             elseif (isset(BPT::$update->$key) || $key === 'other') {
917 917
                 foreach ($default as $def) {
918
-                    if (!isset($arguments[$def])){
918
+                    if (!isset($arguments[$def])) {
919 919
                         $arguments[$def] = self::catchFields($def);
920 920
                     }
921 921
                 }
@@ -934,13 +934,13 @@  discard block
 block discarded – undo
934 934
         self::$status = $response->ok;
935 935
         self::$pure_response = $response;
936 936
         if (!$response->ok) {
937
-            logger::write("Telegram $name method failed : " . json_encode($response), loggerTypes::WARNING);
937
+            logger::write("Telegram $name method failed : ".json_encode($response), loggerTypes::WARNING);
938 938
             return new responseError($response);
939 939
         }
940
-        return self::methodReturn($name,$response);
940
+        return self::methodReturn($name, $response);
941 941
     }
942 942
 
943
-    private static function cleanArguments (array &$arguments): void {
943
+    private static function cleanArguments(array &$arguments): void {
944 944
         foreach ($arguments as $key => $argument) {
945 945
             if ($argument == [] || $argument === null) {
946 946
                 unset($arguments[$key]);
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
      *
956 956
      * @return int|string|bool
957 957
      */
958
-    public static function catchFields (string $field): int|string|bool {
958
+    public static function catchFields(string $field): int | string | bool {
959 959
         switch ($field) {
960 960
             case fields::CHAT_ID :
961 961
             case fields::FROM_CHAT_ID :
@@ -1102,13 +1102,13 @@  discard block
 block discarded – undo
1102 1102
                     default => false
1103 1103
                 };
1104 1104
             case fields::URL :
1105
-                return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
1105
+                return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
1106 1106
             default:
1107 1107
                 return false;
1108 1108
         }
1109 1109
     }
1110 1110
 
1111
-    public static function fileLink (string|null $file_id = null): bool|string {
1111
+    public static function fileLink(string | null $file_id = null): bool | string {
1112 1112
         $file = request::getFile($file_id);
1113 1113
         if (!isset($file->file_path)) {
1114 1114
             return false;
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
      *
1131 1131
      * @return bool
1132 1132
      */
1133
-    public static function downloadFile (string|null $destination = null, string|null $file_id = null): bool {
1133
+    public static function downloadFile(string | null $destination = null, string | null $file_id = null): bool {
1134 1134
         return tools::downloadFile(self::fileLink($file_id), $destination);
1135 1135
     }
1136 1136
 
@@ -1148,10 +1148,10 @@  discard block
 block discarded – undo
1148 1148
      *
1149 1149
      * @return message|bool|responseError
1150 1150
      */
1151
-    public static function sendFile (string $file_id, int|string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup|replyKeyboardMarkup|replyKeyboardRemove|forceReply|stdClass|array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message|bool|responseError {
1151
+    public static function sendFile(string $file_id, int | string $chat_id = null, int $message_thread_id = null, string $caption = null, string $parse_mode = null, array $caption_entities = null, bool $disable_notification = null, bool $protect_content = null, int $reply_to_message_id = null, bool $allow_sending_without_reply = null, inlineKeyboardMarkup | replyKeyboardMarkup | replyKeyboardRemove | forceReply | stdClass | array $reply_markup = null, string $token = null, bool $forgot = null, bool $answer = null): message | bool | responseError {
1152 1152
         $type = tools::fileType($file_id);
1153 1153
         return match ($type) {
1154
-            fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false,null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer),
1154
+            fileTypes::VIDEO => request::sendVideo($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer),
1155 1155
             fileTypes::VIDEO_NOTE => request::sendVideoNote($file_id, $chat_id, $message_thread_id, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer),
1156 1156
             fileTypes::ANIMATION => request::sendAnimation($file_id, $chat_id, $message_thread_id, null, null, null, null, $caption, $parse_mode, $caption_entities, false, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer),
1157 1157
             fileTypes::AUDIO => request::sendAudio($file_id, $chat_id, $message_thread_id, $caption, $parse_mode, $caption_entities, null, null, null, null, $disable_notification, $protect_content, $reply_to_message_id, $allow_sending_without_reply, $reply_markup, $token, $forgot, $answer),
Please login to merge, or discard this patch.
src/BPT.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
  * @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.
291 291
  * @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.
292 292
  */
293
-class BPT extends telegram{
293
+class BPT extends telegram {
294 294
     public static update $update;
295 295
 
296 296
     public static BPT $handler;
297 297
 
298 298
 
299
-    public function __construct (array|stdClass $settings) {
299
+    public function __construct(array | stdClass $settings) {
300 300
         static::$handler = &$this;
301 301
         settings::init($settings);
302 302
     }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     #[NoReturn]
309
-    public static function exit (string|null $message = null) {
309
+    public static function exit (string | null $message = null) {
310 310
         die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>");
311 311
     }
312 312
 }
Please login to merge, or discard this patch.
src/database/mysql.php 1 patch
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,19 +454,19 @@  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
         }
468 468
         else {
469
-            $query .= ' `' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` ';
469
+            $query .= ' `'.(is_string($columns) ? $columns : implode('`,`', $columns)).'` ';
470 470
         }
471 471
     }
472 472
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
      *
483 483
      * @return bool
484 484
      */
485
-    public static function delete (string $table, array $where = null, int $count = null, int $offset = null): bool {
485
+    public static function delete(string $table, array $where = null, int $count = null, int $offset = null): bool {
486 486
         $query = "DELETE FROM `$table`";
487 487
         $vars = self::whereBuilder($query, $where);
488 488
         return self::query($query, $vars, false);
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
      *
502 502
      * @return bool
503 503
      */
504
-    public static function update (string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool {
504
+    public static function update(string $table, array $modify, array $where = null, int $count = null, int $offset = null): bool {
505 505
         $query = "UPDATE `$table` SET";
506 506
         $modify_vars = self::updateBuilder($query, $modify);
507 507
         $where_vars = self::whereBuilder($query, $where);
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
      *
521 521
      * @return bool
522 522
      */
523
-    public static function insert (string $table, string|array $columns, array|string $values): bool {
523
+    public static function insert(string $table, string | array $columns, array | string $values): bool {
524 524
         $query = "INSERT INTO `$table`";
525 525
         $values = self::insertBuilder($query, $columns, $values);
526 526
         return self::query($query, $values, false);
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
      *
544 544
      * @return mysqli_result|bool
545 545
      */
546
-    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 {
546
+    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 {
547 547
         $query = "SELECT";
548 548
         self::selectBuilder($query, $columns);
549 549
         $query .= "FROM `$table`";
550
-        $var = self::whereBuilder($query,$where);
550
+        $var = self::whereBuilder($query, $where);
551 551
         self::groupByBuilder($query, $group_by);
552 552
         self::orderByBuilder($query, $order_by);
553
-        self::countBuilder($query,$count,$offset);
553
+        self::countBuilder($query, $count, $offset);
554 554
         return self::query($query, $var);
555 555
     }
556 556
 
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
      *
568 568
      * @return null|bool|array
569 569
      */
570
-    public static function selectArray (string $table, array|string $columns = '*', array $where = null, array|string $group_by = [], array|string $order_by = []): bool|array|null {
570
+    public static function selectArray(string $table, array | string $columns = '*', array $where = null, array | string $group_by = [], array | string $order_by = []): bool | array | null {
571 571
         $res = self::select($table, $columns, $where, 1, $group_by, $order_by);
572 572
         if ($res) {
573 573
             return $res->fetch_assoc();
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
      * @param array|string $group_by group result based on these columns
587 587
      * @param array|string $order_by order result based on these columns
588 588
      */
589
-    public static function selectObject (string $table, array|string $columns = '*', array $where = null, array|string $group_by = [], array|string $order_by = []) {
589
+    public static function selectObject(string $table, array | string $columns = '*', array $where = null, array | string $group_by = [], array | string $order_by = []) {
590 590
         $res = self::select($table, $columns, $where, 1, $group_by, $order_by);
591 591
         if ($res) {
592 592
             return $res->fetch_object();
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
      *
611 611
      * @return bool|Generator
612 612
      */
613
-    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 {
613
+    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 {
614 614
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by);
615 615
         if ($res) {
616 616
             while ($row = $res->fetch_assoc()) yield $row;
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
      *
629 629
      * @return string if save is true , return file name otherwise return sql data
630 630
      */
631
-    public static function backup (array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string {
631
+    public static function backup(array $wanted_tables = null, bool $table_data = true, bool $save = true, string $file_name = ''): string {
632 632
         self::setCharset('utf8mb4');
633 633
 
634
-        $tables = array_column(self::query('SHOW TABLES')->fetch_all(),0);
634
+        $tables = array_column(self::query('SHOW TABLES')->fetch_all(), 0);
635 635
         if (!empty($wanted_tables)) {
636 636
             $tables = array_intersect($tables, $wanted_tables);
637 637
         }
@@ -642,12 +642,12 @@  discard block
 block discarded – undo
642 642
             logger::write('No table founded for backup, if your database has table : check $wanted_tables argument', loggerTypes::WARNING);
643 643
         }
644 644
         foreach ($tables as $table) {
645
-            $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1] . ";\n\n";
645
+            $sql .= self::query("SHOW CREATE TABLE `$table`")->fetch_row()[1].";\n\n";
646 646
             if ($table_data) {
647 647
                 $total_rows = self::query("SELECT COUNT(*) as `cnt` FROM `$table`")->fetch_object()->cnt;
648 648
                 for ($i = 0; $i < $total_rows; $i = $i + 1000) {
649
-                    $sql .= "INSERT INTO " . $table . " VALUES";
650
-                    $result = self::select($table, '*' , null, 1000, $i);
649
+                    $sql .= "INSERT INTO ".$table." VALUES";
650
+                    $result = self::select($table, '*', null, 1000, $i);
651 651
                     $field_count = $result->field_count;
652 652
                     $affected_rows = self::affected_rows();
653 653
                     $counter = 1;
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
                         $sql .= "\n(";
656 656
                         for ($column = 0; $column < $field_count; $column++) {
657 657
                             $row[$column] = str_replace("\n", "\\n", addslashes($row[$column]));
658
-                            $sql .= !empty($row[$column]) ? '"' . $row[$column] . '"' : '""';
658
+                            $sql .= !empty($row[$column]) ? '"'.$row[$column].'"' : '""';
659 659
                             if ($column < $field_count - 1) {
660 660
                                 $sql .= ',';
661 661
                             }
662 662
                         }
663
-                        $sql .= ')' . ($counter == $affected_rows ? ';' : ',');
663
+                        $sql .= ')'.($counter == $affected_rows ? ';' : ',');
664 664
                         $counter++;
665 665
                     }
666 666
                 }
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
         }
677 677
 
678 678
         if (empty($file_name)) {
679
-            $file_name = self::$db_name . time() . '.sql';
679
+            $file_name = self::$db_name.time().'.sql';
680 680
         }
681 681
         file_put_contents($file_name, $sql);
682 682
         return $file_name;
Please login to merge, or discard this patch.