@@ -32,7 +32,7 @@ |
||
32 | 32 | public bool $selective; |
33 | 33 | |
34 | 34 | |
35 | - public function __construct(stdClass|null $object = null) { |
|
35 | + public function __construct(stdClass | null $object = null) { |
|
36 | 36 | if ($object != null) { |
37 | 37 | parent::__construct($object, self::subs); |
38 | 38 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | public bool $selective; |
33 | 33 | |
34 | 34 | |
35 | - public function __construct(stdClass|null $object = null) { |
|
35 | + public function __construct(stdClass | null $object = null) { |
|
36 | 36 | if ($object != null) { |
37 | 37 | parent::__construct($object, self::subs); |
38 | 38 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public chatInviteLink $invite_link; |
32 | 32 | |
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 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * @method Json_init |
13 | 13 | */ |
14 | - public function json_init () { |
|
14 | + public function json_init() { |
|
15 | 15 | (new jsondb())->init(handler::$dbname); |
16 | 16 | } |
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * |
50 | 50 | */ |
51 | - public function __construct (array $settings) { |
|
51 | + public function __construct(array $settings) { |
|
52 | 52 | if (in_array($settings['type'], self::TYPES)) { |
53 | 53 | if ($settings['type'] === 'Mysqli') { |
54 | 54 | if (self::CheckParam($settings)) { |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - private static function CheckParam (array $array) { |
|
91 | + private static function CheckParam(array $array) { |
|
92 | 92 | if (isset($array['username']) && isset($array['dbname']) && isset($array['password'])) { |
93 | 93 | self::$host = $array['host'] ?? 'localhost'; |
94 | 94 | self::$username = $array['username']; |
@@ -7,4 +7,4 @@ |
||
7 | 7 | /** |
8 | 8 | * Exceptions created by BPT and subclasses |
9 | 9 | */ |
10 | -class bptException extends Exception{} |
|
11 | 10 | \ No newline at end of file |
11 | +class bptException extends Exception {} |
|
12 | 12 | \ No newline at end of file |
@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace BPT; |
4 | 4 | |
5 | -use BPT\tools\{is,file,convert,generator,encrypt}; |
|
5 | +use BPT\tools\{is, file, convert, generator, encrypt}; |
|
6 | 6 | |
7 | -class tools{ |
|
7 | +class tools { |
|
8 | 8 | use is; |
9 | 9 | use file; |
10 | 10 | use convert; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return bool |
22 | 22 | */ |
23 | - public static function isUsername (string $username): bool { |
|
23 | + public static function isUsername(string $username): bool { |
|
24 | 24 | $length = strlen($username); |
25 | 25 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public static function ipInRange (string $ip, string $range): bool { |
|
40 | + public static function ipInRange(string $ip, string $range): bool { |
|
41 | 41 | if (!str_contains($range, '/')) { |
42 | 42 | $range .= '/32'; |
43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public static function isTelegram (string $ip): bool { |
|
60 | + public static function isTelegram(string $ip): bool { |
|
61 | 61 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
62 | 62 | } |
63 | 63 | |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public static function isCloudFlare (string $ip): bool { |
|
75 | + public static function isCloudFlare(string $ip): bool { |
|
76 | 76 | $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', '172.64.0.0/13', '131.0.72.0/22']; |
77 | 77 | foreach ($cf_ips as $cf_ip) { |
78 | - if (self::ipInRange($ip,$cf_ip)) { |
|
78 | + if (self::ipInRange($ip, $cf_ip)) { |
|
79 | 79 | return true; |
80 | 80 | } |
81 | 81 | } |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
97 | 97 | */ |
98 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
98 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
99 | 99 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
100 | - if ($verify){ |
|
100 | + if ($verify) { |
|
101 | 101 | $res = telegram::me($token); |
102 | 102 | if (telegram::$status) { |
103 | 103 | return $res; |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return bool |
131 | 131 | */ |
132 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
132 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
133 | 133 | if (!is_array($ids)) { |
134 | 134 | $ids = [$ids]; |
135 | 135 | } |
136 | 136 | $user_id = $user_id ?? request::catchFields('user_id'); |
137 | 137 | |
138 | 138 | foreach ($ids as $id) { |
139 | - $check = telegram::getChatMember($id,$user_id); |
|
139 | + $check = telegram::getChatMember($id, $user_id); |
|
140 | 140 | if (telegram::$status) { |
141 | 141 | $check = $check->status; |
142 | 142 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array keys will be id and values will be bool(null for not founded ids) |
165 | 165 | */ |
166 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
166 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
167 | 167 | if (!is_array($ids)) { |
168 | 168 | $ids = [$ids]; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $result = []; |
173 | 173 | foreach ($ids as $id) { |
174 | - $check = telegram::getChatMember($id,$user_id); |
|
174 | + $check = telegram::getChatMember($id, $user_id); |
|
175 | 175 | if (telegram::$status) { |
176 | 176 | $check = $check->status; |
177 | 177 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
31 | + public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string { |
|
32 | 32 | $rand_string = ''; |
33 | 33 | $char_len = strlen($characters) - 1; |
34 | - for ($i = 0; $i < $length; $i ++) { |
|
34 | + for ($i = 0; $i < $length; $i++) { |
|
35 | 35 | $rand_string .= $characters[rand(0, $char_len)]; |
36 | 36 | } |
37 | 37 | return $rand_string; |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @return inlineKeyboardMarkup|replyKeyboardMarkup replyKeyboardMarkup for keyboard and inlineKeyboardMarkup for inline |
61 | 61 | * @throws bptException |
62 | 62 | */ |
63 | - public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup|replyKeyboardMarkup { |
|
63 | + public static function easyKey(array $keyboard = [], array $inline = []): inlineKeyboardMarkup | replyKeyboardMarkup { |
|
64 | 64 | if (!empty($keyboard)) { |
65 | 65 | $keyboard_object = new replyKeyboardMarkup(); |
66 | 66 | $keyboard_object->setResize_keyboard($keyboard['resize'] ?? true); |
67 | 67 | if (isset($keyboard['one_time'])) { |
68 | - $keyboard_object->setOne_time_keyboard($keyboard['one_time']) ; |
|
68 | + $keyboard_object->setOne_time_keyboard($keyboard['one_time']); |
|
69 | 69 | } |
70 | 70 | foreach ($keyboard as $row) { |
71 | 71 | $buttons = []; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | return $keyboard_object; |
119 | 119 | } |
120 | 120 | else { |
121 | - logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR); |
|
121 | + logger::write("tools::eKey function used\nkeyboard or inline parameter must be set", loggerTypes::ERROR); |
|
122 | 122 | throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE'); |
123 | 123 | } |
124 | 124 | } |