Passed
Push — main ( 4122b8...60aebc )
by Miaad
01:36
created
api/request.php 1 patch
Braces   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -706,12 +706,10 @@  discard block
 block discarded – undo
706 706
             self::setDefaults($action,$arguments);
707 707
             if (isset($arguments['answer'])) {
708 708
                 return answer::init($action,$arguments);
709
-            }
710
-            else {
709
+            } else {
711 710
                 return self::processResponse($action,curl::init($action,$arguments));
712 711
             }
713
-        }
714
-        else {
712
+        } else {
715 713
             logger::write("$name method is not supported",loggerTypes::ERROR);
716 714
             throw new bptException('METHOD_NOT_FOUND');
717 715
         }
@@ -737,8 +735,7 @@  discard block
 block discarded – undo
737 735
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
738 736
                 }
739 737
             }
740
-        }
741
-        elseif ($file_params = self::methodFile($name)) {
738
+        } elseif ($file_params = self::methodFile($name)) {
742 739
             foreach ($file_params as $param) {
743 740
                 if (isset($arguments[$param]) && file_exists($arguments[$param])) {
744 741
                     $arguments[$param] = new CURLFile($arguments[$param]);
@@ -760,12 +757,10 @@  discard block
 block discarded – undo
760 757
                     $value = new ($return[0]) ($value);
761 758
                 }
762 759
                 return $response;
763
-            }
764
-            else {
760
+            } else {
765 761
                 return new ($return) ($response->result);
766 762
             }
767
-        }
768
-        else {
763
+        } else {
769 764
             return $response->result;
770 765
         }
771 766
     }
@@ -777,8 +772,7 @@  discard block
 block discarded – undo
777 772
                 if (!isset($arguments[$default])){
778 773
                     $arguments[$default] = self::catchFields($default);
779 774
                 }
780
-            }
781
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
775
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
782 776
                 foreach ($default as $def) {
783 777
                     if (!isset($arguments[$def])){
784 778
                         $arguments[$def] = self::catchFields($def);
@@ -794,8 +788,7 @@  discard block
 block discarded – undo
794 788
             self::$status = true;
795 789
             self::$pure_response = $response;
796 790
             return self::methodReturn($name,$response);
797
-        }
798
-        else {
791
+        } else {
799 792
             self::$status = false;
800 793
             self::$pure_response = $response;
801 794
             return new responseError($response);
@@ -831,9 +824,13 @@  discard block
 block discarded – undo
831 824
                     default => false
832 825
                 };
833 826
             case 'file_id' :
834
-                if (isset(BPT::$update->message)) $type = 'message';
835
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
836
-                else return false;
827
+                if (isset(BPT::$update->message)) {
828
+                    $type = 'message';
829
+                } elseif (isset(BPT::$update->edited_message)) {
830
+                    $type = 'edited_message';
831
+                } else {
832
+                    return false;
833
+                }
837 834
 
838 835
                 return match(true) {
839 836
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.
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/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   +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.