@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $clone['chat_id'] = $chatId; |
| 66 | 66 | array_push($payload, $clone); |
| 67 | 67 | } |
| 68 | - $dequeue = function (TimerInterface $timer) use (&$payload) { |
|
| 68 | + $dequeue = function(TimerInterface $timer) use (&$payload) { |
|
| 69 | 69 | // if there's no more message to dequeue cancel the timer |
| 70 | 70 | if (!$payload) { |
| 71 | 71 | $this->loop->cancelTimer($timer); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // pop and process |
| 76 | 76 | $params = array_pop($payload); |
| 77 | - $this->telegram->doSendMessage($params)->/** @scrutinizer ignore-call */ otherwise(function (TelegramException $error) { |
|
| 77 | + $this->telegram->doSendMessage($params)->/** @scrutinizer ignore-call */ otherwise(function(TelegramException $error) { |
|
| 78 | 78 | $this->logger->error("Failed to send message in bulk mode, reason: $error"); |
| 79 | 79 | }); |
| 80 | 80 | }; |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function run() |
| 22 | 22 | { |
| 23 | 23 | $this->telegram->getWebhookInfo()->then( |
| 24 | - function (WebhookInfo $webhookInfo) { |
|
| 24 | + function(WebhookInfo $webhookInfo) { |
|
| 25 | 25 | if (!$webhookInfo->getUrl()) { |
| 26 | 26 | $this->loop->futureTick([$this, 'startPolling']); |
| 27 | 27 | $this->logger->logIsListening(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | $answer = readline(); |
| 35 | 35 | if (strtoupper($answer) === "YES") { |
| 36 | 36 | $this->telegram->deleteWebhook()->then( |
| 37 | - function ($res) { |
|
| 37 | + function($res) { |
|
| 38 | 38 | if ($res === true) { |
| 39 | 39 | $this->logger->info("Webhook is deleted, Zanzara is starting in polling ..."); |
| 40 | 40 | $this->loop->futureTick([$this, 'startPolling']); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | 'limit' => $this->config->getPollingLimit(), |
| 62 | 62 | 'timeout' => $this->config->getPollingTimeout(), |
| 63 | 63 | 'allowed_updates' => $this->config->getPollingAllowedUpdates(), |
| 64 | - ])->then(function (array $updates) use (&$offset, &$processingUpdate) { |
|
| 64 | + ])->then(function(array $updates) use (&$offset, &$processingUpdate) { |
|
| 65 | 65 | if ($offset === 1) { |
| 66 | 66 | //first run I need to get the current updateId from telegram |
| 67 | 67 | $lastUpdate = end($updates); |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | $this->startPolling($offset); |
| 82 | 82 | } |
| 83 | - }, function (TelegramException $error) use (&$offset) { |
|
| 83 | + }, function(TelegramException $error) use (&$offset) { |
|
| 84 | 84 | $this->logger->error("Failed to fetch updates from Telegram: $error"); |
| 85 | 85 | $this->startPolling($offset); // consider place a delay before restarting to poll |
| 86 | - })->/** @scrutinizer ignore-call */ otherwise(function ($e) use (&$offset, &$processingUpdate) { |
|
| 86 | + })->/** @scrutinizer ignore-call */ otherwise(function($e) use (&$offset, &$processingUpdate) { |
|
| 87 | 87 | $this->logger->errorUpdate($e); |
| 88 | 88 | $errorHandler = $this->config->getErrorHandler(); |
| 89 | 89 | if ($errorHandler) { |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function deleteCacheItem(string $cacheKey, $key) |
| 230 | 230 | { |
| 231 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($cacheKey, $key) { |
|
| 231 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($cacheKey, $key) { |
|
| 232 | 232 | if (!$arrayData) { |
| 233 | 233 | return true; //there isn't anything so it's deleted |
| 234 | 234 | } else { |
| 235 | 235 | unset($arrayData[$key]); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - return $this->cache->set($cacheKey, $arrayData)->then(function ($result) { |
|
| 238 | + return $this->cache->set($cacheKey, $arrayData)->then(function($result) { |
|
| 239 | 239 | if ($result !== true) { |
| 240 | 240 | $this->logger->errorWriteCache($result); |
| 241 | 241 | } |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | public function deleteCache(array $keys) |
| 253 | 253 | { |
| 254 | - return $this->cache->deleteMultiple($keys)->then(function ($result) { |
|
| 254 | + return $this->cache->deleteMultiple($keys)->then(function($result) { |
|
| 255 | 255 | if ($result !== true) { |
| 256 | 256 | $this->logger->errorClearCache($result); |
| 257 | 257 | } |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | */ |
| 268 | 268 | public function getCacheItem(string $cacheKey, $key) |
| 269 | 269 | { |
| 270 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($key) { |
|
| 270 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($key) { |
|
| 271 | 271 | if ($arrayData && array_key_exists($key, $arrayData)) { |
| 272 | 272 | return $arrayData[$key]; |
| 273 | 273 | } else { |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | public function doSet(string $cacheKey, string $key, $data, $ttl = false) |
| 316 | 316 | { |
| 317 | 317 | $ttl = $this->checkTtl($ttl); |
| 318 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($ttl, $key, $data, $cacheKey) { |
|
| 318 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($ttl, $key, $data, $cacheKey) { |
|
| 319 | 319 | if (!$arrayData) { |
| 320 | 320 | $arrayData = array(); |
| 321 | 321 | $arrayData[$key] = $data; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | $arrayData[$key] = $data; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - return $this->cache->set($cacheKey, $arrayData, $ttl)->then(function ($result) { |
|
| 326 | + return $this->cache->set($cacheKey, $arrayData, $ttl)->then(function($result) { |
|
| 327 | 327 | if ($result !== true) { |
| 328 | 328 | $this->logger->errorWriteCache($result); |
| 329 | 329 | } |
@@ -345,10 +345,10 @@ discard block |
||
| 345 | 345 | { |
| 346 | 346 | |
| 347 | 347 | $ttl = $this->checkTtl($ttl); |
| 348 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($ttl, $key, $data, $cacheKey) { |
|
| 348 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($ttl, $key, $data, $cacheKey) { |
|
| 349 | 349 | $arrayData[$key][] = $data; |
| 350 | 350 | |
| 351 | - return $this->cache->set($cacheKey, $arrayData, $ttl)->then(function ($result) { |
|
| 351 | + return $this->cache->set($cacheKey, $arrayData, $ttl)->then(function($result) { |
|
| 352 | 352 | if ($result !== true) { |
| 353 | 353 | $this->logger->errorWriteCache($result); |
| 354 | 354 | } |
@@ -366,14 +366,14 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | public function callHandlerByChatId(int $chatId, $update, $container) |
| 368 | 368 | { |
| 369 | - return $this->cache->get($this->getConversationKey($chatId))->then(function ($conversation) use ($update, $container) { |
|
| 369 | + return $this->cache->get($this->getConversationKey($chatId))->then(function($conversation) use ($update, $container) { |
|
| 370 | 370 | if (!empty($conversation["state"])) { |
| 371 | 371 | $handler = $conversation["state"]; |
| 372 | 372 | $handler(new Context($update, $container)); |
| 373 | 373 | } |
| 374 | - }, function ($err) use ($update) { |
|
| 374 | + }, function($err) use ($update) { |
|
| 375 | 375 | $this->logger->errorUpdate($update, $err); |
| 376 | - })->/** @scrutinizer ignore-call */ otherwise(function ($err) use ($update, $chatId) { |
|
| 376 | + })->/** @scrutinizer ignore-call */ otherwise(function($err) use ($update, $chatId) { |
|
| 377 | 377 | $this->logger->errorUpdate($err, $update); |
| 378 | 378 | $this->deleteConversationCache($chatId); |
| 379 | 379 | }); |