Passed
Branch main (01a6e7)
by Miaad
01:27
created
tools.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param string $range Your range ip for check , if you didn't specify the block , it will be 32
33 33
      * @return bool
34 34
      */
35
-    public static function ipInRange (string $ip, string $range): bool {
35
+    public static function ipInRange(string $ip, string $range): bool {
36 36
         if (!str_contains($range, '/')) {
37 37
             $range .= '/32';
38 38
         }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param string $ip     Your ip to be check is telegram or not e.g. '192.168.1.1'
52 52
      * @return bool
53 53
      */
54
-    public static function isTelegram (string $ip): bool {
54
+    public static function isTelegram(string $ip): bool {
55 55
         return self::ipInRange($ip, '149.154.160.0/20') || self::ipInRange($ip, '91.108.4.0/22');
56 56
     }
57 57
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
      * @param string $ip Your ip to be check is CloudFlare or not e.g. '192.168.1.1'
66 66
      * @return bool
67 67
      */
68
-    public static function isCloudFlare (string $ip): bool {
68
+    public static function isCloudFlare(string $ip): bool {
69 69
         $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'];
70 70
         foreach ($cf_ips as $cf_ip) {
71
-            if (self::ipInRange($ip,$cf_ip)) {
71
+            if (self::ipInRange($ip, $cf_ip)) {
72 72
                 return true;
73 73
             }
74 74
         }
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      * @param bool $verify check token with telegram or not
90 90
      * @return bool|array return array when verify is active and token is true array of telegram getMe result
91 91
      */
92
-    public static function isToken (string $token, bool $verify = false): bool|array {
92
+    public static function isToken(string $token, bool $verify = false): bool | array {
93 93
         if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) {
94
-            if ($verify){
94
+            if ($verify) {
95 95
                 $res = telegram::me($token);
96 96
                 if ($res['ok']) {
97 97
                     return $res['result'];
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
      * @param string $characters e.g. => 'abcdefg'
123 123
      * @return string
124 124
      */
125
-    public static function randomString (int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
125
+    public static function randomString(int $length = 16, string $characters = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ'): string {
126 126
         $rand_string = '';
127 127
         $char_len = strlen($characters) - 1;
128
-        for ($i = 0; $i < $length; $i ++) {
128
+        for ($i = 0; $i < $length; $i++) {
129 129
             $rand_string .= $characters[rand(0, $char_len)];
130 130
         }
131 131
         return $rand_string;
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
      * @param string $mode Your selected mode e.g. => `parseMode::HTML` | `HTML`
145 145
      * @return string|false return false when mode is incorrect
146 146
      */
147
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
147
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
148 148
         return match ($mode) {
149
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
150
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
149
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
150
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
151 151
             parseMode::MARKDOWNV2 => str_replace(
152 152
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
153 153
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
      * @param int $precision e.g. => 2
174 174
      * @return string
175 175
      */
176
-    public static function byteFormat (int $byte, int $precision = 2): string {
176
+    public static function byteFormat(int $byte, int $precision = 2): string {
177 177
         $rate_counter = 0;
178 178
 
179
-        while ($byte > 1024){
179
+        while ($byte > 1024) {
180 180
             $byte /= 1024;
181 181
             $rate_counter++;
182 182
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
             $byte = round($byte, $precision);
186 186
         }
187 187
 
188
-        return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
188
+        return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
189 189
     }
190 190
 
191 191
     /**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param bool $format if you set this true , you will receive symbolic string like 2.76MB
206 206
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
207 207
      */
208
-    public static function size (string $path, bool $format = true): string|int|false {
208
+    public static function size(string $path, bool $format = true): string | int | false {
209 209
         if (filter_var($path, FILTER_VALIDATE_URL)) {
210 210
             $ch = curl_init($path);
211 211
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -214,14 +214,14 @@
 block discarded – undo
214 214
             curl_exec($ch);
215 215
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
216 216
             curl_close($ch);
217
-        }
218
-        else {
217
+        } else {
219 218
             $size = file_exists($path) ? filesize($path) : false;
220 219
         }
221 220
 
222 221
         if (isset($size) && is_numeric($size)) {
223 222
             return $format ? tools::rateConverter($size) : $size;
224
-        }
225
-        else return false;
223
+        } else {
224
+            return false;
225
+        }
226 226
     }
227 227
 }
228 228
\ No newline at end of file
Please login to merge, or discard this patch.