@@ -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 |
@@ -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; |