Passed
Push — main ( 4122b8...60aebc )
by Miaad
01:36
created
tools/encrypt.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      * @return string|bool|array{hash:string, key:string, iv:string}
30 30
      * @throws bptException
31 31
      */
32
-    public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string {
32
+    public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string {
33 33
         if (extension_loaded('openssl')) {
34 34
             if ($action === cryptoAction::ENCRYPT) {
35 35
                 $key = self::randomString(64);
@@ -39,22 +39,22 @@  discard block
 block discarded – undo
39 39
             }
40 40
             elseif ($action === cryptoAction::DECRYPT) {
41 41
                 if (empty($key)) {
42
-                    logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
42
+                    logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR);
43 43
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44 44
                 }
45 45
                 elseif (empty($iv)) {
46
-                    logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
46
+                    logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR);
47 47
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 48
                 }
49 49
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50 50
             }
51 51
             else {
52
-                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
52
+                logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING);
53 53
                 return false;
54 54
             }
55 55
         }
56 56
         else {
57
-            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
57
+            logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
58 58
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 59
         }
60 60
     }
Please login to merge, or discard this patch.
tools/convert.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @return string
23 23
      */
24
-    public static function byteFormat (int $byte, int $precision = 2): string {
24
+    public static function byteFormat(int $byte, int $precision = 2): string {
25 25
         $rate_counter = 0;
26 26
 
27
-        while ($byte > 1024){
27
+        while ($byte > 1024) {
28 28
             $byte /= 1024;
29 29
             $rate_counter++;
30 30
         }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             $byte = round($byte, $precision);
34 34
         }
35 35
 
36
-        return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
36
+        return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter];
37 37
     }
38 38
 
39 39
     /**
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return string|false return false when mode is incorrect
52 52
      */
53
-    public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false {
53
+    public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false {
54 54
         return match ($mode) {
55
-            parseMode::HTML => str_replace(['&', '<', '>',], ["&amp;", "&lt;", "&gt;",], $text),
56
-            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text),
55
+            parseMode::HTML => str_replace(['&', '<', '>', ], ["&amp;", "&lt;", "&gt;", ], $text),
56
+            parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text),
57 57
             parseMode::MARKDOWNV2 => str_replace(
58 58
                 ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'],
59 59
                 ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'],
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
      * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string}
93 93
      * @throws Exception
94 94
      */
95
-    public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array {
95
+    public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array {
96 96
         if (!isset($base_time)) {
97 97
             $base_time = '@'.time();
98 98
         }
99 99
         $base_time = new DateTime($base_time);
100
-        $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00');
100
+        $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00');
101 101
 
102 102
         $diff = $base_time->diff($target_time);
103 103
 
Please login to merge, or discard this patch.
tools/file.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...)
28 28
      */
29
-    public static function size (string $path, bool $format = true): string|int|false {
29
+    public static function size(string $path, bool $format = true): string | int | false {
30 30
         if (filter_var($path, FILTER_VALIDATE_URL)) {
31 31
             $ch = curl_init($path);
32 32
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      * @return bool
59 59
      * @throws bptException
60 60
      */
61
-    public static function delete (string $path, bool $sub = true): bool {
61
+    public static function delete(string $path, bool $sub = true): bool {
62 62
         if (is_dir($path)) {
63 63
             if (count(scandir($path)) > 2) {
64 64
                 if ($sub) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                     return rmdir($path);
71 71
                 }
72 72
                 else {
73
-                    logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value",loggerTypes::ERROR);
73
+                    logger::write("tools::delete function used\ndelete function cannot delete folder because its have subFiles and sub parameter haven't true value", loggerTypes::ERROR);
74 74
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
75 75
                 }
76 76
             }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @return bool
91 91
      * @throws bptException when zip extension not found
92 92
      */
93
-    public static function zip (string $path, string $destination): bool {
93
+    public static function zip(string $path, string $destination): bool {
94 94
         if (extension_loaded('zip')) {
95 95
             $rootPath = realpath($path);
96 96
             $zip = new ZipArchive();
Please login to merge, or discard this patch.
api/request/answer.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,32 +11,32 @@  discard block
 block discarded – undo
11 11
 class answer {
12 12
     private static bool $is_answered = false;
13 13
 
14
-    public static function init(string $method,array $data) {
14
+    public static function init(string $method, array $data) {
15 15
         self::checkAnswered();
16 16
         self::checkWebhook();
17 17
         self::sieveData($data);
18 18
         self::$is_answered = true;
19 19
         $data['method'] = $method;
20 20
         $payload = json_encode($data);
21
-        header('Content-Type: application/json;Content-Length: ' . strlen($payload));
21
+        header('Content-Type: application/json;Content-Length: '.strlen($payload));
22 22
         echo $payload;
23 23
         return true;
24 24
     }
25 25
 
26 26
     private static function checkAnswered() {
27 27
         if (self::$is_answered) {
28
-            logger::write('You can use answer mode only once for each webhook update , You already did it!',loggerTypes::ERROR);
28
+            logger::write('You can use answer mode only once for each webhook update , You already did it!', loggerTypes::ERROR);
29 29
             throw new bptException('ANSWER_MODE_USED');
30 30
         }
31 31
     }
32 32
 
33 33
     private static function checkWebhook() {
34
-        if(settings::$receiver === receiver::GETUPDATES) {
35
-            logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
34
+        if (settings::$receiver === receiver::GETUPDATES) {
35
+            logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR);
36 36
             throw new bptException('ANSWER_MODE_GETUPDATES');
37 37
         }
38
-        elseif(settings::$multi) {
39
-            logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
38
+        elseif (settings::$multi) {
39
+            logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR);
40 40
             throw new bptException('ANSWER_MODE_MULTI');
41 41
         }
42 42
     }
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
         unset($data['forgot']);
47 47
         unset($data['return_array']);
48 48
 
49
-        foreach ($data as $key=>&$value){
50
-            if (!isset($value)){
49
+        foreach ($data as $key=>&$value) {
50
+            if (!isset($value)) {
51 51
                 unset($data[$key]);
52 52
             }
53
-            elseif (is_array($value) || is_object($value)){
53
+            elseif (is_array($value) || is_object($value)) {
54 54
                 $value = json_encode($value);
55 55
             }
56 56
         }
Please login to merge, or discard this patch.