@@ -24,7 +24,7 @@ |
||
24 | 24 | return []; |
25 | 25 | } |
26 | 26 | $data = file_get_contents($path); |
27 | - return array_map(function ($item) { |
|
27 | + return array_map(function($item) { |
|
28 | 28 | return explode('=', $item); |
29 | 29 | }, explode("\n", $data)); |
30 | 30 | } |
@@ -37,8 +37,11 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public static function load(string $path = null): self |
39 | 39 | { |
40 | - if (empty($path)) $data = self::read(getcwd() . '/.env'); |
|
41 | - else $data = self::read($path); |
|
40 | + if (empty($path)) { |
|
41 | + $data = self::read(getcwd() . '/.env'); |
|
42 | + } else { |
|
43 | + $data = self::read($path); |
|
44 | + } |
|
42 | 45 | foreach ($data as $item) { |
43 | 46 | [$key, $value] = $item; |
44 | 47 | if (count($item) == 2) { |
@@ -73,7 +76,9 @@ discard block |
||
73 | 76 | public static function put(string $key, string $value, bool $save = false): void |
74 | 77 | { |
75 | 78 | putenv($key . '=' . $value); |
76 | - if ($save) self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]); |
|
79 | + if ($save) { |
|
80 | + self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]); |
|
81 | + } |
|
77 | 82 | } |
78 | 83 | |
79 | 84 | /** |
@@ -85,7 +85,7 @@ |
||
85 | 85 | defined('TG_ADMIN_ID') or define('TG_ADMIN_ID', $admin_id); |
86 | 86 | } |
87 | 87 | |
88 | - set_exception_handler(function ($exception) { |
|
88 | + set_exception_handler(function($exception) { |
|
89 | 89 | |
90 | 90 | if (defined('DEBUG_MODE') && DEBUG_MODE) { |
91 | 91 |
@@ -235,7 +235,9 @@ discard block |
||
235 | 235 | public function fetchWith(UpdateHandler $webhook_handler, ?Update $update = null): void |
236 | 236 | { |
237 | 237 | if (is_subclass_of($webhook_handler, UpdateHandler::class)) { |
238 | - if ($update === null) $update = self::getUpdate(); |
|
238 | + if ($update === null) { |
|
239 | + $update = self::getUpdate(); |
|
240 | + } |
|
239 | 241 | $webhook_handler->resolve($update); |
240 | 242 | } |
241 | 243 | } |
@@ -248,7 +250,9 @@ discard block |
||
248 | 250 | public static function getUpdate(): Update|false |
249 | 251 | { |
250 | 252 | $input = self::getInput(); |
251 | - if (empty($input)) return false; |
|
253 | + if (empty($input)) { |
|
254 | + return false; |
|
255 | + } |
|
252 | 256 | return Telegram::processUpdate($input, self::getApiKey()); |
253 | 257 | } |
254 | 258 | |
@@ -375,7 +379,9 @@ discard block |
||
375 | 379 | */ |
376 | 380 | protected function getTokenFromEnvFile(string $file): ?string |
377 | 381 | { |
378 | - if (!file_exists($file)) return null; |
|
382 | + if (!file_exists($file)) { |
|
383 | + return null; |
|
384 | + } |
|
379 | 385 | return DotEnv::load($file)::get('TELEGRAM_BOT_TOKEN'); |
380 | 386 | } |
381 | 387 |
@@ -65,8 +65,8 @@ |
||
65 | 65 | public static function escapeMarkdown(string $string): string |
66 | 66 | { |
67 | 67 | return str_replace( |
68 | - ['[', '`', '*', '_',], |
|
69 | - ['\[', '\`', '\*', '\_',], |
|
68 | + ['[', '`', '*', '_', ], |
|
69 | + ['\[', '\`', '\*', '\_', ], |
|
70 | 70 | $string |
71 | 71 | ); |
72 | 72 | } |
@@ -137,7 +137,9 @@ discard block |
||
137 | 137 | foreach ($plugins as $plugin) { |
138 | 138 | /** @var Plugin $plugin */ |
139 | 139 | (new $plugin())->__execute($this, $update); |
140 | - if ($this->isActive === false) break; |
|
140 | + if ($this->isActive === false) { |
|
141 | + break; |
|
142 | + } |
|
141 | 143 | } |
142 | 144 | |
143 | 145 | $this->isActive = false; |
@@ -168,10 +170,15 @@ discard block |
||
168 | 170 | throw new \RuntimeException('The method __process does not exist'); |
169 | 171 | } |
170 | 172 | |
171 | - if (is_array($config)) $this->updateConfiguration($config); |
|
173 | + if (is_array($config)) { |
|
174 | + $this->updateConfiguration($config); |
|
175 | + } |
|
172 | 176 | |
173 | - if (!empty($update)) $this->update = $update; |
|
174 | - else $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null; |
|
177 | + if (!empty($update)) { |
|
178 | + $this->update = $update; |
|
179 | + } else { |
|
180 | + $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null; |
|
181 | + } |
|
175 | 182 | |
176 | 183 | if (empty($this->update)) { |
177 | 184 | TelegramLog::error( |
@@ -116,7 +116,7 @@ |
||
116 | 116 | // Get the correct logger instance. |
117 | 117 | $logger = null; |
118 | 118 | self::initialize(); |
119 | - if (in_array($name, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug',], true)) { |
|
119 | + if (in_array($name, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug', ], true)) { |
|
120 | 120 | $logger = self::$logger; |
121 | 121 | } elseif ($name === 'update') { |
122 | 122 | $logger = self::$update_logger; |
@@ -42,7 +42,7 @@ |
||
42 | 42 | $data['raw_data'] = $data; |
43 | 43 | $this->response = $data; |
44 | 44 | |
45 | - $is_ok = (bool)($data['ok'] ?? false); |
|
45 | + $is_ok = (bool) ($data['ok'] ?? false); |
|
46 | 46 | $result = $data['result'] ?? null; |
47 | 47 | |
48 | 48 | if ($is_ok) { |
@@ -37,7 +37,7 @@ |
||
37 | 37 | |
38 | 38 | if ($these_photos = $this->getProperty('photos')) { |
39 | 39 | foreach ($these_photos as $photos) { |
40 | - $all_photos[] = array_map(function ($photo) { |
|
40 | + $all_photos[] = array_map(function($photo) { |
|
41 | 41 | return new PhotoSize($photo); |
42 | 42 | }, $photos); |
43 | 43 | } |