Passed
Push — main ( 41e5bc...ca9ae3 )
by Miaad
01:45
created
src/pay/pay.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 use BPT\settings;
6 6
 
7 7
 class pay {
8
-    public static function init (): void {
8
+    public static function init(): void {
9 9
         if (isset(settings::$pay['crypto'])) {
10 10
             crypto::init();
11 11
         }
Please login to merge, or discard this patch.
src/pay/crypto.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     private static CurlHandle $session;
23 23
 
24
-    public static function init (string $api_key = '', string $ipn_secret = ''): void {
24
+    public static function init(string $api_key = '', string $ipn_secret = ''): void {
25 25
         self::$api_key = settings::$pay['crypto']['api_key'] ?? $api_key;
26 26
         self::$ipn_secret = settings::$pay['crypto']['ipn_secret'] ?? $ipn_secret;
27 27
         self::$session = curl_init();
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
         curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1);
30 30
         curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2);
31 31
         curl_setopt(self::$session, CURLOPT_HTTPHEADER, [
32
-            'X-API-KEY: ' . self::$api_key,
32
+            'X-API-KEY: '.self::$api_key,
33 33
             'Content-Type: application/json'
34 34
         ]);
35 35
     }
36 36
 
37
-    private static function execute (string $method, string $endpoint, string|array $data = '') {
37
+    private static function execute(string $method, string $endpoint, string | array $data = '') {
38 38
         if (is_array($data)) {
39 39
             foreach ($data as $key => $value) {
40 40
                 if (empty($value)) {
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 
48 48
         switch ($method) {
49 49
             case 'GET':
50
-                curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint . !empty($data) && is_array($data) ? ('?' . http_build_query($data)) : '');
50
+                curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint.!empty($data) && is_array($data) ? ('?'.http_build_query($data)) : '');
51 51
                 break;
52 52
             case 'POST':
53 53
                 curl_setopt($session, CURLOPT_POST, true);
54 54
                 curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($data));
55
-                curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint);
55
+                curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint);
56 56
                 break;
57 57
             default:
58 58
                 return false;
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
         return json_decode(curl_exec($session));
61 61
     }
62 62
 
63
-    public static function status (): bool {
63
+    public static function status(): bool {
64 64
         return self::execute('GET', 'status')->message === 'OK';
65 65
     }
66 66
 
67 67
     /**
68 68
      * @return estimatePriceInterface|mixed
69 69
      */
70
-    public static function getEstimatePrice (int|float $amount, string $currency_from, string $currency_to) {
70
+    public static function getEstimatePrice(int | float $amount, string $currency_from, string $currency_to) {
71 71
         return self::execute('GET', 'estimate', [
72 72
             'amount'        => $amount,
73 73
             'currency_from' => $currency_from,
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     /**
79 79
      * @return invoicePaymentInterface|mixed
80 80
      */
81
-    public static function createPayment (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) {
81
+    public static function createPayment(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $purchase_id = null, string $payout_address = null, string $payout_currency = null, string $payout_extra_id = null, bool $fixed_rate = null) {
82 82
         return self::execute('POST', 'payment', [
83 83
             'price_amount'      => $price_amount,
84 84
             'price_currency'    => $price_currency,
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     /**
99 99
      * @return invoicePaymentInterface|mixed
100 100
      */
101
-    public static function createInvoicePayment (string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) {
101
+    public static function createInvoicePayment(string $iid, string $pay_currency, string $purchase_id = null, string $order_description = null, string $customer_email = null, string $payout_address = null, string $payout_extra_id = null, string $payout_currency = null) {
102 102
         return self::execute('POST', 'invoice', [
103 103
             'iid'               => $iid,
104 104
             'pay_currency'      => $pay_currency,
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
     /**
115 115
      * @return estimateUpdateInterface|mixed
116 116
      */
117
-    public static function updateEstimatePrice (int $paymentID) {
118
-        return self::execute('POST', 'payment/' . $paymentID . '/update-merchant-estimate');
117
+    public static function updateEstimatePrice(int $paymentID) {
118
+        return self::execute('POST', 'payment/'.$paymentID.'/update-merchant-estimate');
119 119
     }
120 120
 
121 121
     /**
122 122
      * @return paymentInterface|mixed
123 123
      */
124
-    public static function getPaymentStatus (int $paymentID) {
125
-        return self::execute('GET', 'payment/' . $paymentID);
124
+    public static function getPaymentStatus(int $paymentID) {
125
+        return self::execute('GET', 'payment/'.$paymentID);
126 126
     }
127 127
 
128
-    public static function getMinimumPaymentAmount (string $currency_from, string $currency_to): float {
128
+    public static function getMinimumPaymentAmount(string $currency_from, string $currency_to): float {
129 129
         return self::execute('GET', 'min-amount', [
130 130
             'currency_from' => $currency_from,
131 131
             'currency_to'   => $currency_to
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     /**
136 136
      * @return invoiceResponseInterface|mixed
137 137
      */
138
-    public static function createInvoice (int|float $price_amount, string $price_currency, string $pay_currency, int|float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) {
138
+    public static function createInvoice(int | float $price_amount, string $price_currency, string $pay_currency, int | float $pay_amount = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) {
139 139
         return self::execute('POST', 'invoice', [
140 140
             'price_amount'      => $price_amount,
141 141
             'price_currency'    => $price_currency,
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
         ]);
150 150
     }
151 151
 
152
-    public static function getCurrencies (): array {
152
+    public static function getCurrencies(): array {
153 153
         return self::execute('GET', 'currencies')->currencies;
154 154
     }
155 155
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         return tools::remoteIP() === '144.76.201.30';
158 158
     }
159 159
 
160
-    public static function isIPNRequestValid (): bool {
160
+    public static function isIPNRequestValid(): bool {
161 161
         if (empty($_SERVER['HTTP_X_NOWPAYMENTS_SIG'])) {
162 162
             return false;
163 163
         }
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     /**
178 178
      * @return ipnDataInterface|mixed
179 179
      */
180
-    public static function getIPN () {
180
+    public static function getIPN() {
181 181
         if (!self::isIPNRequestValid()) {
182 182
             return false;
183 183
         }
Please login to merge, or discard this patch.
src/pay/idpay.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,20 +16,20 @@  discard block
 block discarded – undo
16 16
 
17 17
     private static CurlHandle $session;
18 18
 
19
-    public static function init (string $api_key = '', bool $sandbox = false): void {
19
+    public static function init(string $api_key = '', bool $sandbox = false): void {
20 20
         self::$session = curl_init();
21 21
         curl_setopt(self::$session, CURLOPT_RETURNTRANSFER, true);
22 22
         curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1);
23 23
         curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2);
24 24
         curl_setopt(self::$session, CURLOPT_HTTPHEADER, [
25 25
             'Content-Type: application/json',
26
-            'X-API-KEY: ' . settings::$pay['idpay']['api_key'] ?? $api_key,
27
-            'X-SANDBOX: ' . (int) (settings::$pay['idpay']['sandbox'] ?? $sandbox),
26
+            'X-API-KEY: '.settings::$pay['idpay']['api_key'] ?? $api_key,
27
+            'X-SANDBOX: '.(int) (settings::$pay['idpay']['sandbox'] ?? $sandbox),
28 28
         ]);
29 29
         curl_setopt(self::$session, CURLOPT_POST, true);
30 30
     }
31 31
 
32
-    private static function execute (string $endpoint, array $params) {
32
+    private static function execute(string $endpoint, array $params) {
33 33
         foreach ($params as $key => $value) {
34 34
             if (empty($value)) {
35 35
                 unset($params[$key]);
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $session = self::$session;
40 40
 
41 41
         curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($params));
42
-        curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint);
42
+        curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint);
43 43
 
44 44
         return json_decode(curl_exec($session));
45 45
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * @return paymentCreateInterface|errorInterface|object|bool
49 49
      */
50
-    public static function createPayment (string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object|bool {
50
+    public static function createPayment(string $order_id, int $amount, string $name = '', string $phone = '', string $mail = '', string $desc = '', string $callback = ''): object | bool {
51 51
         return self::execute('payment', [
52 52
             'order_id' => $order_id,
53 53
             'amount'   => $amount,
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     /**
63 63
      * @return paymentInterface|errorInterface|object|bool
64 64
      */
65
-    public static function paymentDetail (string $id, string $order_id): object {
65
+    public static function paymentDetail(string $id, string $order_id): object {
66 66
         return self::execute('payment/inquiry', [
67 67
             'order_id' => $order_id,
68 68
             'id'       => $id
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * @return paymentInterface|errorInterface|object|bool
74 74
      */
75
-    public static function paymentConfirm (string $id, string $order_id): object {
75
+    public static function paymentConfirm(string $id, string $order_id): object {
76 76
         return self::execute('payment/verify', [
77 77
             'order_id' => $order_id,
78 78
             'id'       => $id
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * @return paymentListInterface|errorInterface|object|bool
84 84
      */
85
-    public static function paymentList (int $page = 0, int $page_size = 25): object {
85
+    public static function paymentList(int $page = 0, int $page_size = 25): object {
86 86
         return self::execute('payment/transactions', [
87 87
             'page'      => $page,
88 88
             'page_size' => $page_size
89 89
         ]);
90 90
     }
91 91
 
92
-    public static function processCallback (): bool|int {
92
+    public static function processCallback(): bool | int {
93 93
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
94 94
             $response = $_POST;
95 95
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,11 +92,9 @@
 block discarded – undo
92 92
     public static function processCallback (): bool|int {
93 93
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
94 94
             $response = $_POST;
95
-        }
96
-        elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
95
+        } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
97 96
             $response = $_GET;
98
-        }
99
-        else {
97
+        } else {
100 98
             return false;
101 99
         }
102 100
 
Please login to merge, or discard this patch.
src/pay/zarinpal.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     private static CurlHandle $session;
27 27
 
28
-    public static function init (string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void {
28
+    public static function init(string $merchant_id = '', bool $sandbox = false, bool $zarin_gate = false): void {
29 29
         self::$sandbox = settings::$pay['zarinpal']['sandbox'] ?? $sandbox;
30 30
         self::$zarin_gate = settings::$pay['zarinpal']['zarin_gate'] ?? settings::$pay['zarinpal']['zaringate'] ?? $zarin_gate;
31 31
         self::$merchant_id = settings::$pay['zarinpal']['merchant_id'] ?? $merchant_id;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         curl_setopt(self::$session, CURLOPT_POST, true);
41 41
     }
42 42
 
43
-    private static function getUrl (string $endpoint, bool $pay = false): string {
43
+    private static function getUrl(string $endpoint, bool $pay = false): string {
44 44
         if ($pay) {
45 45
             $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE;
46 46
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         return $url;
55 55
     }
56 56
 
57
-    private static function execute (string $endpoint, array $params = []): object {
57
+    private static function execute(string $endpoint, array $params = []): object {
58 58
         foreach ($params as $key => $value) {
59 59
             if (empty($value)) {
60 60
                 unset($params[$key]);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     /**
89 89
      * @return object|requestInterface
90 90
      */
91
-    public static function request (int $amount, string $description, string $callback_url, array $metadata = [], string $mobile = '', string $email = '', array $wages = [], int $card_pan = null, string $currency = ''): object {
91
+    public static function request(int $amount, string $description, string $callback_url, array $metadata = [], string $mobile = '', string $email = '', array $wages = [], int $card_pan = null, string $currency = ''): object {
92 92
         return self::execute('/request.json', [
93 93
             'amount'       => $amount,
94 94
             'description'  => $description,
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         ]);
103 103
     }
104 104
 
105
-    public static function payURL (string|array $authority): bool|string {
105
+    public static function payURL(string | array $authority): bool | string {
106 106
         if (is_array($authority)) {
107 107
             if (!isset($authority->authority)) {
108 108
                 return false;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     /**
116 116
      * @return object|verifyInterface
117 117
      */
118
-    public static function verify (int $amount, string $authority): object {
118
+    public static function verify(int $amount, string $authority): object {
119 119
         return self::execute('/verify.json', [
120 120
             'amount'    => $amount,
121 121
             'authority' => $authority
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
     /**
126 126
      * @return object|unverifiedInterface
127 127
      */
128
-    public static function unVerified (): object {
128
+    public static function unVerified(): object {
129 129
         return self::execute('/unVerified.json');
130 130
     }
131 131
 
132 132
     /**
133 133
      * @return object|refundInterface
134 134
      */
135
-    public static function refund (string $authorization, string $authority): object {
135
+    public static function refund(string $authorization, string $authority): object {
136 136
         return self::execute('/refund.json', [
137 137
             'authorization' => $authorization,
138 138
             'authority'     => $authority
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
     #[NoReturn]
143
-    public static function redirect (string $url): void {
144
-        @header('Location: ' . $url);
143
+    public static function redirect(string $url): void {
144
+        @header('Location: '.$url);
145 145
         die("<meta http-equiv='refresh' content='0; url=$url' /><script>window.location.href = '$url';</script>");
146 146
     }
147 147
 
148
-    public static function processCallback (int $amount): object|bool|int {
148
+    public static function processCallback(int $amount): object | bool | int {
149 149
         if (!isset($_GET['Authority']) || !isset($_GET['Status'])) {
150 150
             return false;
151 151
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,7 @@
 block discarded – undo
43 43
     private static function getUrl (string $endpoint, bool $pay = false): string {
44 44
         if ($pay) {
45 45
             $url = self::$sandbox ? self::SANDBOX_PAY_BASE : self::PAY_BASE;
46
-        }
47
-        else {
46
+        } else {
48 47
             $url = self::$sandbox ? self::SANDBOX_API_BASE : self::API_BASE;
49 48
         }
50 49
         $url .= $endpoint;
Please login to merge, or discard this patch.
src/database/mysql.php 2 patches
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
 
@@ -375,8 +367,7 @@  discard block
 block discarded – undo
375 367
         foreach ($order_by as $key => $mode) {
376 368
             if ($first) {
377 369
                 $first = false;
378
-            }
379
-            else {
370
+            } else {
380 371
                 $query .= ', ';
381 372
             }
382 373
             if (is_numeric($key)) {
@@ -390,8 +381,7 @@  discard block
 block discarded – undo
390 381
     private static function countBuilder(string &$query, int $count = null, int $offset = null): void {
391 382
         if (!empty($count)) {
392 383
             $query .= !empty($offset) ? " LIMIT $offset,$count" : " LIMIT $count";
393
-        }
394
-        elseif (!empty($offset)) {
384
+        } elseif (!empty($offset)) {
395 385
             $query .= " OFFSET $offset";
396 386
         }
397 387
     }
@@ -403,8 +393,7 @@  discard block
 block discarded – undo
403 393
         foreach ($modify as $name => $value) {
404 394
             if ($first) {
405 395
                 $first = false;
406
-            }
407
-            else {
396
+            } else {
408 397
                 $query .= ' ,';
409 398
             }
410 399
 
@@ -444,7 +433,9 @@  discard block
 block discarded – undo
444 433
 
445 434
     private static function insertBuilder(string &$query, string|array $columns, array|string $values): array {
446 435
         $query .= '(`' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '`) VALUES (';
447
-        if (is_string($values)) $values = [$values];
436
+        if (is_string($values)) {
437
+            $values = [$values];
438
+        }
448 439
         $query .= '?' . str_repeat(',?', count($values) - 1) . ')';
449 440
         return $values;
450 441
     }
@@ -452,8 +443,7 @@  discard block
 block discarded – undo
452 443
     private static function selectBuilder(string &$query, string|array $columns): void {
453 444
         if ($columns == '*') {
454 445
             $query .= " * ";
455
-        }
456
-        else {
446
+        } else {
457 447
             $query .= ' `' . (is_string($columns) ? $columns : implode('`,`', $columns)) . '` ';
458 448
         }
459 449
     }
@@ -601,9 +591,12 @@  discard block
 block discarded – undo
601 591
     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 {
602 592
         $res = self::select($table, $columns, $where, $count, $offset, $group_by, $order_by);
603 593
         if ($res) {
604
-            while ($row = $res->fetch_assoc()) yield $row;
594
+            while ($row = $res->fetch_assoc()) {
595
+                yield $row;
596
+            }
597
+        } else {
598
+            return $res;
605 599
         }
606
-        else return $res;
607 600
     }
608 601
 
609 602
     /**
Please login to merge, or discard this 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, 0, $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, 0, $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.
src/tools.php 2 patches
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 /**
30 30
  * tools class , gather what ever you need
31 31
  */
32
-class tools{
32
+class tools {
33 33
     /**
34 34
      * Check the given username format
35 35
      *
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      *
42 42
      * @return bool
43 43
      */
44
-    public static function isUsername (string $username): bool {
44
+    public static function isUsername(string $username): bool {
45 45
         $length = strlen($username);
46 46
         return !str_contains($username, '__') && $length >= 4 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username);
47 47
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @return bool
60 60
      */
61
-    public static function ipInRange (string $ip, string $range): bool {
61
+    public static function ipInRange(string $ip, string $range): bool {
62 62
         if (!str_contains($range, '/')) {
63 63
             $range .= '/32';
64 64
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      *
79 79
      * @return bool
80 80
      */
81
-    public static function isTelegram (string $ip): bool {
81
+    public static function isTelegram(string $ip): bool {
82 82
         return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22');
83 83
     }
84 84
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      *
94 94
      * @return bool
95 95
      */
96
-    public static function isCloudFlare (string $ip): bool {
96
+    public static function isCloudFlare(string $ip): bool {
97 97
         $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22'];
98 98
         foreach ($cf_ips as $cf_ip) {
99
-            if (self::ipInRange($ip,$cf_ip)) {
99
+            if (self::ipInRange($ip, $cf_ip)) {
100 100
                 return true;
101 101
             }
102 102
         }
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
      *
115 115
      * @return bool
116 116
      */
117
-    public static function isArvanCloud (string $ip): bool {
117
+    public static function isArvanCloud(string $ip): bool {
118 118
         $ar_ips = ['185.143.232.0/22', '92.114.16.80/28', '2.146.0.0/28', '46.224.2.32/29', '89.187.178.96/29', '195.181.173.128/29', '89.187.169.88/29', '188.229.116.16/29', '83.123.255.56/31', '164.138.128.28/31', '94.182.182.28/30', '185.17.115.176/30', '5.213.255.36/31', '138.128.139.144/29', '5.200.14.8/29', '188.122.68.224/29', '188.122.83.176/29', '213.179.217.16/29', '185.179.201.192/29', '43.239.139.192/29', '213.179.197.16/29', '213.179.201.192/29', '109.200.214.248/29', '138.128.141.16/29', '188.122.78.136/29', '213.179.211.32/29', '103.194.164.24/29', '185.50.105.136/29', '213.179.213.16/29', '162.244.52.120/29', '188.122.80.240/29', '109.200.195.64/29', '109.200.199.224/29', '185.228.238.0/28', '94.182.153.24/29', '94.101.182.0/27', '37.152.184.208/28', '78.39.156.192/28', '158.255.77.238/31', '81.12.28.16/29', '176.65.192.202/31', '2.144.3.128/28', '89.45.48.64/28', '37.32.16.0/27', '37.32.17.0/27', '37.32.18.0/27'];
119 119
         foreach ($ar_ips as $ar_ip) {
120
-            if (self::ipInRange($ip,$ar_ip)) {
120
+            if (self::ipInRange($ip, $ar_ip)) {
121 121
                 return true;
122 122
             }
123 123
         }
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
      *
138 138
      * @return bool|user return array when verify is active and token is true array of telegram getMe result
139 139
      */
140
-    public static function isToken (string $token, bool $verify = false): bool|user {
140
+    public static function isToken(string $token, bool $verify = false): bool | user {
141 141
         if (!preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
142 142
             return false;
143 143
         }
144
-        if (!$verify){
144
+        if (!$verify) {
145 145
             return true;
146 146
         }
147 147
         $res = telegram::me($token);
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
      *
172 172
      * @return bool
173 173
      */
174
-    public static function isJoined (array|string|int $ids , int|null $user_id = null): bool {
174
+    public static function isJoined(array | string | int $ids, int | null $user_id = null): bool {
175 175
         if (!is_array($ids)) {
176 176
             $ids = [$ids];
177 177
         }
178 178
         $user_id = $user_id ?? request::catchFields('user_id');
179 179
 
180 180
         foreach ($ids as $id) {
181
-            $check = telegram::getChatMember($id,$user_id);
181
+            $check = telegram::getChatMember($id, $user_id);
182 182
             if (telegram::$status) {
183 183
                 $check = $check->status;
184 184
                 if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) {
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      *
206 206
      * @return array keys will be id and values will be bool(null for not founded ids)
207 207
      */
208
-    public static function joinChecker (array|string|int $ids , int|null $user_id = null): array {
208
+    public static function joinChecker(array | string | int $ids, int | null $user_id = null): array {
209 209
         if (!is_array($ids)) {
210 210
             $ids = [$ids];
211 211
         }
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
         $result = [];
215 215
         foreach ($ids as $id) {
216
-            $check = telegram::getChatMember($id,$user_id);
216
+            $check = telegram::getChatMember($id, $user_id);
217 217
             if (telegram::$status) {
218 218
                 $check = $check->status;
219 219
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
      * @return bool
234 234
      */
235 235
     public static function isShorted(string $text): bool{
236
-        return preg_match('/^[a-zA-Z0-9]+$/',$text);
236
+        return preg_match('/^[a-zA-Z0-9]+$/', $text);
237 237
     }
238 238
 
239 239
     /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
253 253
      */
254
-    public static function size (string $path, bool $format = true, bool $space_between = true): string|int|false {
254
+    public static function size(string $path, bool $format = true, bool $space_between = true): string | int | false {
255 255
         if (filter_var($path, FILTER_VALIDATE_URL)) {
256 256
             $ch = curl_init($path);
257 257
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             $size = file_exists($path) ? filesize($path) : false;
267 267
         }
268 268
         if (isset($size) && is_numeric($size)) {
269
-            return $format ? tools::byteFormat($size, space_between: $space_between) : $size;
269
+            return $format ? tools::byteFormat($size, space_between : $space_between) : $size;
270 270
         }
271 271
         return false;
272 272
     }
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      * @return bool
285 285
      * @throws bptException
286 286
      */
287
-    public static function delete (string $path, bool $sub = true): bool {
287
+    public static function delete(string $path, bool $sub = true): bool {
288 288
         $path = realpath($path);
289 289
         if (!is_dir($path)) {
290 290
             return unlink($path);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
             return rmdir($path);
294 294
         }
295 295
         if (!$sub) {
296
-            logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
296
+            logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR);
297 297
             throw new bptException('DELETE_FOLDER_HAS_SUB');
298 298
         }
299 299
         $it = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      * @return bool
316 316
      * @throws bptException when zip extension not found
317 317
      */
318
-    public static function zip (string $path, string $destination): bool {
318
+    public static function zip(string $path, string $destination): bool {
319 319
         if (!extension_loaded('zip')) {
320 320
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
321 321
             throw new bptException('ZIP_EXTENSION_MISSING');
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
      *
351 351
      * @return bool true on success and false in failure
352 352
      */
353
-    public static function downloadFile (string $url, string $path, int $chunk_size = 512): bool {
353
+    public static function downloadFile(string $url, string $path, int $chunk_size = 512): bool {
354 354
         $file = fopen($url, 'rb');
355 355
         if (!$file) return false;
356 356
         $path = fopen($path, 'wb');
357 357
         if (!$path) return false;
358 358
 
359 359
         $length = $chunk_size * 1024;
360
-        while (!feof($file)){
360
+        while (!feof($file)) {
361 361
             fwrite($path, fread($file, $length), $length);
362 362
         }
363 363
         fclose($path);
@@ -380,10 +380,10 @@  discard block
 block discarded – undo
380 380
      *
381 381
      * @return string
382 382
      */
383
-    public static function byteFormat (int $byte, int $precision = 2, bool $space_between = true): string {
383
+    public static function byteFormat(int $byte, int $precision = 2, bool $space_between = true): string {
384 384
         $rate_counter = 0;
385 385
 
386
-        while ($byte > 1024){
386
+        while ($byte > 1024) {
387 387
             $byte /= 1024;
388 388
             $rate_counter++;
389 389
         }
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
             $byte = round($byte, $precision);
393 393
         }
394 394
 
395
-        return $byte . ($space_between ? ' ' : '') . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
395
+        return $byte.($space_between ? ' ' : '').['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
396 396
     }
397 397
 
398 398
     /**
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
      *
410 410
      * @return string|false return false when mode is incorrect
411 411
      */
412
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
412
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
413 413
         return match ($mode) {
414
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
415
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
414
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
415
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
416 416
             parseMode::MARKDOWNV2 => str_replace(
417 417
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
418 418
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
      * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string}
452 452
      * @throws Exception
453 453
      */
454
-    public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array {
454
+    public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array {
455 455
         $base_time = new DateTime($base_time ?? '@'.time());
456
-        $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00');
456
+        $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00');
457 457
 
458 458
         $diff = $base_time->diff($target_time);
459 459
 
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
      *
481 481
      * @return string[]|string
482 482
      */
483
-    public static function realEscapeString(string|array $input): string|array {
484
-        if(is_array($input)) {
483
+    public static function realEscapeString(string | array $input): string | array {
484
+        if (is_array($input)) {
485 485
             return array_map(__METHOD__, $input);
486 486
         }
487 487
 
488
-        if(!empty($input) && is_string($input)) {
488
+        if (!empty($input) && is_string($input)) {
489 489
             return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input);
490 490
         }
491 491
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      *
504 504
      * @return string[]|string
505 505
      */
506
-    public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array {
506
+    public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array {
507 507
         $pos = strpos($subject, $search);
508 508
         if ($pos !== false) {
509 509
             return substr_replace($subject, $replace, $pos, strlen($search));
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
      *
521 521
      * @return string see possible values in fileType class
522 522
      */
523
-    public static function fileType (string $file_id): string {
523
+    public static function fileType(string $file_id): string {
524 524
         $data = base64_decode(str_pad(strtr($file_id, '-_', '+/'), strlen($file_id) % 4, '='));
525 525
         $new = '';
526 526
         $last = '';
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
                 $last = $char;
535 535
             }
536 536
         }
537
-        $data = unpack('VtypeId/Vdc_id', $new . $last);
537
+        $data = unpack('VtypeId/Vdc_id', $new.$last);
538 538
         $data['typeId'] = $data['typeId'] & ~33554432 & ~16777216;
539 539
         return [
540 540
             fileTypes::THUMBNAIL,
@@ -572,10 +572,10 @@  discard block
 block discarded – undo
572 572
      *
573 573
      * @return string
574 574
      */
575
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
575
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
576 576
         $rand_string = '';
577 577
         $char_len = strlen($characters) - 1;
578
-        for ($i = 0; $i < $length; $i ++) {
578
+        for ($i = 0; $i < $length; $i++) {
579 579
             $rand_string .= $characters[rand(0, $char_len)];
580 580
         }
581 581
         return $rand_string;
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
      * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline
605 605
      * @throws bptException
606 606
      */
607
-    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup {
607
+    public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup {
608 608
         if (!empty($keyboard)) {
609 609
             $keyboard_object = new replyKeyboardMarkup();
610 610
             $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true);
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
             return $keyboard_object;
669 669
         }
670 670
         else {
671
-            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
671
+            logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR);
672 672
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
673 673
         }
674 674
     }
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
      *
686 686
      * @return string
687 687
      */
688
-    public static function inviteLink (int $user_id = null, string $bot_username = null): string {
688
+    public static function inviteLink(int $user_id = null, string $bot_username = null): string {
689 689
         if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
690 690
         if (empty($bot_username)) $bot_username = telegram::getMe()->username;
691
-        return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
691
+        return 'https://t.me/'.str_replace('@', '', $bot_username).'?start=ref_'.tools::shortEncode($user_id);
692 692
     }
693 693
 
694 694
     /**
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
      * @return string|bool|array{hash:string, key:string, iv:string}
713 713
      * @throws bptException
714 714
      */
715
-    public static function codec (string $action, string $text, string $key = null, string $iv = null): bool|array|string {
715
+    public static function codec(string $action, string $text, string $key = null, string $iv = null): bool | array | string {
716 716
         if (!extension_loaded('openssl')) {
717
-            logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
717
+            logger::write("tools::codec function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
718 718
             throw new bptException('OPENSSL_EXTENSION_MISSING');
719 719
         }
720 720
         if ($action === codecAction::ENCRYPT) {
@@ -725,17 +725,17 @@  discard block
 block discarded – undo
725 725
         }
726 726
         elseif ($action === codecAction::DECRYPT) {
727 727
             if (empty($key)) {
728
-                logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR);
728
+                logger::write("tools::codec function used\nkey parameter is not set", loggerTypes::ERROR);
729 729
                 throw new bptException('ARGUMENT_NOT_FOUND_KEY');
730 730
             }
731 731
             if (empty($iv)) {
732
-                logger::write("tools::codec function used\niv parameter is not set",loggerTypes::ERROR);
732
+                logger::write("tools::codec function used\niv parameter is not set", loggerTypes::ERROR);
733 733
                 throw new bptException('ARGUMENT_NOT_FOUND_IV');
734 734
             }
735 735
             return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
736 736
         }
737 737
         else {
738
-            logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
738
+            logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING);
739 739
             return false;
740 740
         }
741 741
     }
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
     public static function shortEncode(int $num): string {
753 753
         $codes = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
754 754
         $array = [];
755
-        while ($num > 0){
755
+        while ($num > 0) {
756 756
             $array[] = $num % 62;
757 757
             $num = floor($num / 62);
758 758
         }
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         foreach ($array as &$value) {
761 761
             $value = $codes[$value];
762 762
         }
763
-        return strrev(implode('',$array));
763
+        return strrev(implode('', $array));
764 764
     }
765 765
 
766 766
     /**
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
         $num = 0;
778 778
         $text = str_split(strrev($text));
779 779
         foreach ($text as $key=>$value) {
780
-            $num += strpos($codes,$value) * pow(62,$key);
780
+            $num += strpos($codes, $value) * pow(62, $key);
781 781
         }
782 782
         return $num;
783 783
     }
Please login to merge, or discard this patch.
Braces   +34 added lines, -32 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
                         }
@@ -641,8 +643,7 @@  discard block
 block discarded – undo
641 643
             }
642 644
             $keyboard_object->setKeyboard($rows);
643 645
             return $keyboard_object;
644
-        }
645
-        elseif (!empty($inline)) {
646
+        } elseif (!empty($inline)) {
646 647
             $keyboard_object = new inlineKeyboardMarkup();
647 648
             $rows = [];
648 649
             foreach ($inline as $row) {
@@ -652,12 +653,10 @@  discard block
 block discarded – undo
652 653
                     if (isset($button_info[1])) {
653 654
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
654 655
                             $button->setText($button_info[0])->setUrl($button_info[1]);
655
-                        }
656
-                        else {
656
+                        } else {
657 657
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
658 658
                         }
659
-                    }
660
-                    else {
659
+                    } else {
661 660
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
662 661
                     }
663 662
                     $buttons[] = $button;
@@ -666,8 +665,7 @@  discard block
 block discarded – undo
666 665
             }
667 666
             $keyboard_object->setInline_keyboard($rows);
668 667
             return $keyboard_object;
669
-        }
670
-        else {
668
+        } else {
671 669
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
672 670
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
673 671
         }
@@ -686,8 +684,12 @@  discard block
 block discarded – undo
686 684
      * @return string
687 685
      */
688 686
     public static function inviteLink (int $user_id = null, string $bot_username = null): string {
689
-        if (empty($user_id)) $user_id = telegram::catchFields(fields::USER_ID);
690
-        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
+        }
691 693
         return 'https://t.me/' . str_replace('@', '', $bot_username) . '?start=ref_' . tools::shortEncode($user_id);
692 694
     }
693 695
 
@@ -722,8 +724,7 @@  discard block
 block discarded – undo
722 724
             $iv = self::randomString();
723 725
             $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
724 726
             return ['hash' => $output, 'key' => $key, 'iv' => $iv];
725
-        }
726
-        elseif ($action === codecAction::DECRYPT) {
727
+        } elseif ($action === codecAction::DECRYPT) {
727 728
             if (empty($key)) {
728 729
                 logger::write("tools::codec function used\nkey parameter is not set",loggerTypes::ERROR);
729 730
                 throw new bptException('ARGUMENT_NOT_FOUND_KEY');
@@ -733,8 +734,7 @@  discard block
 block discarded – undo
733 734
                 throw new bptException('ARGUMENT_NOT_FOUND_IV');
734 735
             }
735 736
             return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
736
-        }
737
-        else {
737
+        } else {
738 738
             logger::write("tools::codec function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
739 739
             return false;
740 740
         }
@@ -756,7 +756,9 @@  discard block
 block discarded – undo
756 756
             $array[] = $num % 62;
757 757
             $num = floor($num / 62);
758 758
         }
759
-        if (count($array) < 1) $array = [0];
759
+        if (count($array) < 1) {
760
+            $array = [0];
761
+        }
760 762
         foreach ($array as &$value) {
761 763
             $value = $codes[$value];
762 764
         }
Please login to merge, or discard this patch.
src/types/videoNote.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
     public int $duration;
29 29
 
30 30
     /** Optional. Video thumbnail */
31
-    public null|photoSize $thumbnail = null;
31
+    public null | photoSize $thumbnail = null;
32 32
 
33 33
     /** Optional. File size in bytes */
34
-    public null|int $file_size = null;
34
+    public null | int $file_size = null;
35 35
 
36 36
 
37
-    public function __construct(stdClass|null $object = null) {
37
+    public function __construct(stdClass | null $object = null) {
38 38
         if ($object != null) {
39 39
             parent::__construct($object, self::subs);
40 40
         }
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return bool|string string will be returned when destination doesn't set
57 57
      */
58
-    public function download(string|null $destination = null): bool|string {
59
-        return telegram::downloadFile($destination ?? 'unknown.mp4',$this->file_id);
58
+    public function download(string | null $destination = null): bool | string {
59
+        return telegram::downloadFile($destination ?? 'unknown.mp4', $this->file_id);
60 60
     }
61 61
 
62 62
     public function link(): string {
Please login to merge, or discard this patch.
src/types/inputMedia.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
      * be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the
57 57
      * thumbnail was uploaded using multipart/form-data under <file_attach_name>.
58 58
      */
59
-    public CURLFile|string $thumbnail;
59
+    public CURLFile | string $thumbnail;
60 60
 
61 61
     /** `video` and `animation` only. width */
62 62
     public int $width;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public bool $disable_content_type_detection;
84 84
 
85 85
 
86
-    public function __construct(stdClass|null $object = null) {
86
+    public function __construct(stdClass | null $object = null) {
87 87
         if ($object != null) {
88 88
             parent::__construct($object, self::subs);
89 89
         }
Please login to merge, or discard this patch.
src/types/animation.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
     public int $duration;
32 32
 
33 33
     /** Optional. Animation thumbnail as defined by sender */
34
-    public null|photoSize $thumbnail = null;
34
+    public null | photoSize $thumbnail = null;
35 35
 
36 36
     /** Optional. Original animation filename as defined by sender */
37
-    public null|string $file_name = null;
37
+    public null | string $file_name = null;
38 38
 
39 39
     /** Optional. MIME type of the file as defined by sender */
40
-    public null|string $mime_type = null;
40
+    public null | string $mime_type = null;
41 41
 
42 42
     /**
43 43
      * Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
44 44
      * difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
45 45
      * integer or double-precision float type are safe for storing this value.
46 46
      */
47
-    public null|int $file_size = null;
47
+    public null | int $file_size = null;
48 48
 
49 49
 
50
-    public function __construct(stdClass|null $object = null) {
50
+    public function __construct(stdClass | null $object = null) {
51 51
         if ($object != null) {
52 52
             parent::__construct($object, self::subs);
53 53
         }
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @return bool|string string will be returned when destination doesn't set
70 70
      */
71
-    public function download(string|null $destination = null): bool|string {
72
-        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.gif',$this->file_id);
71
+    public function download(string | null $destination = null): bool | string {
72
+        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.gif', $this->file_id);
73 73
     }
74 74
 
75 75
     public function link(): string {
Please login to merge, or discard this patch.