@@ -115,7 +115,7 @@ |
||
| 115 | 115 | { |
| 116 | 116 | // Get the correct logger instance. |
| 117 | 117 | $logger = null; |
| 118 | - if (in_array($name, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug',], true)) { |
|
| 118 | + if (in_array($name, ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug', ], true)) { |
|
| 119 | 119 | $logger = self::$logger; |
| 120 | 120 | } elseif ($name === 'update') { |
| 121 | 121 | $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 | } |
@@ -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 | } |
@@ -177,7 +177,9 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $update = new Update(json_decode($input, true)); |
| 179 | 179 | |
| 180 | - if (!$update->isOk()) return false; |
|
| 180 | + if (!$update->isOk()) { |
|
| 181 | + return false; |
|
| 182 | + } |
|
| 181 | 183 | |
| 182 | 184 | return $update; |
| 183 | 185 | } |
@@ -190,7 +192,9 @@ discard block |
||
| 190 | 192 | public static function getUpdate(): Update|false |
| 191 | 193 | { |
| 192 | 194 | $input = self::getInput(); |
| 193 | - if ($input === '' || Common::isJson($input) === false) return false; |
|
| 195 | + if ($input === '' || Common::isJson($input) === false) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 194 | 198 | return Telegram::processUpdate($input); |
| 195 | 199 | } |
| 196 | 200 | |
@@ -216,7 +220,9 @@ discard block |
||
| 216 | 220 | public function fetchWith(WebhookHandler $webhook_handler, ?Update $update = null): void |
| 217 | 221 | { |
| 218 | 222 | if (is_subclass_of($webhook_handler, WebhookHandler::class)) { |
| 219 | - if ($update === null) $update = self::getUpdate(); |
|
| 223 | + if ($update === null) { |
|
| 224 | + $update = self::getUpdate(); |
|
| 225 | + } |
|
| 220 | 226 | $webhook_handler->resolve($update); |
| 221 | 227 | } |
| 222 | 228 | } |
@@ -229,7 +235,9 @@ discard block |
||
| 229 | 235 | */ |
| 230 | 236 | protected function getTokenFromEnvFile(string $file): ?string |
| 231 | 237 | { |
| 232 | - if (!file_exists($file)) return null; |
|
| 238 | + if (!file_exists($file)) { |
|
| 239 | + return null; |
|
| 240 | + } |
|
| 233 | 241 | return DotEnv::load($file)::get('TELEGRAM_API_KEY'); |
| 234 | 242 | } |
| 235 | 243 | |
@@ -151,10 +151,15 @@ discard block |
||
| 151 | 151 | throw new \RuntimeException(sprintf('The method %s does not exist', $method)); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if (is_array($config)) $this->updateConfiguration($config); |
|
| 154 | + if (is_array($config)) { |
|
| 155 | + $this->updateConfiguration($config); |
|
| 156 | + } |
|
| 155 | 157 | |
| 156 | - if (!empty($update)) $this->update = $update; |
|
| 157 | - else $this->update = Telegram::getUpdate(); |
|
| 158 | + if (!empty($update)) { |
|
| 159 | + $this->update = $update; |
|
| 160 | + } else { |
|
| 161 | + $this->update = Telegram::getUpdate(); |
|
| 162 | + } |
|
| 158 | 163 | |
| 159 | 164 | if (defined('DEBUG_MODE') && DEBUG_MODE) { |
| 160 | 165 | try { |
@@ -189,7 +194,9 @@ discard block |
||
| 189 | 194 | foreach ($plugins as $plugin) { |
| 190 | 195 | /** @var Plugin $plugin */ |
| 191 | 196 | (new $plugin())->__execute($this, $update); |
| 192 | - if ($this->isActive === false) break; |
|
| 197 | + if ($this->isActive === false) { |
|
| 198 | + break; |
|
| 199 | + } |
|
| 193 | 200 | } |
| 194 | 201 | |
| 195 | 202 | $this->isActive = false; |
@@ -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 | if (count($item) == 2) { |
| 44 | 47 | putenv($item[0] . '=' . $item[1]); |
@@ -72,7 +75,9 @@ discard block |
||
| 72 | 75 | public static function put(string $key, string $value, bool $save = false): void |
| 73 | 76 | { |
| 74 | 77 | putenv($key . '=' . $value); |
| 75 | - if ($save) self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]); |
|
| 78 | + if ($save) { |
|
| 79 | + self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]); |
|
| 80 | + } |
|
| 76 | 81 | } |
| 77 | 82 | |
| 78 | 83 | /** |