@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $ip = $ip ?? tools::remoteIP(); |
36 | 36 | if (!tools::isTelegram($ip)) { |
37 | 37 | if (!callback::process()) { |
38 | - logger::write('not authorized access denied. IP : '. $ip ?? 'unknown',loggerTypes::WARNING); |
|
38 | + logger::write('not authorized access denied. IP : '.$ip ?? 'unknown', loggerTypes::WARNING); |
|
39 | 39 | BPT::exit(); |
40 | 40 | } |
41 | 41 | die('callback handler stole the process :('); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - protected static function processUpdate(string|stdClass|update $update = null): void { |
|
46 | + protected static function processUpdate(string | stdClass | update $update = null): void { |
|
47 | 47 | if (!is_object($update)) { |
48 | 48 | $update = json_decode($update ?? file_get_contents('php://input')); |
49 | 49 | if (!$update) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - if (settings::$use_types_classes && !is_a($update,'update')) { |
|
61 | + if (settings::$use_types_classes && !is_a($update, 'update')) { |
|
62 | 62 | $update = new update($update); |
63 | 63 | } |
64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | db::save(); |
70 | 70 | } |
71 | 71 | |
72 | - protected static function setMessageExtra (stdClass|update &$update): void { |
|
72 | + protected static function setMessageExtra(stdClass | update & $update): void { |
|
73 | 73 | if (!isset($update->message->text) && !isset($update->edited_message->text)) { |
74 | 74 | return; |
75 | 75 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | BPT::$handler->something_else(BPT::$update); |
146 | 146 | } |
147 | 147 | else { |
148 | - logger::write('Update received but handlers are not set',loggerTypes::WARNING); |
|
148 | + logger::write('Update received but handlers are not set', loggerTypes::WARNING); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | private static CurlHandle $session; |
40 | 40 | |
41 | - public static function init (string $api_key = '', string $ipn_secret = '', int $round_decimal = 4): void { |
|
41 | + public static function init(string $api_key = '', string $ipn_secret = '', int $round_decimal = 4): void { |
|
42 | 42 | self::$api_key = settings::$pay['crypto']['api_key'] ?? $api_key; |
43 | 43 | self::$ipn_secret = settings::$pay['crypto']['ipn_secret'] ?? $ipn_secret; |
44 | 44 | self::$round_decimal = settings::$pay['crypto']['round_decimal'] ?? $round_decimal; |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYPEER, 1); |
48 | 48 | curl_setopt(self::$session, CURLOPT_SSL_VERIFYHOST, 2); |
49 | 49 | curl_setopt(self::$session, CURLOPT_HTTPHEADER, [ |
50 | - 'X-API-KEY: ' . self::$api_key, |
|
50 | + 'X-API-KEY: '.self::$api_key, |
|
51 | 51 | 'Content-Type: application/json' |
52 | 52 | ]); |
53 | 53 | } |
54 | 54 | |
55 | - private static function execute (string $method, string $endpoint, string|array $data = '') { |
|
55 | + private static function execute(string $method, string $endpoint, string | array $data = '') { |
|
56 | 56 | if (is_array($data)) { |
57 | 57 | foreach ($data as $key => $value) { |
58 | 58 | if (empty($value)) { |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | |
66 | 66 | switch ($method) { |
67 | 67 | case 'GET': |
68 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint . (!empty($data) && is_array($data) ? ('?' . http_build_query($data)) : '')); |
|
68 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint.(!empty($data) && is_array($data) ? ('?'.http_build_query($data)) : '')); |
|
69 | 69 | break; |
70 | 70 | case 'POST': |
71 | 71 | curl_setopt($session, CURLOPT_POST, true); |
72 | 72 | curl_setopt($session, CURLOPT_POSTFIELDS, json_encode($data)); |
73 | - curl_setopt($session, CURLOPT_URL, self::API_BASE . $endpoint); |
|
73 | + curl_setopt($session, CURLOPT_URL, self::API_BASE.$endpoint); |
|
74 | 74 | break; |
75 | 75 | default: |
76 | 76 | return false; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * This is a method to get information about the current state of the API. Receive true if its ok and false in otherwise |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - public static function status (): bool { |
|
85 | + public static function status(): bool { |
|
86 | 86 | return self::execute('GET', 'status')->message === 'OK'; |
87 | 87 | } |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return estimatePriceInterface|errorResponseInterface|mixed |
99 | 99 | */ |
100 | - public static function getEstimatePrice (int|float $amount, string $currency_from, string $currency_to) { |
|
100 | + public static function getEstimatePrice(int | float $amount, string $currency_from, string $currency_to) { |
|
101 | 101 | return self::execute('GET', 'estimate', [ |
102 | 102 | 'amount' => $amount, |
103 | 103 | 'currency_from' => $currency_from, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return invoicePaymentInterface|errorResponseInterface|mixed |
126 | 126 | */ |
127 | - 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, bool $is_fee_paid_by_user = null) { |
|
127 | + 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, bool $is_fee_paid_by_user = null) { |
|
128 | 128 | return self::execute('POST', 'payment', [ |
129 | 129 | 'price_amount' => $price_amount, |
130 | 130 | 'price_currency' => $price_currency, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return invoicePaymentInterface|errorResponseInterface|mixed |
158 | 158 | */ |
159 | - 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) { |
|
159 | + 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) { |
|
160 | 160 | return self::execute('POST', 'invoice-payment', [ |
161 | 161 | 'iid' => $iid, |
162 | 162 | 'pay_currency' => $pay_currency, |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return estimateUpdateInterface|errorResponseInterface|mixed |
179 | 179 | */ |
180 | - public static function updateEstimatePrice (int $paymentID) { |
|
181 | - return self::execute('POST', 'payment/' . $paymentID . '/update-merchant-estimate'); |
|
180 | + public static function updateEstimatePrice(int $paymentID) { |
|
181 | + return self::execute('POST', 'payment/'.$paymentID.'/update-merchant-estimate'); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return paymentInterface|errorResponseInterface|mixed |
190 | 190 | */ |
191 | - public static function getPaymentStatus (int $paymentID) { |
|
192 | - return self::execute('GET', 'payment/' . $paymentID); |
|
191 | + public static function getPaymentStatus(int $paymentID) { |
|
192 | + return self::execute('GET', 'payment/'.$paymentID); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return float |
202 | 202 | */ |
203 | - public static function getMinimumPaymentAmount (string $currency_from, string $currency_to): float { |
|
203 | + public static function getMinimumPaymentAmount(string $currency_from, string $currency_to): float { |
|
204 | 204 | return self::execute('GET', 'min-amount', [ |
205 | 205 | 'currency_from' => $currency_from, |
206 | 206 | 'currency_to' => $currency_to |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return invoiceResponseInterface|errorResponseInterface|mixed |
223 | 223 | */ |
224 | - public static function createInvoice (int|float $price_amount, string $price_currency, string $pay_currency = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
224 | + public static function createInvoice(int | float $price_amount, string $price_currency, string $pay_currency = null, string $ipn_callback_url = null, string $order_id = null, string $order_description = null, string $success_url = null, string $cancel_url = null) { |
|
225 | 225 | return self::execute('POST', 'invoice', [ |
226 | 226 | 'price_amount' => $price_amount, |
227 | 227 | 'price_currency' => $price_currency, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * |
240 | 240 | * @return array |
241 | 241 | */ |
242 | - public static function getCurrencies (): array { |
|
242 | + public static function getCurrencies(): array { |
|
243 | 243 | return self::execute('GET', 'currencies')->currencies; |
244 | 244 | } |
245 | 245 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return array |
250 | 250 | */ |
251 | - public static function getFullCurrencies (): array { |
|
251 | + public static function getFullCurrencies(): array { |
|
252 | 252 | return self::execute('GET', 'full-currencies')->currencies; |
253 | 253 | } |
254 | 254 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array |
260 | 260 | */ |
261 | - public static function getAvailableCheckedCurrencies (): array { |
|
261 | + public static function getAvailableCheckedCurrencies(): array { |
|
262 | 262 | return self::execute('GET', 'merchant/coins')->currencies; |
263 | 263 | } |
264 | 264 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return bool |
278 | 278 | */ |
279 | - public static function isIPNRequestValid (): bool { |
|
279 | + public static function isIPNRequestValid(): bool { |
|
280 | 280 | if (empty($_SERVER['HTTP_X_NOWPAYMENTS_SIG'])) { |
281 | 281 | return false; |
282 | 282 | } |
@@ -298,14 +298,14 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return ipnDataInterface|mixed |
300 | 300 | */ |
301 | - public static function getIPN () { |
|
301 | + public static function getIPN() { |
|
302 | 302 | if (!self::isIPNRequestValid()) { |
303 | 303 | return false; |
304 | 304 | } |
305 | 305 | return json_decode(file_get_contents('php://input')); |
306 | 306 | } |
307 | 307 | |
308 | - protected static function createOrder (float|int $amount, int $user_id, string $description): int|string { |
|
308 | + protected static function createOrder(float | int $amount, int $user_id, string $description): int | string { |
|
309 | 309 | if (!mysql::getMysqli()) { |
310 | 310 | logger::write("crypto::ezPay function used\ncreating order needed mysql connection in our mysql class", loggerTypes::ERROR); |
311 | 311 | throw new bptException('MYSQL_CONNECTION_NEEDED'); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | return mysql::insertId(); |
317 | 317 | } |
318 | 318 | |
319 | - protected static function getOrder (int $order_id): bool|object { |
|
319 | + protected static function getOrder(int $order_id): bool | object { |
|
320 | 320 | if (!mysql::getMysqli()) { |
321 | 321 | logger::write("crypto::ezPay function used\ncreating order needed mysql connection in our mysql class", loggerTypes::ERROR); |
322 | 322 | throw new bptException('MYSQL_CONNECTION_NEEDED'); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * @return bool|string |
348 | 348 | * @throws bptException |
349 | 349 | */ |
350 | - public static function ezPay (float|int $amount, int $user_id = null, string $currency = 'usd', string $description = 'Invoice created by BPT library', bool $direct_url = false, bool $one_time_url = true): bool|string { |
|
350 | + public static function ezPay(float | int $amount, int $user_id = null, string $currency = 'usd', string $description = 'Invoice created by BPT library', bool $direct_url = false, bool $one_time_url = true): bool | string { |
|
351 | 351 | if (empty(self::$ipn_secret)) { |
352 | 352 | logger::write("crypto::ezPay function used\nyou must set ipn_secret to use this", loggerTypes::ERROR); |
353 | 353 | return false; |
@@ -359,10 +359,10 @@ discard block |
||
359 | 359 | $user_id = $user_id ?? request::catchFields(fields::USER_ID); |
360 | 360 | $order_id = self::createOrder($amount, $user_id, $description); |
361 | 361 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::CALLBACK, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
362 | - $callback_url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
362 | + $callback_url = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
363 | 363 | |
364 | 364 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::SUCCESS, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
365 | - $success_url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
365 | + $success_url = 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
366 | 366 | |
367 | 367 | $invoice_id = self::createInvoice($amount, $currency, null, $callback_url, $order_id, $description, $success_url)->id; |
368 | 368 | |
@@ -381,17 +381,17 @@ discard block |
||
381 | 381 | ], ['id' => $order_id], 1); |
382 | 382 | |
383 | 383 | if ($direct_url) { |
384 | - return 'https://nowpayments.io/payment/?iid='. $invoice_id; |
|
384 | + return 'https://nowpayments.io/payment/?iid='.$invoice_id; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $data = ['type' => callbackTypes::CRYPTO, 'action_type' => cryptoCallbackActionTypes::REDIRECT, 'amount' => $amount, 'currency' => $currency, 'user_id' => $user_id, 'order_id' => $order_id]; |
388 | - return 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '?data='.urlencode(callback::encodeData($data)); |
|
388 | + return 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'?data='.urlencode(callback::encodeData($data)); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | 392 | * @internal Only for BPT self usage , Don't use it in your source! |
393 | 393 | */ |
394 | - public static function callbackProcess (array $data) { |
|
394 | + public static function callbackProcess(array $data) { |
|
395 | 395 | if (!isset($data['action_type'])) { |
396 | 396 | return false; |
397 | 397 | } |
@@ -411,16 +411,16 @@ discard block |
||
411 | 411 | BPT::exit('This link is one time only, Receive another link'); |
412 | 412 | } |
413 | 413 | } |
414 | - $url = 'https://nowpayments.io/payment/?iid='. $extra_info->invoice_id; |
|
414 | + $url = 'https://nowpayments.io/payment/?iid='.$extra_info->invoice_id; |
|
415 | 415 | |
416 | - @header('Location: ' . $url); |
|
416 | + @header('Location: '.$url); |
|
417 | 417 | die("<meta http-equiv='refresh' content='0; url=$url' /><script>window.location.href = '$url';</script>"); |
418 | 418 | } |
419 | 419 | |
420 | 420 | if ($action_type === cryptoCallbackActionTypes::CALLBACK) { |
421 | 421 | $ipn = self::getIPN(); |
422 | 422 | |
423 | - if ($ipn->payment_status !== cryptoStatus::FINISHED && $ipn->payment_status !== cryptoStatus::PARTIALLY_PAID ) { |
|
423 | + if ($ipn->payment_status !== cryptoStatus::FINISHED && $ipn->payment_status !== cryptoStatus::PARTIALLY_PAID) { |
|
424 | 424 | die(); |
425 | 425 | } |
426 | 426 | |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | die(); |
443 | 443 | } |
444 | 444 | |
445 | - $paid = round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid/$payment->pay_amount*$payment->price_amount, self::$round_decimal); |
|
445 | + $paid = round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid / $payment->pay_amount * $payment->price_amount, self::$round_decimal); |
|
446 | 446 | $extra_info['related_payments'][$payment_id] = $paid; |
447 | 447 | $extra_info['total_paid'] += $paid; |
448 | 448 | mysql::update('orders', ['extra_info' => json_encode($extra_info)], ['id' => $order_id], 1); |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'description' => $order->description, |
505 | 505 | 'real_amount' => $order->amount, |
506 | 506 | 'currency' => $extra_info->currency, |
507 | - 'paid_amount' => round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid/$payment->pay_amount*$payment->price_amount, self::$round_decimal), |
|
507 | + 'paid_amount' => round(isset($payment->actually_paid_at_fiat) && $payment->actually_paid_at_fiat > 0 ? $payment->actually_paid_at_fiat : $payment->actually_paid / $payment->pay_amount * $payment->price_amount, self::$round_decimal), |
|
508 | 508 | 'total_paid' => $extra_info->total_paid |
509 | 509 | ]; |
510 | 510 | $callback_data = object(...$callback_data); |
@@ -20,18 +20,18 @@ |
||
20 | 20 | public string $description; |
21 | 21 | |
22 | 22 | /** @var int|float Real amount or known as requested amount */ |
23 | - public int|float $real_amount; |
|
23 | + public int | float $real_amount; |
|
24 | 24 | |
25 | 25 | /** @var string Fiat currency(aka usd, euro, ...) */ |
26 | 26 | public string $currency; |
27 | 27 | |
28 | 28 | /** @var int|float Paid amount in this payment */ |
29 | - public int|float $paid_amount; |
|
29 | + public int | float $paid_amount; |
|
30 | 30 | |
31 | 31 | /** @var int|float Total paid amount for the order id */ |
32 | - public int|float $total_paid; |
|
32 | + public int | float $total_paid; |
|
33 | 33 | |
34 | - public function __construct(stdClass|null $object = null) { |
|
34 | + public function __construct(stdClass | null $object = null) { |
|
35 | 35 | if ($object != null) { |
36 | 36 | parent::__construct($object, self::subs); |
37 | 37 | } |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init(string $method,array $data) { |
|
20 | + public static function init(string $method, array $data) { |
|
21 | 21 | $info = self::getInfo($data); |
22 | 22 | $data = $info['data']; |
23 | 23 | $handler = $info['handler']; |
24 | - self::setTimeout($data,$handler,$method); |
|
24 | + self::setTimeout($data, $handler, $method); |
|
25 | 25 | self::setData($data); |
26 | 26 | $data['method'] = $method; |
27 | 27 | curl_setopt($handler, CURLOPT_POSTFIELDS, $data); |
28 | 28 | $result = curl_exec($handler); |
29 | 29 | if (curl_errno($handler)) { |
30 | - logger::write(curl_error($handler),loggerTypes::WARNING); |
|
30 | + logger::write(curl_error($handler), loggerTypes::WARNING); |
|
31 | 31 | } |
32 | 32 | if ($info['token'] != settings::$token) { |
33 | 33 | curl_close($handler); |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); |
45 | 45 | curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
46 | 46 | } |
47 | - else{ |
|
47 | + else { |
|
48 | 48 | $token = settings::$token; |
49 | - if (!isset(self::$curl_handler)){ |
|
49 | + if (!isset(self::$curl_handler)) { |
|
50 | 50 | self::$curl_handler = curl_init(settings::$base_url."/bot$token/"); |
51 | 51 | curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true); |
52 | 52 | curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false); |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
65 | - private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void { |
|
65 | + private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void { |
|
66 | 66 | if (isset($data['forgot'])) { |
67 | 67 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time); |
68 | 68 | unset($data['forgot']); |
69 | 69 | } |
70 | - elseif ($method === 'getUpdates' || $method === 'setWebhook'){ |
|
70 | + elseif ($method === 'getUpdates' || $method === 'setWebhook') { |
|
71 | 71 | curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000); |
72 | 72 | } |
73 | 73 | elseif (settings::$base_timeout > 0) { |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | private static function setData(array &$data): void { |
79 | - foreach ($data as &$value){ |
|
80 | - if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){ |
|
79 | + foreach ($data as &$value) { |
|
80 | + if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) { |
|
81 | 81 | $value = json_encode($value); |
82 | 82 | } |
83 | 83 | } |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @internal Only for BPT self usage , Don't use it in your source! |
19 | 19 | */ |
20 | - public static function init (int $log_size = 10): void { |
|
20 | + public static function init(int $log_size = 10): void { |
|
21 | 21 | self::$log_size = $log_size; |
22 | 22 | $log_file = realpath(settings::$name.'BPT.log'); |
23 | 23 | $mode = file_exists($log_file) && self::$log_size * 1024 * 1024 > filesize($log_file) ? 'a' : 'w'; |
24 | 24 | self::$handler = fopen(settings::$name.'BPT.log', $mode); |
25 | 25 | if ($mode === 'w') { |
26 | - fwrite(self::$handler,"♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
26 | + fwrite(self::$handler, "♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nTnx for using our library\nSome information about us :\nAuthor : @Im_Miaad\nHelper : @A_LiReza_ME\nChannel : @BPT_CH\nOur Website : https://bptlib.ir\n\nIf you have any problem with our library\nContact to our supports\n♥♥♥♥♥♥♥♥♥♥♥♥♥♥ BPT Library ♥♥♥♥♥♥♥♥♥♥♥♥♥♥\nINFO : BPT Library LOG STARTED ...\nwarning : this file automatically deleted when its size reached log_size setting, do not delete it manually\n\n"); |
|
27 | 27 | } |
28 | 28 | if (self::$waited_logs != []) { |
29 | 29 | foreach (self::$waited_logs as $log) { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function write(string $data, string $type = loggerTypes::NONE): void { |
46 | - $text = date('Y/m/d H:i:s') . ($type !== loggerTypes::NONE ? " : ⤵\n$type" : '') . " : $data\n\n"; |
|
46 | + $text = date('Y/m/d H:i:s').($type !== loggerTypes::NONE ? " : ⤵\n$type" : '')." : $data\n\n"; |
|
47 | 47 | if (!is_null(self::$handler)) { |
48 | 48 | fwrite(self::$handler, $text); |
49 | 49 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return $this |
16 | 16 | */ |
17 | - public function setGlobal (array $global): self { |
|
17 | + public function setGlobal(array $global): self { |
|
18 | 18 | $this->settings['global'] = $global; |
19 | 19 | return $this; |
20 | 20 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return $this |
26 | 26 | */ |
27 | - public function setGroup (array $group): self { |
|
27 | + public function setGroup(array $group): self { |
|
28 | 28 | $this->settings['group'] = $group; |
29 | 29 | return $this; |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return $this |
36 | 36 | */ |
37 | - public function setSuperGroup (array $supergroup): self { |
|
37 | + public function setSuperGroup(array $supergroup): self { |
|
38 | 38 | $this->settings['supergroup'] = $supergroup; |
39 | 39 | return $this; |
40 | 40 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return $this |
46 | 46 | */ |
47 | - public function setChannel (array $channel): self { |
|
47 | + public function setChannel(array $channel): self { |
|
48 | 48 | $this->settings['channel'] = $channel; |
49 | 49 | return $this; |
50 | 50 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return $this |
56 | 56 | */ |
57 | - public function setUser (array $user): self { |
|
57 | + public function setUser(array $user): self { |
|
58 | 58 | $this->settings['user'] = $user; |
59 | 59 | return $this; |
60 | 60 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return $this |
66 | 66 | */ |
67 | - public function setGroupUser (array $group_user): self { |
|
67 | + public function setGroupUser(array $group_user): self { |
|
68 | 68 | $this->settings['group_user'] = $group_user; |
69 | 69 | return $this; |
70 | 70 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | /** |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function getSettings (): array { |
|
75 | + public function getSettings(): array { |
|
76 | 76 | return $this->settings; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | \ No newline at end of file |
@@ -4,17 +4,17 @@ |
||
4 | 4 | class easyIdpay { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setApiKey (string $api_key): self { |
|
7 | + public function setApiKey(string $api_key): self { |
|
8 | 8 | $this->settings['api_key'] = $api_key; |
9 | 9 | return $this; |
10 | 10 | } |
11 | 11 | |
12 | - public function setSandbox (string $sandbox): self { |
|
12 | + public function setSandbox(string $sandbox): self { |
|
13 | 13 | $this->settings['sandbox'] = $sandbox; |
14 | 14 | return $this; |
15 | 15 | } |
16 | 16 | |
17 | - public function getSettings (): array { |
|
17 | + public function getSettings(): array { |
|
18 | 18 | return $this->settings; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -4,22 +4,22 @@ |
||
4 | 4 | class easyZarinpal { |
5 | 5 | private array $settings = []; |
6 | 6 | |
7 | - public function setSandbox (string $sandbox): self { |
|
7 | + public function setSandbox(string $sandbox): self { |
|
8 | 8 | $this->settings['sandbox'] = $sandbox; |
9 | 9 | return $this; |
10 | 10 | } |
11 | 11 | |
12 | - public function setZarinGate (string $zarin_gate): self { |
|
12 | + public function setZarinGate(string $zarin_gate): self { |
|
13 | 13 | $this->settings['zarin_gate'] = $zarin_gate; |
14 | 14 | return $this; |
15 | 15 | } |
16 | 16 | |
17 | - public function setMerchantId (int $merchant_id): self { |
|
17 | + public function setMerchantId(int $merchant_id): self { |
|
18 | 18 | $this->settings['merchant_id'] = $merchant_id; |
19 | 19 | return $this; |
20 | 20 | } |
21 | 21 | |
22 | - public function getSettings (): array { |
|
22 | + public function getSettings(): array { |
|
23 | 23 | return $this->settings; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @return $this |
15 | 15 | */ |
16 | - public function setHost (string $host): self { |
|
16 | + public function setHost(string $host): self { |
|
17 | 17 | $this->settings['host'] = $host; |
18 | 18 | return $this; |
19 | 19 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return $this |
25 | 25 | */ |
26 | - public function setPort (string $port): self { |
|
26 | + public function setPort(string $port): self { |
|
27 | 27 | $this->settings['port'] = $port; |
28 | 28 | return $this; |
29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return $this |
35 | 35 | */ |
36 | - public function setUsername (string $user): self { |
|
36 | + public function setUsername(string $user): self { |
|
37 | 37 | $this->settings['user'] = $user; |
38 | 38 | return $this; |
39 | 39 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return $this |
45 | 45 | */ |
46 | - public function setPassword (string $pass): self { |
|
46 | + public function setPassword(string $pass): self { |
|
47 | 47 | $this->settings['pass'] = $pass; |
48 | 48 | return $this; |
49 | 49 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function setDBName (string $dbname): self { |
|
56 | + public function setDBName(string $dbname): self { |
|
57 | 57 | $this->settings['dbname'] = $dbname; |
58 | 58 | return $this; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return $this |
65 | 65 | */ |
66 | - public function setAutoProcess (bool $auto_process): self { |
|
66 | + public function setAutoProcess(bool $auto_process): self { |
|
67 | 67 | $this->settings['auto_process'] = $auto_process; |
68 | 68 | return $this; |
69 | 69 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return $this |
75 | 75 | */ |
76 | - public function setAutoLoad (bool $auto_load): self { |
|
76 | + public function setAutoLoad(bool $auto_load): self { |
|
77 | 77 | $this->settings['auto_load'] = $auto_load; |
78 | 78 | return $this; |
79 | 79 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | /** |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public function getSettings (): array { |
|
84 | + public function getSettings(): array { |
|
85 | 85 | return $this->settings; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | \ No newline at end of file |