Passed
Push — main ( fe7ef9...03f6f3 )
by Miaad
10:51
created
src/types/chatShared.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 int $chat_id;
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/keyboardButtonRequestUser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
     public bool $user_is_premium;
29 29
 
30 30
 
31
-    public function __construct(stdClass|null $object = null) {
31
+    public function __construct(stdClass | null $object = null) {
32 32
         if ($object != null) {
33 33
             parent::__construct($object, self::subs);
34 34
         }
Please login to merge, or discard this patch.
src/types/keyboardButtonRequestChat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     public bool $bot_is_member;
57 57
 
58 58
 
59
-    public function __construct(stdClass|null $object = null) {
59
+    public function __construct(stdClass | null $object = null) {
60 60
         if ($object != null) {
61 61
             parent::__construct($object, self::subs);
62 62
         }
Please login to merge, or discard this patch.
src/lock.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @return bool|int
37 37
      */
38
-    public static function save(string $name, string $data): bool|int {
39
-        return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock",0640);
38
+    public static function save(string $name, string $data): bool | int {
39
+        return file_put_contents(settings::$name."$name.lock", $data) && chmod(settings::$name."$name.lock", 0640);
40 40
     }
41 41
 
42 42
     /**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @return bool|string
48 48
      */
49
-    public static function read(string $name): bool|string {
49
+    public static function read(string $name): bool | string {
50 50
         return file_get_contents(realpath(settings::$name."$name.lock"));
51 51
     }
52 52
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return bool|int
59 59
      */
60
-    public static function mtime(string $name): bool|int {
60
+    public static function mtime(string $name): bool | int {
61 61
         return filemtime(realpath(settings::$name."$name.lock"));
62 62
     }
63 63
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      *
80 80
      * @return bool
81 81
      */
82
-    public static function deleteIfExist (string|array $names): bool {
82
+    public static function deleteIfExist(string | array $names): bool {
83 83
         if (is_string($names)) {
84 84
             $names = [$names];
85 85
         }
Please login to merge, or discard this patch.
src/receiver/getUpdates.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@
 block discarded – undo
16 16
  */
17 17
 class getUpdates extends receiver {
18 18
     #[NoReturn]
19
-    public static function init () {
19
+    public static function init() {
20 20
         $last_update_id = self::loadData();
21 21
         lock::set('getUpdateHook');
22
-        while(true) {
22
+        while (true) {
23 23
             if (!lock::exist('getUpdateHook')) {
24 24
                 break;
25 25
             }
26
-            $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates);
26
+            $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates);
27 27
             if (!telegram::$status) {
28
-                logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR);
29
-                BPT::exit(print_r($updates,true));
28
+                logger::write("There is some problem happened , telegram response : \n".json_encode($updates), loggerTypes::ERROR);
29
+                BPT::exit(print_r($updates, true));
30 30
             }
31 31
             self::handleUpdates($updates);
32
-            $last_update_id = BPT::$update->update_id+1;
33
-            lock::save('getUpdate',$last_update_id);
32
+            $last_update_id = BPT::$update->update_id + 1;
33
+            lock::save('getUpdate', $last_update_id);
34 34
         }
35 35
     }
36 36
 
37
-    private static function loadData(): bool|int|string {
37
+    private static function loadData(): bool | int | string {
38 38
         if (lock::exist('getUpdate')) {
39 39
             return lock::read('getUpdate');
40 40
         }
41 41
         self::deleteOldLocks();
42 42
         telegram::deleteWebhook();
43
-        lock::save('getUpdate',0);
43
+        lock::save('getUpdate', 0);
44 44
         return 0;
45 45
     }
46 46
 
Please login to merge, or discard this patch.
src/receiver/webhook.php 2 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
     public static function init () {
23 23
         if (settings::$multi) {
24 24
             multi::init();
25
-        }
26
-        else {
25
+        } else {
27 26
             if (!lock::exist('BPT-HOOK')) {
28 27
                 self::processSetWebhook();
29 28
             }
@@ -108,11 +107,9 @@  discard block
 block discarded – undo
108 107
         ignore_user_abort(true);
109 108
         if (function_exists('fastcgi_finish_request')) {
110 109
             fastcgi_finish_request();
111
-        }
112
-        elseif (function_exists('litespeed_finish_request')) {
110
+        } elseif (function_exists('litespeed_finish_request')) {
113 111
             litespeed_finish_request();
114
-        }
115
-        else {
112
+        } else {
116 113
             return false;
117 114
         }
118 115
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @internal Only for BPT self usage , Don't use it in your source!
21 21
      */
22
-    public static function init () {
22
+    public static function init() {
23 23
         if (settings::$multi) {
24 24
             multi::init();
25 25
         }
@@ -39,28 +39,28 @@  discard block
 block discarded – undo
39 39
         lock::deleteIfExist(['BPT-MULTI-EXEC', 'BPT-MULTI-CURL', 'getUpdate', 'getUpdateHook']);
40 40
     }
41 41
 
42
-    protected static function setWebhook(string $url,string $secret = '') {
42
+    protected static function setWebhook(string $url, string $secret = '') {
43 43
         $res = BPT::setWebhook($url, settings::$certificate, max_connections: settings::$max_connection, allowed_updates: settings::$allowed_updates, drop_pending_updates: settings::$skip_old_updates, secret_token: $secret);
44 44
         if (!BPT::$status) {
45
-            logger::write("There is some problem happened , telegram response : \n".json_encode($res),loggerTypes::ERROR);
46
-            BPT::exit(print_r($res,true));
45
+            logger::write("There is some problem happened , telegram response : \n".json_encode($res), loggerTypes::ERROR);
46
+            BPT::exit(print_r($res, true));
47 47
         }
48
-        logger::write('Webhook was set successfully',loggerTypes::INFO);
48
+        logger::write('Webhook was set successfully', loggerTypes::INFO);
49 49
     }
50 50
 
51 51
     protected static function checkURL() {
52 52
         if (!(isset($_SERVER['SERVER_NAME']) && isset($_SERVER['REQUEST_URI']))) {
53
-            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)',loggerTypes::ERROR);
53
+            logger::write('For using webhook receiver , you should open this file in your webserver(by domain)', loggerTypes::ERROR);
54 54
             throw new bptException('WEBHOOK_NEED_URL');
55 55
         }
56 56
     }
57 57
 
58 58
     protected static function setURL(): string {
59 59
         if (isset($_GET['token'])) {
60
-            logger::write("You can not specify token in url",loggerTypes::ERROR);
60
+            logger::write("You can not specify token in url", loggerTypes::ERROR);
61 61
             BPT::exit("You can not specify token in url");
62 62
         }
63
-        return (isset(settings::$certificate) ? 'http://' : 'https://') . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
63
+        return (isset(settings::$certificate) ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
64 64
     }
65 65
 
66 66
     protected static function setCertificate() {
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
         self::checkURL();
76 76
         self::setCertificate();
77 77
         $url = self::setURL();
78
-        $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':','---',settings::$token);
79
-        self::setWebhook($url,$secret);
78
+        $secret = !empty(settings::$secret) ? settings::$secret : str_replace(':', '---', settings::$token);
79
+        self::setWebhook($url, $secret);
80 80
         lock::save('BPT-HOOK', md5($secret));
81 81
         BPT::exit('Done');
82 82
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     private static function checkSecret() {
85 85
         $secret_hash = lock::read('BPT-HOOK');
86 86
         if ($secret_hash !== md5(self::getSecret())) {
87
-            logger::write('This is not webhook set by BPT, webhook will reset',loggerTypes::WARNING);
87
+            logger::write('This is not webhook set by BPT, webhook will reset', loggerTypes::WARNING);
88 88
             self::processSetWebhook();
89 89
         }
90 90
     }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return bool
107 107
      */
108
-    public static function fastClose (int $timeout = 86400): bool {
108
+    public static function fastClose(int $timeout = 86400): bool {
109 109
         if (settings::$multi || !lock::exist('BPT-HOOK') || settings::$receiver !== \BPT\constants\receiver::WEBHOOK) {
110 110
             return false;
111 111
         }
Please login to merge, or discard this patch.
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.