@@ -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 |
@@ -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 | |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string[]|string |
126 | 126 | */ |
127 | - public static function realEscapeString(string|array $input): string|array { |
|
128 | - if(is_array($input)) { |
|
127 | + public static function realEscapeString(string | array $input): string | array { |
|
128 | + if (is_array($input)) { |
|
129 | 129 | return array_map(__METHOD__, $input); |
130 | 130 | } |
131 | 131 | |
132 | - if(!empty($input) && is_string($input)) { |
|
132 | + if (!empty($input) && is_string($input)) { |
|
133 | 133 | return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $input); |
134 | 134 | } |
135 | 135 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return string[]|string |
149 | 149 | */ |
150 | - public static function strReplaceFirst(string|array $search, string|array $replace, string|array $subject): string|array { |
|
150 | + public static function strReplaceFirst(string | array $search, string | array $replace, string | array $subject): string | array { |
|
151 | 151 | $pos = strpos($subject, $search); |
152 | 152 | if ($pos !== false) { |
153 | 153 | return substr_replace($subject, $replace, $pos, strlen($search)); |
@@ -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 |
@@ -4,4 +4,4 @@ |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -class telegramException extends Exception{} |
|
8 | 7 | \ No newline at end of file |
8 | +class telegramException extends Exception {} |
|
9 | 9 | \ No newline at end of file |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | * @method gameHighScore[]|responseError getGameHighScores (int|null|array $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $return_array = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects. |
237 | 237 | * @method gameHighScore[]|responseError getGameHigh (int|null|array $user_id = null, int|null $chat_id = null, int|null $message_id = null, string|null $inline_message_id = null, string|null $token = null, bool|null $return_array = null, bool|null $forgot = null, bool|null $answer = null) Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an Array of GameHighScore objects. |
238 | 238 | */ |
239 | -class BPT extends telegram{ |
|
239 | +class BPT extends telegram { |
|
240 | 240 | public static update $update; |
241 | 241 | |
242 | 242 | public static BPT $handler; |
243 | 243 | |
244 | 244 | |
245 | - public function __construct (array|stdClass $settings) { |
|
245 | + public function __construct(array | stdClass $settings) { |
|
246 | 246 | static::$handler = &$this; |
247 | 247 | settings::init($settings); |
248 | 248 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | settings::done(); |
252 | 252 | } |
253 | 253 | |
254 | - public static function exit (string|null $message = null) { |
|
254 | + public static function exit (string | null $message = null) { |
|
255 | 255 | die($message ?? "<div style='width:98vw;height:98vh;display:flex;justify-content:center;align-items:center;font-size:25vw'>BPT</div>"); |
256 | 256 | } |
257 | 257 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public string $description; |
19 | 19 | |
20 | 20 | |
21 | - public function __construct(stdClass|null $object = null) { |
|
21 | + public function __construct(stdClass | null $object = null) { |
|
22 | 22 | if ($object != null) { |
23 | 23 | parent::__construct($object, self::subs); |
24 | 24 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | /** Keep all of properties which has sub properties */ |
12 | 12 | private const subs = []; |
13 | 13 | |
14 | - public function __construct(stdClass|null $object = null) { |
|
14 | + public function __construct(stdClass | null $object = null) { |
|
15 | 15 | if ($object != null) { |
16 | 16 | parent::__construct($object, self::subs); |
17 | 17 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | public int $file_date; |
29 | 29 | |
30 | 30 | |
31 | - public function __construct(stdClass|null $object = null) { |
|
31 | + public function __construct(stdClass | null $object = null) { |
|
32 | 32 | if ($object != null) { |
33 | 33 | parent::__construct($object, self::subs); |
34 | 34 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | public photoSize $thumb; |
47 | 47 | |
48 | 48 | |
49 | - public function __construct(stdClass|null $object = null) { |
|
49 | + public function __construct(stdClass | null $object = null) { |
|
50 | 50 | if ($object != null) { |
51 | 51 | parent::__construct($object, self::subs); |
52 | 52 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | public chatInviteLink $invite_link; |
32 | 32 | |
33 | 33 | |
34 | - public function __construct(stdClass|null $object = null) { |
|
34 | + public function __construct(stdClass | null $object = null) { |
|
35 | 35 | if ($object != null) { |
36 | 36 | parent::__construct($object, self::subs); |
37 | 37 | } |