Passed
Push — main ( ca9ae3...e465fe )
by Miaad
10:35
created
src/types/poll.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,43 +29,43 @@
 block discarded – undo
29 29
     public int $total_voter_count;
30 30
 
31 31
     /** True, if the poll is closed */
32
-    public null|bool $is_closed = null;
32
+    public null | bool $is_closed = null;
33 33
 
34 34
     /** True, if the poll is anonymous */
35
-    public null|bool $is_anonymous = null;
35
+    public null | bool $is_anonymous = null;
36 36
 
37 37
     /** Poll type, currently can be “regular” or “quiz” */
38 38
     public string $type;
39 39
 
40 40
     /** True, if the poll allows multiple answers */
41
-    public null|bool $allows_multiple_answers = null;
41
+    public null | bool $allows_multiple_answers = null;
42 42
 
43 43
     /**
44 44
      * Optional. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which
45 45
      * are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.
46 46
      */
47
-    public null|int $correct_option_id = null;
47
+    public null | int $correct_option_id = null;
48 48
 
49 49
     /**
50 50
      * Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style
51 51
      * poll, 0-200 characters
52 52
      */
53
-    public null|string $explanation = null;
53
+    public null | string $explanation = null;
54 54
 
55 55
     /**
56 56
      * Optional. Special entities like usernames, URLs, bot commands, etc. that appear in the explanation
57 57
      * @var messageEntity[]
58 58
      */
59
-    public null|array $explanation_entities = null;
59
+    public null | array $explanation_entities = null;
60 60
 
61 61
     /** Optional. Amount of time in seconds the poll will be active after creation */
62
-    public null|int $open_period = null;
62
+    public null | int $open_period = null;
63 63
 
64 64
     /** Optional. Point in time (Unix timestamp) when the poll will be automatically closed */
65
-    public null|int $close_date = null;
65
+    public null | int $close_date = null;
66 66
 
67 67
 
