Passed
Push — main ( e7b3ac...e48c60 )
by Miaad
01:34
created
src/receiver/getUpdates.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,25 +14,25 @@  discard block
 block discarded – undo
14 14
  * getUpdates class , For receiving updates by polling methods
15 15
  */
16 16
 class getUpdates extends receiver {
17
-    public static function init () {
17
+    public static function init() {
18 18
         $last_update_id = self::loadData();
19
-        while(true) {
19
+        while (true) {
20 20
             if (!lock::exist('getUpdate')) {
21
-                $updates = telegram::getUpdates($last_update_id,allowed_updates: settings::$allowed_updates);
21
+                $updates = telegram::getUpdates($last_update_id, allowed_updates: settings::$allowed_updates);
22 22
                 if (telegram::$status) {
23 23
                     self::handleUpdates($updates);
24
-                    lock::save('getUpdate',BPT::$update->update_id+1);
25
-                    $last_update_id = BPT::$update->update_id+1;
24
+                    lock::save('getUpdate', BPT::$update->update_id + 1);
25
+                    $last_update_id = BPT::$update->update_id + 1;
26 26
                 }
27 27
                 else {
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
             }
32 32
         }
33 33
     }
34 34
 
35
-    private static function loadData(): bool|int|string {
35
+    private static function loadData(): bool | int | string {
36 36
         if (lock::exist('getUpdate')) {
37 37
             $last_update_id = lock::read('getUpdate');
38 38
         }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
             self::deleteOldLocks();
41 41
             telegram::deleteWebhook();
42 42
             $last_update_id = 0;
43
-            lock::save('getUpdate',0);
43
+            lock::save('getUpdate', 0);
44 44
         }
45 45
         return $last_update_id;
46 46
     }
Please login to merge, or discard this patch.
src/lock.php 1 patch
Spacing   +4 added lines, -4 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(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(settings::$name."$name.lock");
62 62
     }
63 63
 
Please login to merge, or discard this patch.
src/tools.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@
 block discarded – undo
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 7
 /**
8 8
  * tools class , gather what ever you need
9 9
  */
10
-class tools{
10
+class tools {
11 11
     use is;
12 12
     use file;
13 13
     use convert;
Please login to merge, or discard this patch.
src/settings.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
     public static int $log_size = 10;
27 27
 
28
-    public static string|CURLFile|null $certificate = null;
28
+    public static string | CURLFile | null $certificate = null;
29 29
 
30 30
     public static bool $handler = true;
31 31
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 
59 59
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
60 60
 
61
-    public static array|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
61
+    public static array | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
62 62
 
63 63
     /**
64 64
      * @internal Only for BPT self usage , Don't use it in your source!
65 65
      */
66
-    public static function init (array|stdClass $settings): void {
66
+    public static function init(array | stdClass $settings): void {
67 67
         $settings = (array) $settings;
68 68
 
69 69
         foreach ($settings as $setting => $value) {
70
-            try{
70
+            try {
71 71
                 if ($setting === 'name') {
72 72
                     if (!is_dir('bots_files')) {
73 73
                         mkdir('bots_files');
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
                 }
80 80
                 self::$$setting = $value;
81 81
             }
82
-            catch (TypeError){
83
-                logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
82
+            catch (TypeError) {
83
+                logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING);
84 84
             }
85
-            catch (Error){
86
-                logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
85
+            catch (Error) {
86
+                logger::write("$setting setting is not one of library settings", loggerTypes::WARNING);
87 87
             }
88 88
         }
89 89
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
                 }
102 102
             }
103 103
             else {
104
-                logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
104
+                logger::write('token format is not right, check it and try again', loggerTypes::ERROR);
105 105
                 throw new bptException('TOKEN_NOT_TRUE');
106 106
             }
107 107
         }
108 108
         else {
109
-            logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
109
+            logger::write('You must specify token parameter in settings', loggerTypes::ERROR);
110 110
             throw new bptException('TOKEN_NOT_FOUND');
111 111
         }
112 112
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public static function done(): void {
118 118
         if (self::$logger) {
119
-            $estimated = round((microtime(true)-$_SERVER['REQUEST_TIME_FLOAT'])*1000,2);
119
+            $estimated = round((microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000, 2);
120 120
             $status_message = match (true) {
121 121
                 $estimated < 100 => 'Excellent',
122 122
                 $estimated < 500 => 'Very good',
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         if (self::$secure_folder) {
149 149
             $address = explode('/', $_SERVER['REQUEST_URI']);
150 150
             unset($address[count($address) - 1]);
151
-            $address = implode('/', $address) . '/BPT.php';
151
+            $address = implode('/', $address).'/BPT.php';
152 152
             $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n  Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n    Order Allow,Deny\n    Allow from all\n</Files>";
153 153
             if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
154 154
                 file_put_contents('.htaccess', $text);
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             getUpdates::init();
162 162
         }
163 163
         else {
164
-            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
164
+            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
165 165
             throw new bptException('GETUPDATE_NEED_HANDLER');
166 166
         }
167 167
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -78,11 +78,9 @@  discard block
 block discarded – undo
78 78
                     $value = 'bots_files/'.$value.'/';
79 79
                 }
80 80
                 self::$$setting = $value;
81
-            }
82
-            catch (TypeError){
81
+            } catch (TypeError){
83 82
                 logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
84
-            }
85
-            catch (Error){
83
+            } catch (Error){
86 84
                 logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
87 85
             }
88 86
         }
@@ -99,13 +97,11 @@  discard block
 block discarded – undo
99 97
                 if (!empty(self::$receiver)) {
100 98
                     self::$receiver !== receiver::GETUPDATES ? webhook::init() : self::getUpdates();
101 99
                 }
102
-            }
103
-            else {
100
+            } else {
104 101
                 logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
105 102
                 throw new bptException('TOKEN_NOT_TRUE');
106 103
             }
107
-        }
108
-        else {
104
+        } else {
109 105
             logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
110 106
             throw new bptException('TOKEN_NOT_FOUND');
111 107
         }
@@ -159,8 +155,7 @@  discard block
 block discarded – undo
159 155
     private static function getUpdates(): void {
160 156
         if (self::$handler) {
161 157
             getUpdates::init();
162
-        }
163
-        else {
158
+        } else {
164 159
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
165 160
             throw new bptException('GETUPDATE_NEED_HANDLER');
166 161
         }
Please login to merge, or discard this patch.