@@ -12,11 +12,9 @@ |
||
12 | 12 | public static function init() { |
13 | 13 | if (lock::exist('BPT-MULTI-EXEC')) { |
14 | 14 | self::setUpdate(exec::init()); |
15 | - } |
|
16 | - elseif(lock::exist('BPT-MULTI-CURL')) { |
|
15 | + } elseif(lock::exist('BPT-MULTI-CURL')) { |
|
17 | 16 | self::setUpdate(curl::init()); |
18 | - } |
|
19 | - else { |
|
17 | + } else { |
|
20 | 18 | self::deleteOldLocks(); |
21 | 19 | self::checkURL(); |
22 | 20 | self::setCertificate(); |
@@ -22,8 +22,7 @@ discard block |
||
22 | 22 | self::handleUpdates($updates); |
23 | 23 | lock::save('getUpdate',BPT::$update->update_id+1); |
24 | 24 | $last_update_id = BPT::$update->update_id+1; |
25 | - } |
|
26 | - else { |
|
25 | + } else { |
|
27 | 26 | logger::write("There is some problem happened , telegram response : \n".json_encode($updates),loggerTypes::ERROR); |
28 | 27 | BPT::exit(print_r($updates,true)); |
29 | 28 | } |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | private static function loadData(): bool|int|string { |
35 | 34 | if (lock::exist('getUpdate')) { |
36 | 35 | $last_update_id = lock::read('getUpdate'); |
37 | - } |
|
38 | - else { |
|
36 | + } else { |
|
39 | 37 | self::deleteOldLocks(); |
40 | 38 | telegram::deleteWebhook(); |
41 | 39 | $last_update_id = 0; |
@@ -34,8 +34,7 @@ discard block |
||
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 |
||
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 | } |
@@ -702,12 +702,10 @@ discard block |
||
702 | 702 | self::setDefaults($action,$arguments); |
703 | 703 | if (isset($arguments['answer'])) { |
704 | 704 | return answer::init($action,$arguments); |
705 | - } |
|
706 | - else { |
|
705 | + } else { |
|
707 | 706 | return self::processResponse($action,curl::init($action,$arguments)); |
708 | 707 | } |
709 | - } |
|
710 | - else { |
|
708 | + } else { |
|
711 | 709 | logger::write("$name method is not supported",loggerTypes::ERROR); |
712 | 710 | throw new bptException('METHOD_NOT_FOUND'); |
713 | 711 | } |
@@ -733,8 +731,7 @@ discard block |
||
733 | 731 | $arguments['media'][$key]['media'] = new CURLFile($media['media']); |
734 | 732 | } |
735 | 733 | } |
736 | - } |
|
737 | - elseif ($file_params = self::methodFile($name)) { |
|
734 | + } elseif ($file_params = self::methodFile($name)) { |
|
738 | 735 | foreach ($file_params as $param) { |
739 | 736 | if (isset($arguments[$param]) && file_exists($arguments[$param])) { |
740 | 737 | $arguments[$param] = new CURLFile($arguments[$param]); |
@@ -756,12 +753,10 @@ discard block |
||
756 | 753 | $value = new ($return[0]) ($value); |
757 | 754 | } |
758 | 755 | return $response; |
759 | - } |
|
760 | - else { |
|
756 | + } else { |
|
761 | 757 | return new ($return) ($response->result); |
762 | 758 | } |
763 | - } |
|
764 | - else { |
|
759 | + } else { |
|
765 | 760 | return $response->result; |
766 | 761 | } |
767 | 762 | } |
@@ -773,8 +768,7 @@ discard block |
||
773 | 768 | if (!isset($arguments[$default])){ |
774 | 769 | $arguments[$default] = self::catchFields($default); |
775 | 770 | } |
776 | - } |
|
777 | - elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
771 | + } elseif (isset(BPT::$update->$key) || $key === 'other') { |
|
778 | 772 | foreach ($default as $def) { |
779 | 773 | if (!isset($arguments[$def])){ |
780 | 774 | $arguments[$def] = self::catchFields($def); |
@@ -790,8 +784,7 @@ discard block |
||
790 | 784 | self::$status = true; |
791 | 785 | self::$pure_response = $response; |
792 | 786 | return self::methodReturn($name,$response); |
793 | - } |
|
794 | - else { |
|
787 | + } else { |
|
795 | 788 | self::$status = false; |
796 | 789 | self::$pure_response = $response; |
797 | 790 | return new responseError($response); |
@@ -827,9 +820,13 @@ discard block |
||
827 | 820 | default => false |
828 | 821 | }; |
829 | 822 | case 'file_id' : |
830 | - if (isset(BPT::$update->message)) $type = 'message'; |
|
831 | - elseif (isset(BPT::$update->edited_message)) $type = 'edited_message'; |
|
832 | - else return false; |
|
823 | + if (isset(BPT::$update->message)) { |
|
824 | + $type = 'message'; |
|
825 | + } elseif (isset(BPT::$update->edited_message)) { |
|
826 | + $type = 'edited_message'; |
|
827 | + } else { |
|
828 | + return false; |
|
829 | + } |
|
833 | 830 | |
834 | 831 | return match(true) { |
835 | 832 | isset(BPT::$update->$type->animation) => BPT::$update->$type->animation->file_id, |
@@ -6,8 +6,7 @@ |
||
6 | 6 | public function __call (string $name, array $arguments) { |
7 | 7 | if (!isset($arguments[1]) && isset($arguments[0]) && is_array($arguments[0])) { |
8 | 8 | return request::$name(...$arguments[0]); |
9 | - } |
|
10 | - else { |
|
9 | + } else { |
|
11 | 10 | return request::$name(...$arguments); |
12 | 11 | } |
13 | 12 | } |
@@ -175,8 +175,9 @@ |
||
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 | } |
@@ -35,14 +35,14 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -105,8 +105,9 @@ |
||
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 |
@@ -17,21 +17,18 @@ discard block |
||
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 |
||
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 | } |