68
-    public function __construct(stdClass|null $object = null) {
68
+    public function __construct(stdClass | null $object = null) {
69 69
         if ($object != null) {
70 70
             parent::__construct($object, self::subs);
71 71
         }
Please login to merge, or discard this patch.
src/telegram/request/curl.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * @internal Only for BPT self usage , Don't use it in your source!
18 18
      */
19
-    public static function init(string $method,array $data) {
19
+    public static function init(string $method, array $data) {
20 20
         $info = self::getInfo($data);
21 21
         $data = $info['data'];
22 22
         $handler = $info['handler'];
23
-        self::setTimeout($data,$handler,$method);
23
+        self::setTimeout($data, $handler, $method);
24 24
         self::setData($data);
25 25
         $data['method'] = $method;
26 26
         curl_setopt($handler, CURLOPT_POSTFIELDS, $data);
27 27
         $result = curl_exec($handler);
28 28
         if (curl_errno($handler)) {
29
-            logger::write(curl_error($handler),loggerTypes::WARNING);
29
+            logger::write(curl_error($handler), loggerTypes::WARNING);
30 30
         }
31 31
         if ($info['token'] != settings::$token) {
32 32
             curl_close($handler);
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
43 43
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
44 44
         }
45
-        else{
45
+        else {
46 46
             $token = settings::$token;
47
-            if (!isset(self::$curl_handler)){
47
+            if (!isset(self::$curl_handler)) {
48 48
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
49 49
                 curl_setopt(self::$curl_handler, CURLOPT_RETURNTRANSFER, true);
50 50
                 curl_setopt(self::$curl_handler, CURLOPT_SSL_VERIFYPEER, false);
@@ -60,22 +60,22 @@  discard block
 block discarded – undo
60 60
         ];
61 61
     }
62 62
 
63
-    private static function setTimeout(array &$data , CurlHandle $curl_handler,string $method): void {
63
+    private static function setTimeout(array &$data, CurlHandle $curl_handler, string $method): void {
64 64
         if (isset($data['forgot'])) {
65 65
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
66 66
             unset($data['forgot']);
67 67
         }
68
-        elseif ($method === 'getUpdates' || $method === 'setWebhook'){
68
+        elseif ($method === 'getUpdates' || $method === 'setWebhook') {
69 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
70 70
         }
71
-        else{
71
+        else {
72 72
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
73 73
         }
74 74
     }
75 75
 
76 76
     private static function setData(array &$data): void {
77
-        foreach ($data as &$value){
78
-            if (is_array($value) || (is_object($value) && !is_a($value,'CURLFile'))){
77
+        foreach ($data as &$value) {
78
+            if (is_array($value) || (is_object($value) && !is_a($value, 'CURLFile'))) {
79 79
                 $value = json_encode($value);
80 80
             }
81 81
         }
Please login to merge, or discard this patch.
src/types/forumTopic.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
     public int $icon_color;
19 19
 
20 20
     /** Optional. Unique identifier of the custom emoji shown as the topic icon */
21
-    public null|string $icon_custom_emoji_id = null;
21
+    public null | string $icon_custom_emoji_id = null;
22 22
 
23 23
 
24
-    public function __construct(stdClass|null $object = null) {
24
+    public function __construct(stdClass | null $object = null) {
25 25
         if ($object != null) {
26 26
             parent::__construct($object, self::subs);
27 27
         }
Please login to merge, or discard this patch.
src/logger.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
         if (file_exists($log_file) && !(filesize($log_file) > self::$log_size * 1024 * 1024)) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         self::$handler = fopen(settings::$name.'BPT.log', $mode);
32 32
 
33 33
         if ($write) {
34
-            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");
34
+            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");
35 35
         }
36 36
 
37 37
         if (self::$waited_logs != []) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @return void
53 53
      */
54 54
     public static function write(string $data, string $type = loggerTypes::NONE): void {
55
-        $text = date('Y/m/d H:i:s') . ( $type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n" );
55
+        $text = date('Y/m/d H:i:s').($type === loggerTypes::NONE ? " : $data\n\n" : " : ⤵\n$type : $data\n\n");
56 56
         if (!is_null(self::$handler)) {
57 57
             fwrite(self::$handler, $text);
58 58
         }
Please login to merge, or discard this patch.
examples/messenger/bot.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,11 +5,11 @@  discard block
 block discarded – undo
5 5
 use BPT\database\mysql;
6 6
 use BPT\types\message;
7 7
 
8
-if (file_exists('vendor/autoload.php')){
8
+if (file_exists('vendor/autoload.php')) {
9 9
     require 'vendor/autoload.php';
10 10
 }
11
-else{
12
-    if(!file_exists('BPT.phar')) {
11
+else {
12
+    if (!file_exists('BPT.phar')) {
13 13
         copy('https://dl.bptlib.ir/BPT.phar', 'BPT.phar');
14 14
     }
15 15
     require 'BPT.phar';
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
     const SEND_FAILED = 'Failed!';
36 36
     const SEND_SUCCESSFUL = 'Done!';
37 37
 
38
-    public function __construct(array $settings){
38
+    public function __construct(array $settings) {
39 39
         parent::__construct($settings);
40 40
     }
41 41
 
42
-    public function message(message $update){
42
+    public function message(message $update) {
43 43
         $text = $update->text ?? '';
44 44
         $user_id = $update->from->id;
45 45
 
46 46
         if ($text === '/start') {
47
-            $this->sendMessage(self::START_TEXT,answer: true);
47
+            $this->sendMessage(self::START_TEXT, answer: true);
48 48
         }
49 49
         else {
50 50
             /** You could use both style */
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
                     $this->sendMessage(self::HELP, answer: true);
57 57
                 }
58 58
                 elseif ($text === '/reply_on') {
59
-                    mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1);
59
+                    mysql::update('users', ['value'=>'reply_on'], ['id'=>$user_id], 1);
60 60
                     $this->sendMessage(self::REPLY_ON, answer: true);
61 61
                 }
62 62
                 elseif ($text === '/reply_off') {
63
-                    mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1);
63
+                    mysql::update('users', ['value'=>'reply_off'], ['id'=>$user_id], 1);
64 64
                     $this->sendMessage(self::REPLY_OFF, answer: true);
65 65
                 }
66 66
                 elseif (isset($update->reply_to_message)) {
67 67
                     $reply_message_id = $update->reply_to_message->message_id;
68 68
 
69 69
                     if ($update->reply_to_message->from->id === $user_id) {
70
-                        $check_message = mysql::select('messages', ['receiver_message_id','receiver_id'], [
70
+                        $check_message = mysql::select('messages', ['receiver_message_id', 'receiver_id'], [
71 71
                             'sender_message_id' => $reply_message_id,
72 72
                             'sender_id'         => $user_id
73
-                        ],1);
73
+                        ], 1);
74 74
 
75 75
                         if ($check_message->num_rows > 0) {
76 76
                             $data = $check_message->fetch_object();
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
                         }
84 84
                     }
85 85
                     else {
86
-                        $data = mysql::select('messages', ['sender_message_id','sender_id'], [
86
+                        $data = mysql::select('messages', ['sender_message_id', 'sender_id'], [
87 87
                             'receiver_message_id' => $reply_message_id,
88 88
                             'receiver_id'         => $user_id
89
-                        ],1)->fetch_object();
89
+                        ], 1)->fetch_object();
90 90
 
91
-                        $value = mysql::select('users','value',['id'=>$user_id])->fetch_object()->value;
91
+                        $value = mysql::select('users', 'value', ['id'=>$user_id])->fetch_object()->value;
92 92
                         $receiver_id = $data->sender_id;
93 93
                         if ($value === 'reply_on') {
94
-                            mysql::update('users',['value'=>''],['id'=>$user_id]);
94
+                            mysql::update('users', ['value'=>''], ['id'=>$user_id]);
95 95
                             $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id);
96 96
                         }
97 97
                         else {
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 
102 102
                     if (self::$status) {
103 103
                         mysql::insert('messages',
104
-                            ['sender_message_id','sender_id','receiver_message_id','receiver_id'],
105
-                            [$message_id,$user_id,$result->message_id,$receiver_id]
104
+                            ['sender_message_id', 'sender_id', 'receiver_message_id', 'receiver_id'],
105
+                            [$message_id, $user_id, $result->message_id, $receiver_id]
106 106
                         );
107 107
                         if (self::SHOW_STATUS) {
108 108
                             $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             else {
117 117
                 $username = $update->from->username;
118 118
                 if (empty($username)) {
119
-                    $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : '');
119
+                    $name = $update->from->first_name.(!empty($update->from->last_name) ? (' '.$update->from->last_name) : '');
120 120
                     $keyboard = [
121 121
                         'inline_keyboard' => [
122 122
                             [
@@ -154,33 +154,33 @@  discard block
 block discarded – undo
154 154
                 }
155 155
                 if (isset($update->reply_to_message)) {
156 156
                     $reply_message_id = $update->reply_to_message->message_id;
157
-                    if ($update->reply_to_message->from->id === $user_id){
157
+                    if ($update->reply_to_message->from->id === $user_id) {
158 158
                         $check_message = mysql::select('messages', 'receiver_message_id', [
159 159
                             'sender_message_id' => $reply_message_id,
160 160
                             'sender_id'         => $user_id
161
-                        ],1);
161
+                        ], 1);
162 162
                         if ($check_message->num_rows > 0) {
163
-                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard);
163
+                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id, reply_markup: $keyboard);
164 164
                         }
165 165
                         else {
166
-                            $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
166
+                            $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
167 167
                         }
168 168
                     }
169 169
                     else {
170 170
                         $check_message = mysql::select('messages', 'sender_message_id', [
171 171
                             'receiver_message_id' => $reply_message_id,
172 172
                             'receiver_id'         => $user_id
173
-                        ],1);
173
+                        ], 1);
174 174
                         if ($check_message->num_rows > 0) {
175
-                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard);
175
+                            $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id, reply_markup: $keyboard);
176 176
                         }
177 177
                         else {
178
-                            $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
178
+                            $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
179 179
                         }
180 180
                     }
181 181
                 }
182 182
                 else {
183
-                    $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
183
+                    $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
184 184
                 }
185 185
 
186 186
                 /**
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
                  */
190 190
                 if (self::$status) {
191 191
                     mysql::insert('messages',
192
-                        ['sender_message_id','sender_id','receiver_message_id','receiver_id'],
193
-                        [$message_id,$user_id,$result->message_id,self::ADMIN]
192
+                        ['sender_message_id', 'sender_id', 'receiver_message_id', 'receiver_id'],
193
+                        [$message_id, $user_id, $result->message_id, self::ADMIN]
194 194
                     );
195 195
                     if (self::SHOW_STATUS) {
196 196
                         $this->sendMessage(self::SEND_SUCCESSFUL, answer: true);
Please login to merge, or discard this patch.
src/types/user.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
     public int $id;
22 22
 
23 23
     /** True, if this user is a bot */
24
-    public null|bool $is_bot = null;
24
+    public null | bool $is_bot = null;
25 25
 
26 26
     /** User's or bot's first name */
27
-    public null|string $first_name = null;
27
+    public null | string $first_name = null;
28 28
 
29 29
     /** Optional. User's or bot's last name */
30
-    public null|string $last_name = null;
30
+    public null | string $last_name = null;
31 31
 
32 32
     /** Optional. User's or bot's username */
33
-    public null|string $username = null;
33
+    public null | string $username = null;
34 34
 
35 35
     /** Optional. IETF language tag of the user's language */
36
-    public null|string $language_code = null;
36
+    public null | string $language_code = null;
37 37
 
38 38
     /** Optional. True, if this user is a Telegram Premium user */
39
-    public null|bool $is_premium = null;
39
+    public null | bool $is_premium = null;
40 40
 
41 41
     /** Optional. True, if this user added the bot to the attachment menu */
42
-    public null|bool $added_to_attachment_menu = null;
42
+    public null | bool $added_to_attachment_menu = null;
43 43
 
44 44
     /** Optional. True, if the bot can be invited to groups. Returned only in getMe. */
45
-    public null|bool $can_join_groups = null;
45
+    public null | bool $can_join_groups = null;
46 46
 
47 47
     /** Optional. True, if privacy mode is disabled for the bot. Returned only in getMe. */
48
-    public null|bool $can_read_all_group_messages = null;
48
+    public null | bool $can_read_all_group_messages = null;
49 49
 
50 50
     /** Optional. True, if the bot supports inline queries. Returned only in getMe. */
51
-    public null|bool $supports_inline_queries = null;
51
+    public null | bool $supports_inline_queries = null;
52 52
 
53 53
 
54
-    public function __construct(stdClass|null $object = null) {
54
+    public function __construct(stdClass | null $object = null) {
55 55
         if ($object != null) {
56 56
             parent::__construct($object, self::subs);
57 57
         }
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
     }
63 63
 
64 64
     public function fullName(bool $nameFirst = true): string {
65
-        return trim($nameFirst ? $this->first_name . ' ' . $this->last_name : $this->last_name . ' ' . $this->first_name);
65
+        return trim($nameFirst ? $this->first_name.' '.$this->last_name : $this->last_name.' '.$this->first_name);
66 66
     }
67 67
 
68
-    public function getProfiles(int|null $offset = null, int|null $limit = null): userProfilePhotos|responseError {
69
-        return telegram::getUserProfilePhotos($this->id,$offset,$limit);
68
+    public function getProfiles(int | null $offset = null, int | null $limit = null): userProfilePhotos | responseError {
69
+        return telegram::getUserProfilePhotos($this->id, $offset, $limit);
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
src/types/photoSize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     public int $height;
29 29
 
30 30
     /** Optional. File size in bytes */
31
-    public null|int $file_size = null;
31
+    public null | int $file_size = null;
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
         }
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @return bool|string string will be returned when destination doesn't set
54 54
      */
55
-    public function download(string|null $destination = null): bool|string {
56
-        return telegram::downloadFile($destination ?? 'unknown.jpg',$this->file_id);
55
+    public function download(string | null $destination = null): bool | string {
56
+        return telegram::downloadFile($destination ?? 'unknown.jpg', $this->file_id);
57 57
     }
58 58
 
59 59
     public function link(): string {
Please login to merge, or discard this patch.
src/types/chatPhoto.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public string $big_file_unique_id;
38 38
 
39 39
 
40
-    public function __construct(stdClass|null $object = null) {
40
+    public function __construct(stdClass | null $object = null) {
41 41
         if ($object != null) {
42 42
             parent::__construct($object, self::subs);
43 43
         }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @return bool|string string will be returned when destination doesn't set
61 61
      */
62
-    public function download(string|null $destination = null,bool $big = true): bool|string {
63
-        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.mp4',$big ? $this->big_file_id : $this->small_file_id);
62
+    public function download(string | null $destination = null, bool $big = true): bool | string {
63
+        return telegram::downloadFile($destination ?? $this->file_name ?? 'unknown.mp4', $big ? $this->big_file_id : $this->small_file_id);
64 64
     }
65 65
 
66 66
     public function link(bool $big = true): string {
Please login to merge, or discard this patch.
src/types/chatInviteLink.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -31,28 +31,28 @@
 block discarded – undo
31 31
     public bool $is_revoked;
32 32
 
33 33
     /** Optional. Invite link name */
34
-    public null|string $name = null;
34
+    public null | string $name = null;
35 35
 
36 36
     /** Optional. Point in time (Unix timestamp) when the link will expire or has been expired */
37
-    public null|int $expire_date = null;
37
+    public null | int $expire_date = null;
38 38
 
39 39
     /**
40 40
      * Optional. The maximum number of users that can be members of the chat simultaneously after joining the chat
41 41
      * via this invite link; 1-99999
42 42
      */
43
-    public null|int $member_limit = null;
43
+    public null | int $member_limit = null;
44 44
 
45 45
     /** Optional. Number of pending join requests created using this link */
46
-    public null|int $pending_join_request_count = null;
46
+    public null | int $pending_join_request_count = null;
47 47
 
48 48
 
49
-    public function __construct(stdClass|null $object = null) {
49
+    public function __construct(stdClass | null $object = null) {
50 50
         if ($object != null) {
51 51
             parent::__construct($object, self::subs);
52 52
         }
53 53
     }
54 54
 
55
-    public function revoke(): self|responseError|bool {
55
+    public function revoke(): self | responseError | bool {
56 56
         return $this->is_revoked ?? telegram::revokeChatInviteLink($this->invite_link);
57 57
     }
58 58
 }
Please login to merge, or discard this patch.