Passed
Branch main (405ee4)
by Miaad
02:11
created
types/types.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,21 +17,18 @@  discard block
 block discarded – undo
17 17
         foreach ($object as $key=>$value) {
18 18
             if (isset($subs[$key])) {
19 19
                 $this->$key = new ($subs[$key]) ($value);
20
-            }
21
-            else {
20
+            } else {
22 21
                 if (is_array($value)) {
23 22
                     foreach ($value as $sub_key=>$sub_value) {
24 23
                         if (is_array($sub_value)) {
25 24
                             foreach ($sub_value as $sub2_value) {
26 25
                                 $this->$key[$sub_key][] = new ($subs['array']['array'][$key]) ($sub2_value);
27 26
                             }
28
-                        }
29
-                        else{
27
+                        } else{
30 28
                             $this->$key[] = new ($subs['array'][$key]) ($sub_value);
31 29
                         }
32 30
                     }
33
-                }
34
-                else{
31
+                } else{
35 32
                     $this->$key = $value;
36 33
                     if (ucfirst($key) === basename(get_class($this)).'_id') {
37 34
                         $this->{'id'} = $value;
@@ -48,8 +45,7 @@  discard block
 block discarded – undo
48 45
             $name = substr($name,3);
49 46
             if (isset($arguments[0])) {
50 47
                 $this->$name = $arguments[0];
51
-            }
52
-            elseif (isset($arguments['value'])) {
48
+            } elseif (isset($arguments['value'])) {
53 49
                 $this->$name = $arguments['value'];
54 50
             }
55 51
         }
Please login to merge, or discard this patch.
database/handler.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -62,13 +62,11 @@  discard block
 block discarded – undo
62 62
                     if ($db) {
63 63
                         self::$connect = $db;
64 64
                         print_r($db);
65
-                    }
66
-                    else {
65
+                    } else {
67 66
                         print self::$username;
68 67
                         throw new \exception('a problem to connecting');
69 68
                     }
70
-                }
71
-                else {
69
+                } else {
72 70
                     throw new \exception('required parameters not found');
73 71
                 }
74 72
             }
@@ -77,13 +75,11 @@  discard block
 block discarded – undo
77 75
                     self::$type = $settings['type'];
78 76
                     self::$dbname = $settings['dbname'];
79 77
                     (new database())->json_init();
80
-                }
81
-                else {
78
+                } else {
82 79
                     throw new \exception('parameter dbanme not found');
83 80
                 }
84 81
             }
85
-        }
86
-        else {
82
+        } else {
87 83
             throw new \exception('parameter type not found');
88 84
         }
89 85
     }
@@ -96,8 +92,7 @@  discard block
 block discarded – undo
96 92
             self::$password = $array['password'];
97 93
             self::$charset = $array['charset'] ?? 'utf8';
98 94
             return true;
99
-        }
100
-        else {
95
+        } else {
101 96
             return false;
102 97
         }
103 98
     }
Please login to merge, or discard this patch.
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/encrypt.php 1 patch
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,24 +36,20 @@
 block discarded – undo
36 36
                 $iv = self::randomString();
37 37
                 $output = base64_encode(openssl_encrypt($text, 'AES-256-CBC', $key, 1, $iv));
38 38
                 return ['hash' => $output, 'key' => $key, 'iv' => $iv];
39
-            }
40
-            elseif ($action === cryptoAction::DECRYPT) {
39
+            } elseif ($action === cryptoAction::DECRYPT) {
41 40
                 if (empty($key)) {
42 41
                     logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR);
43 42
                     throw new bptException('ARGUMENT_NOT_FOUND_KEY');
44
-                }
45
-                elseif (empty($iv)) {
43
+                } elseif (empty($iv)) {
46 44
                     logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR);
47 45
                     throw new bptException('ARGUMENT_NOT_FOUND_IV');
48 46
                 }
49 47
                 return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv);
50
-            }
51
-            else {
48
+            } else {
52 49
                 logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING);
