Passed
Push — main ( d761d2...4cb247 )
by Miaad
10:19
created
src/tools/file.php 1 patch
Braces   +16 added lines, -13 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
         }
@@ -129,9 +128,13 @@  discard block
 block discarded – undo
129 128
      */
130 129
     public static function downloadFile (string $url, string $path,int $chunk_size = 512): bool {
131 130
         $file = fopen($url, 'rb');
132
-        if (!$file) return false;
131
+        if (!$file) {
132
+            return false;
133
+        }
133 134
         $path = fopen($path, 'wb');
134
-        if (!$path) return false;
135
+        if (!$path) {
136
+            return false;
137
+        }
135 138
 
136 139
         $length = $chunk_size * 1024;
137 140
         while (!feof($file)){
Please login to merge, or discard this patch.
src/api/request/curl.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
             $curl_handler = curl_init(settings::$base_url."/bot$token/");
42 42
             curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
43 43
             curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
44
-        }
45
-        else{
44
+        } else{
46 45
             $token = settings::$token;
47 46
             if (!isset(self::$curl_handler)){
48 47
                 self::$curl_handler = curl_init(settings::$base_url."/bot$token/");
@@ -64,11 +63,9 @@  discard block
 block discarded – undo
64 63
         if (isset($data['forgot'])) {
65 64
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$forgot_time);
66 65
             unset($data['forgot']);
67
-        }
68
-        elseif ($method === 'getUpdates'){
66
+        } elseif ($method === 'getUpdates'){
69 67
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, 5000);
70
-        }
71
-        else{
68
+        } else{
72 69
             curl_setopt($curl_handler, CURLOPT_TIMEOUT_MS, settings::$base_timeout);
73 70
         }
74 71
     }
Please login to merge, or discard this patch.
src/api/request.php 1 patch
Braces   +14 added lines, -17 removed lines patch added patch discarded remove patch
@@ -709,16 +709,14 @@  discard block
 block discarded – undo
709 709
             self::setDefaults($action,$arguments);
710 710
             if (isset($arguments['answer'])) {
711 711
                 return answer::init($action,$arguments);
712
-            }
713
-            else {
712
+            } else {
714 713
                 $result = curl::init($action,$arguments);
715 714
                 if (is_object($result)) {
716 715
                     return self::processResponse($action,$result);
717 716
                 }
718 717
                 return false;
719 718
             }
720
-        }
721
-        else {
719
+        } else {
722 720
             logger::write("$name method is not supported",loggerTypes::ERROR);
723 721
             throw new bptException('METHOD_NOT_FOUND');
724 722
         }
@@ -744,8 +742,7 @@  discard block
 block discarded – undo
744 742
                     $arguments['media'][$key]['media'] = new CURLFile($media['media']);
745 743
                 }
746 744
             }
747
-        }
748
-        elseif ($file_params = self::methodFile($name)) {
745
+        } elseif ($file_params = self::methodFile($name)) {
749 746
             foreach ($file_params as $param) {
750 747
                 if (isset($arguments[$param]) && file_exists($arguments[$param])) {
751 748
                     $arguments[$param] = new CURLFile($arguments[$param]);
@@ -767,12 +764,10 @@  discard block
 block discarded – undo
767 764
                     $value = new ($return[0]) ($value);
768 765
                 }
769 766
                 return $response;
770
-            }
771
-            else {
767
+            } else {
772 768
                 return new ($return) ($response->result);
773 769
             }
774
-        }
775
-        else {
770
+        } else {
776 771
             return $response->result;
777 772
         }
778 773
     }
@@ -784,8 +779,7 @@  discard block
 block discarded – undo
784 779
                 if (!isset($arguments[$default])){
785 780
                     $arguments[$default] = self::catchFields($default);
786 781
                 }
787
-            }
788
-            elseif (isset(BPT::$update->$key) || $key === 'other') {
782
+            } elseif (isset(BPT::$update->$key) || $key === 'other') {
789 783
                 foreach ($default as $def) {
790 784
                     if (!isset($arguments[$def])){
791 785
                         $arguments[$def] = self::catchFields($def);
@@ -801,8 +795,7 @@  discard block
 block discarded – undo
801 795
             self::$status = true;
802 796
             self::$pure_response = $response;
803 797
             return self::methodReturn($name,$response);
804
-        }
805
-        else {
798
+        } else {
806 799
             self::$status = false;
807 800
             self::$pure_response = $response;
808 801
             return new responseError($response);
@@ -845,9 +838,13 @@  discard block
 block discarded – undo
845 838
                     default => false
846 839
                 };
847 840
             case fields::FILE_ID :
848
-                if (isset(BPT::$update->message)) $type = 'message';
849
-                elseif (isset(BPT::$update->edited_message)) $type = 'edited_message';
850
-                else return false;
841
+                if (isset(BPT::$update->message)) {
842
+                    $type = 'message';
843
+                } elseif (isset(BPT::$update->edited_message)) {
844
+                    $type = 'edited_message';
845
+                } else {
846
+                    return false;
847
+                }
851 848
 
852 849
                 return match(true) {
853 850
                     isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id,
Please login to merge, or discard this patch.
src/api/telegram.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@  discard block
 block discarded – undo
11 11
     public function __call (string $name, array $arguments) {
12 12
         if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) {
13 13
             return request::$name(...$arguments[0]);
14
-        }
15
-        else {
14
+        } else {
16 15
             return request::$name(...$arguments);
17 16
         }
18 17
     }
@@ -36,8 +35,7 @@  discard block
 block discarded – undo
36 35
         if (isset($file->file_path)) {
37 36
             $file_path = settings::$down_url.'bot'.settings::$token.'/'.$file->file_path;
38 37
             return tools::downloadFile($file_path,$destination);
39
-        }
40
-        else {
38
+        } else {
41 39
             return false;
42 40
         }
43 41
     }
Please login to merge, or discard this patch.