@@ -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 | } |
@@ -70,7 +70,9 @@ |
||
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | if ($return->valid() && $return->getReturn()) { |
| 73 | - if ($this->kill_on_yield) $this->kill(); |
|
| 73 | + if ($this->kill_on_yield) { |
|
| 74 | + $this->kill(); |
|
| 75 | + } |
|
| 74 | 76 | } |
| 75 | 77 | } |
| 76 | 78 | } |
@@ -20,7 +20,9 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public static function isJson(?string $string): bool |
| 22 | 22 | { |
| 23 | - if (!is_string($string)) return false; |
|
| 23 | + if (!is_string($string)) { |
|
| 24 | + return false; |
|
| 25 | + } |
|
| 24 | 26 | json_decode($string); |
| 25 | 27 | return json_last_error() === JSON_ERROR_NONE; |
| 26 | 28 | } |
@@ -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 | /** |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | 'default' => MenuButtonDefault::class, |
| 15 | 15 | ]; |
| 16 | 16 | |
| 17 | - if (! isset($type[$data['type'] ?? ''])) { |
|
| 17 | + if (!isset($type[$data['type'] ?? ''])) { |
|
| 18 | 18 | return new MenuButtonNotImplemented($data); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -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; |
@@ -154,10 +154,15 @@ discard block |
||
| 154 | 154 | throw new \RuntimeException(sprintf('The method %s does not exist', $method)); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if (is_array($config)) $this->updateConfiguration($config); |
|
| 157 | + if (is_array($config)) { |
|
| 158 | + $this->updateConfiguration($config); |
|
| 159 | + } |
|
| 158 | 160 | |
| 159 | - if (!empty($update)) $this->update = $update; |
|
| 160 | - else $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null; |
|
| 161 | + if (!empty($update)) { |
|
| 162 | + $this->update = $update; |
|
| 163 | + } else { |
|
| 164 | + $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null; |
|
| 165 | + } |
|
| 161 | 166 | |
| 162 | 167 | if (empty($this->update)) { |
| 163 | 168 | TelegramLog::error('The update is empty'); |
@@ -201,7 +206,9 @@ discard block |
||
| 201 | 206 | foreach ($plugins as $plugin) { |
| 202 | 207 | /** @var Plugin $plugin */ |
| 203 | 208 | (new $plugin())->__execute($this, $update); |
| 204 | - if ($this->isActive === false) break; |
|
| 209 | + if ($this->isActive === false) { |
|
| 210 | + break; |
|
| 211 | + } |
|
| 205 | 212 | } |
| 206 | 213 | |
| 207 | 214 | $this->isActive = false; |
@@ -191,7 +191,7 @@ |
||
| 191 | 191 | ); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if (!self::validateToken($apiKey)){ |
|
| 194 | + if (!self::validateToken($apiKey)) { |
|
| 195 | 195 | throw new TelegramException( |
| 196 | 196 | 'Invalid token! Please check your code and try again.' |
| 197 | 197 | ); |
@@ -258,7 +258,9 @@ discard block |
||
| 258 | 258 | public static function getUpdate(): Update|false |
| 259 | 259 | { |
| 260 | 260 | $input = self::getInput(); |
| 261 | - if (empty($input)) return false; |
|
| 261 | + if (empty($input)) { |
|
| 262 | + return false; |
|
| 263 | + } |
|
| 262 | 264 | return Telegram::processUpdate($input, self::getApiKey()); |
| 263 | 265 | } |
| 264 | 266 | |
@@ -284,7 +286,9 @@ discard block |
||
| 284 | 286 | public function fetchWith(WebhookHandler $webhook_handler, ?Update $update = null): void |
| 285 | 287 | { |
| 286 | 288 | if (is_subclass_of($webhook_handler, WebhookHandler::class)) { |
| 287 | - if ($update === null) $update = self::getUpdate(); |
|
| 289 | + if ($update === null) { |
|
| 290 | + $update = self::getUpdate(); |
|
| 291 | + } |
|
| 288 | 292 | $webhook_handler->resolve($update); |
| 289 | 293 | } |
| 290 | 294 | } |
@@ -297,7 +301,9 @@ discard block |
||
| 297 | 301 | */ |
| 298 | 302 | protected function getTokenFromEnvFile(string $file): ?string |
| 299 | 303 | { |
| 300 | - if (!file_exists($file)) return null; |
|
| 304 | + if (!file_exists($file)) { |
|
| 305 | + return null; |
|
| 306 | + } |
|
| 301 | 307 | return DotEnv::load($file)::get('TELEGRAM_API_KEY'); |
| 302 | 308 | } |
| 303 | 309 | |