53 50
                 return false;
54 51
             }
55
-        }
56
-        else {
52
+        } else {
57 53
             logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR);
58 54
             throw new bptException('OPENSSL_EXTENSION_MISSING');
59 55
         }
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
@@ -105,8 +105,9 @@
 block discarded – undo
105 105
         foreach ($string as $k => &$v) {
106 106
             if ($diff->$v) {
107 107
                 $v = $diff->$v;
108
+            } else {
109
+                unset($string[$k]);
108 110
             }
109
-            else unset($string[$k]);
110 111
         }
111 112
         $string['status'] = $base_time < $target_time ? 'later' : 'ago';
112 113
 
Please login to merge, or discard this patch.
tools/file.php 1 patch
Braces   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,14 +35,14 @@  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
         if (isset($size) && is_numeric($size)) {
43 42
             return $format ? tools::byteFormat($size) : $size;
43
+        } else {
44
+            return false;
44 45
         }
45
-        else return false;
46 46
     }
47 47
 
48 48
     /**
@@ -68,15 +68,16 @@  discard block
 block discarded – undo
68 68
                         $file->isDir() ? rmdir($file->getRealPath()) : unlink($file->getRealPath());
69 69
                     }
70 70
                     return rmdir($path);
71
-                }
72
-                else {
71
+                } else {
73 72
                     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 73
                     throw new bptException('DELETE_FOLDER_HAS_SUB');
75 74
                 }
75
+            } else {
76
+                return rmdir($path);
76 77
             }
77
-            else return rmdir($path);
78
+        } else {
79
+            return unlink($path);
78 80
         }
79
-        else return unlink($path);
80 81
     }
81 82
 
82 83
     /**
@@ -104,13 +105,11 @@  discard block
 block discarded – undo
104 105
                         $zip->addFile($filePath, substr($filePath, $root_len));
105 106
                     }
106 107
                 }
107
-            }
108
-            else {
108
+            } else {
109 109
                 $zip->addFile($path, basename($path));
110 110
             }
111 111
             return $zip->close();
112
-        }
113
-        else {
112
+        } else {
114 113
             logger::write("tools::zip function used\nzip extension is not found , It may not be installed or enabled", loggerTypes::ERROR);
115 114
             throw new bptException('ZIP_EXTENSION_MISSING');
116 115
         }
Please login to merge, or discard this patch.
api/request/answer.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
         if(settings::$receiver === receiver::GETUPDATES) {
35 35
             logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
36 36
             throw new bptException('ANSWER_MODE_GETUPDATES');
37
-        }
38
-        elseif(settings::$multi) {
37
+        } elseif(settings::$multi) {
39 38
             logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
40 39
             throw new bptException('ANSWER_MODE_MULTI');
41 40
         }
@@ -49,8 +48,7 @@  discard block
 block discarded – undo
49 48
         foreach ($data as $key=>&$value){
50 49
             if (!isset($value)){
51 50
                 unset($data[$key]);
52
-            }
53
-            elseif (is_array($value) || is_object($value)){
51
+            } elseif (is_array($value) || is_object($value)){
54 52
                 $value = json_encode($value);
55 53
             }
56 54
         }
Please login to merge, or discard this patch.
settings.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,11 +58,9 @@  discard block
 block discarded – undo
58 58
         foreach ($settings as $setting => $value) {
59 59
             try{
60 60
                 self::$$setting = $value;
61
-            }
62
-            catch (TypeError){
61
+            } catch (TypeError){
63 62
                 logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
64
-            }
65
-            catch (Error){
63
+            } catch (Error){
66 64
                 logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
67 65
             }
68 66
         }
@@ -75,13 +73,11 @@  discard block
 block discarded – undo
75 73
                 if (!empty(self::$receiver)) {
76 74
                     self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates();
77 75
                 }
78
-            }
79
-            else {
76
+            } else {
80 77
                 logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
81 78
                 throw new bptException('TOKEN_NOT_TRUE');
82 79
             }
83
-        }
84
-        else {
80
+        } else {
85 81
             logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
86 82
             throw new bptException('TOKEN_NOT_FOUND');
87 83
         }
@@ -138,8 +134,7 @@  discard block
 block discarded – undo
138 134
     private static function getUpdates() {
139 135
         if (self::$handler) {
140 136
             getUpdates::init();
141
-        }
142
-        else {
137
+        } else {
143 138
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
144 139
             throw new bptException('GETUPDATE_NEED_HANDLER');
145 140
         }
Please login to merge, or discard this patch.
tools/generator.php 1 patch
Braces   +10 added lines, -15 removed lines patch added patch discarded remove patch
@@ -68,7 +68,9 @@  discard block
 block discarded – undo
68 68
                 $keyboard_object->setOne_time_keyboard($keyboard['one_time']);
69 69
             }
70 70
             foreach ($keyboard as $row) {
71
-                if (!is_array($row)) continue;
71
+                if (!is_array($row)) {
72
+                    continue;
73
+                }
72 74
                 $buttons = [];
73 75
                 foreach ($row as $base_button) {
74 76
                     $button_info = explode('||', $base_button);
@@ -77,15 +79,12 @@  discard block
 block discarded – undo
77 79
                     if (count($button_info) > 1) {
78 80
                         if ($button_info[1] === 'con') {
79 81
                             $button->setRequest_contact(true);
80
-                        }
81
-                        elseif ($button_info[1] === 'loc') {
82
+                        } elseif ($button_info[1] === 'loc') {
82 83
                             $button->setRequest_location(true);
83
-                        }
84
-                        elseif ($button_info[1] === 'poll') {
84
+                        } elseif ($button_info[1] === 'poll') {
85 85
                             $type = $button_info[2] === pollType::QUIZ ? pollType::QUIZ : pollType::REGULAR;
86 86
                             $button->setRequest_poll((new keyboardButtonPollType())->setType($type));
87
-                        }
88
-                        elseif ($button_info[1] === 'web' && isset($button_info[2])) {
87
+                        } elseif ($button_info[1] === 'web' && isset($button_info[2])) {
89 88
                             $url = $button_info[2];
90 89
                             $button->setWeb_app((new webAppInfo())->setUrl($url));
91 90
                         }
@@ -95,8 +94,7 @@  discard block
 block discarded – undo
95 94
                 $keyboard_object->setKeyboard([$buttons]);
96 95
             }
97 96
             return $keyboard_object;
98
-        }
99
-        elseif (!empty($inline)) {
97
+        } elseif (!empty($inline)) {
100 98
             $keyboard_object = new inlineKeyboardMarkup();
101 99
             foreach ($inline as $row) {
102 100
                 $buttons = [];
@@ -105,20 +103,17 @@  discard block
 block discarded – undo
105 103
                     if (isset($button_info[1])) {
106 104
                         if (filter_var($button_info[1], FILTER_VALIDATE_URL) && str_starts_with($button_info[1], 'http')) {
107 105
                             $button->setText($button_info[0])->setUrl($button_info[1]);
108
-                        }
109
-                        else {
106
+                        } else {
110 107
                             $button->setText($button_info[0])->setCallback_data($button_info[1]);
111 108
                         }
112
-                    }
113
-                    else {
109
+                    } else {
114 110
                         $button->setText($button_info[0])->setUrl('https://t.me/BPT_CH');
115 111
                     }
116 112
                 }
117 113
                 $keyboard_object->setInline_keyboard([$buttons]);
118 114
             }
119 115
             return $keyboard_object;
120
-        }
121
-        else {
116
+        } else {
122 117
             logger::write("tools::eKey function used\nkeyboard or inline parameter must be set",loggerTypes::ERROR);
123 118
             throw new bptException('ARGUMENT_NOT_FOUND_KEYBOARD_INLINE');
124 119
         }
Please login to merge, or discard this patch.