Passed
Push — main ( 7044f1...4122b8 )
by Miaad
01:31
created
tools/is.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -175,8 +175,9 @@
 block discarded – undo
175 175
             if (telegram::$status) {
176 176
                 $check = $check->status;
177 177
                 $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED;
178
+            } else {
179
+                $result[$id] = null;
178 180
             }
179
-            else $result[$id] = null;
180 181
         }
181 182
         return $result;
182 183
     }
Please login to merge, or discard this patch.
tools/file.php 1 patch
Braces   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,15 +35,15 @@  discard block
 block discarded – undo
35 35
             curl_exec($ch);
36 36
             $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
37 37
             curl_close($ch);
38
-        }
39
-        else {
38
+        } else {
40 39
             $size = file_exists($path) ? filesize($path) : false;
41 40
         }
42 41
 
43 42
         if (isset($size) && is_numeric($size)) {
44 43
             return $format ? tools::byteFormat($size) : $size;
44
+        } else {
45
+            return false;
45 46
         }
46
-        else return false;
47 47
     }
48 48
 
49 49
     /**
@@ -69,15 +69,16 @@  discard block
 block discarded – undo
69 69
                         $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
70 70
                     }
71 71
                     return rmdir($path);
72
-                }
73
-                else {
72
+                } else {
74 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);
75 74
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
76 75
                 }
76
+            } else {
77
+                return rmdir($path);
77 78
             }
78
-            else return rmdir($path);
79
+        } else {
80
+            return unlink($path);
79 81
         }
80
-        else return unlink($path);
81 82
     }
82 83
 
83 84
     /**
@@ -95,7 +96,9 @@  discard block
 block discarded – undo
95 96
      */
96 97
     public static function zip (string $path, string $destination, bool $self = true, bool $sub_folder = true): bool {
97 98
         if (extension_loaded('zip')) {
98
-            if (file_exists($destination)) unlink($destination);
99
+            if (file_exists($destination)) {
100
+                unlink($destination);
101
+            }
99 102
 
100 103
             $path = realpath($path);
101 104
             $zip = new ZipArchive();
@@ -121,23 +124,19 @@  discard block
 block discarded – undo
121 124
                     if ($file->isFile()){
122 125
                         if ($sub_folder){
123 126
                             $zip->addFile($file, str_replace($path . '\\', '', $file));
124
-                        }
125
-                        else{
127
+                        } else{
126 128
                             $zip->addFile($file, basename($file));
127 129
                         }
128
-                    }
129
-                    elseif ($file->isDir() && $sub_folder) {
130
+                    } elseif ($file->isDir() && $sub_folder) {
130 131
                         $zip->addEmptyDir(str_replace($path . '\\', '', $file . '\\'));
131 132
                     }
132 133
                 }
133
-            }
134
-            else{
134
+            } else{
135 135
                 $zip->addFile($path, basename($path));
136 136
             }
137 137
 
138 138
             return $zip->close();
139
-        }
140
-        else {
139
+        } else {
141 140
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
142 141
             throw new bptException('ZIP_EXTENSION_MISSING');
143 142
         }
Please login to merge, or discard this patch.
tools/generator.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -76,15 +76,12 @@  discard block
 block discarded – undo
76 76
                     if (count($button_info) > 1) {
77 77
                         if ($button_info[1] === 'con') {
78 78
                             $button->setRequest_contact(true);
79
-                        }
80
-                        elseif ($button_info[1] === 'loc') {
79
+                        } elseif ($button_info[1] === 'loc') {
81 80
                             $button->setRequest_location(true);
82
-                        }
83
-                        elseif ($button_info[1] === 'poll') {
81
+                        } elseif ($button_info[1] === 'poll') {
84 82
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
85 83
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
86
-                        }
87
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
84
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
88 85
                             $url = $button_info[2];
89 86
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
90 87
                         }
@@ -94,8 +91,7 @@  discard block
 block discarded – undo
94 91
                 $keyboard_object->setKeyboard([$buttons]);
95 92
             }
96 93
             return $keyboard_object;
97
-        }
98
-        elseif (!empty($inline)) {
94
+        } elseif (!empty($inline)) {
99 95
             $keyboard_object = new inlineKeyboardMarkup();
100 96
             foreach ($inline as $row) {
101 97
                 $buttons = [];
@@ -104,20 +100,17 @@  discard block
 block discarded – undo
104 100
                     if (isset($button_info[1])) {
105 101
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
106 102
                             $button->setText($button_info[0])->setUrl($button_info[1]);
107
-                        }
108
-                        else {
103
+                        } else {
109 104
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
110 105
                         }
111
-                    }
112
-                    else {
106
+                    } else {
113 107
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
114 108
                     }
115 109
                 }
116 110
                 $keyboard_object->setInline_keyboard([$buttons]);
117 111
             }
118 112
             return $keyboard_object;
119
-        }
120
-        else {
113
+        } else {
121 114
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
122 115
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
123 116
         }
Please login to merge, or discard this patch.
tools/encrypt.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
                 $iv = self::randomString();
38 38
                 $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
39 39
                 return ['hash' => $output, 'key' => $key, 'iv' => $iv];
40
-            }
41
-            elseif ($action === cryptoAction::DECRYPT) {
40
+            } elseif ($action === cryptoAction::DECRYPT) {
42 41
                 if (empty($key)) {
43 42
                     logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
44 43
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
@@ -48,13 +47,11 @@  discard block
 block discarded – undo
48 47
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
49 48
                 }
50 49
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
51
-            }
52
-            else {
50
+            } else {
53 51
                 logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`");
54 52
                 return false;
55 53
             }
56
-        }
57
-        else {
54
+        } else {
58 55
             logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
59 56
             throw new bptException('OPENSSL_EXTENSION_MISSING');
60 57
         }
Please login to merge, or discard this patch.
tools/convert.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,8 +106,9 @@
 block discarded – undo
106 106
         foreach ($string as $k => &$v) {
107 107
             if ($diff->$v) {
108 108
                 $v = $diff->$v;
109
+            } else {
110
+                unset($string[$k]);
109 111
             }
110
-            else unset($string[$k]);
111 112
         }
112 113
         $string['status'] = $status;
113 114
 
Please login to merge, or discard this patch.