@@ -11,7 +11,7 @@ |
||
| 11 | 11 | /** |
| 12 | 12 | * @method Json_init |
| 13 | 13 | */ |
| 14 | - public function json_init () { |
|
| 14 | + public function json_init() { |
|
| 15 | 15 | (new jsondb())->init(handler::$dbname); |
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * |
| 50 | 50 | */ |
| 51 | - public function __construct (array $settings) { |
|
| 51 | + public function __construct(array $settings) { |
|
| 52 | 52 | if (in_array($settings['type'], self::TYPES)) { |
| 53 | 53 | if ($settings['type'] === 'Mysqli') { |
| 54 | 54 | if (self::CheckParam($settings)) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private static function CheckParam (array $array) { |
|
| 91 | + private static function CheckParam(array $array) { |
|
| 92 | 92 | if (isset($array['username']) && isset($array['dbname']) && isset($array['password'])) { |
| 93 | 93 | self::$host = $array['host'] ?? 'localhost'; |
| 94 | 94 | self::$username = $array['username']; |
@@ -62,13 +62,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -7,4 +7,4 @@ |
||
| 7 | 7 | /** |
| 8 | 8 | * Exceptions created by BPT and subclasses |
| 9 | 9 | */ |
| 10 | -class bptException extends Exception{} |
|
| 11 | 10 | \ No newline at end of file |
| 11 | +class bptException extends Exception {} |
|
| 12 | 12 | \ No newline at end of file |
@@ -2,9 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace BPT; |
| 4 | 4 | |
| 5 | -use BPT\tools\{is,file,convert,generator,encrypt}; |
|
| 5 | +use BPT\tools\{is, file, convert, generator, encrypt}; |
|
| 6 | 6 | |
| 7 | -class tools{ |
|
| 7 | +class tools { |
|
| 8 | 8 | use is; |
| 9 | 9 | use file; |
| 10 | 10 | use convert; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return bool |
| 22 | 22 | */ |
| 23 | - public static function isUsername (string $username): bool { |
|
| 23 | + public static function isUsername(string $username): bool { |
|
| 24 | 24 | $length = strlen($username); |
| 25 | 25 | return !str_contains($username, '__') && $length >= 5 && $length <= 33 && preg_match('/^@?([a-zA-Z])(\w{4,31})$/', $username); |
| 26 | 26 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return bool |
| 39 | 39 | */ |
| 40 | - public static function ipInRange (string $ip, string $range): bool { |
|
| 40 | + public static function ipInRange(string $ip, string $range): bool { |
|
| 41 | 41 | if (!str_contains($range, '/')) { |
| 42 | 42 | $range .= '/32'; |
| 43 | 43 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public static function isTelegram (string $ip): bool { |
|
| 60 | + public static function isTelegram(string $ip): bool { |
|
| 61 | 61 | return tools::ipInRange($ip, '149.154.160.0/20') || tools::ipInRange($ip, '91.108.4.0/22'); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public static function isCloudFlare (string $ip): bool { |
|
| 75 | + public static function isCloudFlare(string $ip): bool { |
|
| 76 | 76 | $cf_ips = ['173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/12', '172.64.0.0/13', '131.0.72.0/22']; |
| 77 | 77 | foreach ($cf_ips as $cf_ip) { |
| 78 | - if (self::ipInRange($ip,$cf_ip)) { |
|
| 78 | + if (self::ipInRange($ip, $cf_ip)) { |
|
| 79 | 79 | return true; |
| 80 | 80 | } |
| 81 | 81 | } |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return bool|user return array when verify is active and token is true array of telegram getMe result |
| 97 | 97 | */ |
| 98 | - public static function isToken (string $token, bool $verify = false): bool|user { |
|
| 98 | + public static function isToken(string $token, bool $verify = false): bool | user { |
|
| 99 | 99 | if (preg_match('/^(\d{8,10}):[\w\-]{35}$/', $token)) { |
| 100 | - if ($verify){ |
|
| 100 | + if ($verify) { |
|
| 101 | 101 | $res = telegram::me($token); |
| 102 | 102 | if (telegram::$status) { |
| 103 | 103 | return $res; |
@@ -129,14 +129,14 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return bool |
| 131 | 131 | */ |
| 132 | - public static function isJoined (array|string|int $ids , int|null $user_id = null): bool { |
|
| 132 | + public static function isJoined(array | string | int $ids, int | null $user_id = null): bool { |
|
| 133 | 133 | if (!is_array($ids)) { |
| 134 | 134 | $ids = [$ids]; |
| 135 | 135 | } |
| 136 | 136 | $user_id = $user_id ?? request::catchFields('user_id'); |
| 137 | 137 | |
| 138 | 138 | foreach ($ids as $id) { |
| 139 | - $check = telegram::getChatMember($id,$user_id); |
|
| 139 | + $check = telegram::getChatMember($id, $user_id); |
|
| 140 | 140 | if (telegram::$status) { |
| 141 | 141 | $check = $check->status; |
| 142 | 142 | if ($check === chatMemberStatus::LEFT || $check === chatMemberStatus::KICKED) { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array keys will be id and values will be bool(null for not founded ids) |
| 165 | 165 | */ |
| 166 | - public static function joinChecker (array|string|int $ids , int|null $user_id = null): array { |
|
| 166 | + public static function joinChecker(array | string | int $ids, int | null $user_id = null): array { |
|
| 167 | 167 | if (!is_array($ids)) { |
| 168 | 168 | $ids = [$ids]; |
| 169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | $result = []; |
| 173 | 173 | foreach ($ids as $id) { |
| 174 | - $check = telegram::getChatMember($id,$user_id); |
|
| 174 | + $check = telegram::getChatMember($id, $user_id); |
|
| 175 | 175 | if (telegram::$status) { |
| 176 | 176 | $check = $check->status; |
| 177 | 177 | $result[$id] = $check !== chatMemberStatus::LEFT && $check !== chatMemberStatus::KICKED; |
@@ -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 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return string|bool|array{hash:string, key:string, iv:string} |
| 30 | 30 | * @throws bptException |
| 31 | 31 | */ |
| 32 | - public static function crypto (string $action, string $text, string $key = null, string $iv = null): bool|array|string { |
|
| 32 | + public static function crypto(string $action, string $text, string $key = null, string $iv = null): bool | array | string { |
|
| 33 | 33 | if (extension_loaded('openssl')) { |
| 34 | 34 | if ($action === cryptoAction::ENCRYPT) { |
| 35 | 35 | $key = self::randomString(64); |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | elseif ($action === cryptoAction::DECRYPT) { |
| 41 | 41 | if (empty($key)) { |
| 42 | - logger::write("tools::crypto function used\nkey parameter is not set",loggerTypes::ERROR); |
|
| 42 | + logger::write("tools::crypto function used\nkey parameter is not set", loggerTypes::ERROR); |
|
| 43 | 43 | throw new bptException('ARGUMENT_NOT_FOUND_KEY'); |
| 44 | 44 | } |
| 45 | 45 | elseif (empty($iv)) { |
| 46 | - logger::write("tools::crypto function used\niv parameter is not set",loggerTypes::ERROR); |
|
| 46 | + logger::write("tools::crypto function used\niv parameter is not set", loggerTypes::ERROR); |
|
| 47 | 47 | throw new bptException('ARGUMENT_NOT_FOUND_IV'); |
| 48 | 48 | } |
| 49 | 49 | return openssl_decrypt(base64_decode($text), 'AES-256-CBC', $key, 1, $iv); |
| 50 | 50 | } |
| 51 | 51 | else { |
| 52 | - logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`",loggerTypes::WARNING); |
|
| 52 | + logger::write("tools::crypto function used\naction is not right, its must be `encode` or `decode`", loggerTypes::WARNING); |
|
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | else { |
| 57 | - logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled",loggerTypes::ERROR); |
|
| 57 | + logger::write("tools::crypto function used\nopenssl extension is not found , It may not be installed or enabled", loggerTypes::ERROR); |
|
| 58 | 58 | throw new bptException('OPENSSL_EXTENSION_MISSING'); |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -36,24 +36,20 @@ |
||
| 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 | } |
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return string |
| 23 | 23 | */ |
| 24 | - public static function byteFormat (int $byte, int $precision = 2): string { |
|
| 24 | + public static function byteFormat(int $byte, int $precision = 2): string { |
|
| 25 | 25 | $rate_counter = 0; |
| 26 | 26 | |
| 27 | - while ($byte > 1024){ |
|
| 27 | + while ($byte > 1024) { |
|
| 28 | 28 | $byte /= 1024; |
| 29 | 29 | $rate_counter++; |
| 30 | 30 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $byte = round($byte, $precision); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - return $byte . ' ' . ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 36 | + return $byte.' '.['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'][$rate_counter]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string|false return false when mode is incorrect |
| 52 | 52 | */ |
| 53 | - public static function modeEscape (string $text, string $mode = parseMode::HTML): string|false { |
|
| 53 | + public static function modeEscape(string $text, string $mode = parseMode::HTML): string | false { |
|
| 54 | 54 | return match ($mode) { |
| 55 | - parseMode::HTML => str_replace(['&', '<', '>',], ["&", "<", ">",], $text), |
|
| 56 | - parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[',], $text), |
|
| 55 | + parseMode::HTML => str_replace(['&', '<', '>', ], ["&", "<", ">", ], $text), |
|
| 56 | + parseMode::MARKDOWN => str_replace(['\\', '_', '*', '`', '['], ['\\\\', '\_', '\*', '\`', '\[', ], $text), |
|
| 57 | 57 | parseMode::MARKDOWNV2 => str_replace( |
| 58 | 58 | ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\'], |
| 59 | 59 | ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!', '\\\\'], |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * @return array{status: string,year: string,month: string,day: string,hour: string,minute: string,second: string} |
| 93 | 93 | * @throws Exception |
| 94 | 94 | */ |
| 95 | - public static function timeDiff (int|string $target_time, int|string|null $base_time = null): array { |
|
| 95 | + public static function timeDiff(int | string $target_time, int | string | null $base_time = null): array { |
|
| 96 | 96 | if (!isset($base_time)) { |
| 97 | 97 | $base_time = '@'.time(); |
| 98 | 98 | } |
| 99 | 99 | $base_time = new DateTime($base_time); |
| 100 | - $target_time = new DateTime(is_numeric($target_time) ? '@' . $target_time : $target_time . ' +00:00'); |
|
| 100 | + $target_time = new DateTime(is_numeric($target_time) ? '@'.$target_time : $target_time.' +00:00'); |
|
| 101 | 101 | |
| 102 | 102 | $diff = $base_time->diff($target_time); |
| 103 | 103 | |
@@ -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 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return string|int|false string for formatted data , int for normal data , false when size can not be found(file not found or ...) |
| 28 | 28 | */ |
| 29 | - public static function size (string $path, bool $format = true): string|int|false { |
|
| 29 | + public static function size(string $path, bool $format = true): string | int | false { |
|
| 30 | 30 | if (filter_var($path, FILTER_VALIDATE_URL)) { |
| 31 | 31 | $ch = curl_init($path); |
| 32 | 32 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return bool |
| 59 | 59 | * @throws bptException |
| 60 | 60 | */ |
| 61 | - public static function delete (string $path, bool $sub = true): bool { |
|
| 61 | + public static function delete(string $path, bool $sub = true): bool { |
|
| 62 | 62 | if (is_dir($path)) { |
| 63 | 63 | if (count(scandir($path)) > 2) { |
| 64 | 64 | if ($sub) { |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | return rmdir($path); |
| 71 | 71 | } |
| 72 | 72 | else { |
| 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); |
|
| 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); |
|
| 74 | 74 | throw new bptException('DELETE_FOLDER_HAS_SUB'); |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return bool |
| 91 | 91 | * @throws bptException when zip extension not found |
| 92 | 92 | */ |
| 93 | - public static function zip (string $path, string $destination): bool { |
|
| 93 | + public static function zip(string $path, string $destination): bool { |
|
| 94 | 94 | if (extension_loaded('zip')) { |
| 95 | 95 | $rootPath = realpath($path); |
| 96 | 96 | $zip = new ZipArchive(); |
@@ -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 | } |
@@ -11,32 +11,32 @@ discard block |
||
| 11 | 11 | class answer {
|
| 12 | 12 | private static bool $is_answered = false; |
| 13 | 13 | |
| 14 | - public static function init(string $method,array $data) {
|
|
| 14 | + public static function init(string $method, array $data) {
|
|
| 15 | 15 | self::checkAnswered(); |
| 16 | 16 | self::checkWebhook(); |
| 17 | 17 | self::sieveData($data); |
| 18 | 18 | self::$is_answered = true; |
| 19 | 19 | $data['method'] = $method; |
| 20 | 20 | $payload = json_encode($data); |
| 21 | - header('Content-Type: application/json;Content-Length: ' . strlen($payload));
|
|
| 21 | + header('Content-Type: application/json;Content-Length: '.strlen($payload));
|
|
| 22 | 22 | echo $payload; |
| 23 | 23 | return true; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | private static function checkAnswered() {
|
| 27 | 27 | if (self::$is_answered) {
|
| 28 | - logger::write('You can use answer mode only once for each webhook update , You already did it!',loggerTypes::ERROR);
|
|
| 28 | + logger::write('You can use answer mode only once for each webhook update , You already did it!', loggerTypes::ERROR);
|
|
| 29 | 29 | throw new bptException('ANSWER_MODE_USED');
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | private static function checkWebhook() {
|
| 34 | - if(settings::$receiver === receiver::GETUPDATES) {
|
|
| 35 | - logger::write('Answer mode only work when receiver is webhook',loggerTypes::ERROR);
|
|
| 34 | + if (settings::$receiver === receiver::GETUPDATES) {
|
|
| 35 | + logger::write('Answer mode only work when receiver is webhook', loggerTypes::ERROR);
|
|
| 36 | 36 | throw new bptException('ANSWER_MODE_GETUPDATES');
|
| 37 | 37 | } |
| 38 | - elseif(settings::$multi) {
|
|
| 39 | - logger::write('You can not use answer mode when multi setting is on',loggerTypes::ERROR);
|
|
| 38 | + elseif (settings::$multi) {
|
|
| 39 | + logger::write('You can not use answer mode when multi setting is on', loggerTypes::ERROR);
|
|
| 40 | 40 | throw new bptException('ANSWER_MODE_MULTI');
|
| 41 | 41 | } |
| 42 | 42 | } |
@@ -46,11 +46,11 @@ discard block |
||
| 46 | 46 | unset($data['forgot']); |
| 47 | 47 | unset($data['return_array']); |
| 48 | 48 | |
| 49 | - foreach ($data as $key=>&$value){
|
|
| 50 | - if (!isset($value)){
|
|
| 49 | + foreach ($data as $key=>&$value) {
|
|
| 50 | + if (!isset($value)) {
|
|
| 51 | 51 | unset($data[$key]); |
| 52 | 52 | } |
| 53 | - elseif (is_array($value) || is_object($value)){
|
|
| 53 | + elseif (is_array($value) || is_object($value)) {
|
|
| 54 | 54 | $value = json_encode($value); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -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 | } |