@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function deleteCacheItem($cacheKey, $key) |
| 207 | 207 | { |
| 208 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($cacheKey, $key) { |
|
| 208 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($cacheKey, $key) { |
|
| 209 | 209 | if (!$arrayData) { |
| 210 | 210 | return true; //there isn't anything so it's deleted |
| 211 | 211 | } else { |
| 212 | 212 | unset($arrayData[$key]); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return $this->cache->set($cacheKey, $arrayData)->then(function ($result) { |
|
| 215 | + return $this->cache->set($cacheKey, $arrayData)->then(function($result) { |
|
| 216 | 216 | if ($result !== true) { |
| 217 | 217 | $this->logger->errorWriteCache($result); |
| 218 | 218 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | public function deleteCache(array $keys) |
| 230 | 230 | { |
| 231 | - return $this->cache->deleteMultiple($keys)->then(function ($result) { |
|
| 231 | + return $this->cache->deleteMultiple($keys)->then(function($result) { |
|
| 232 | 232 | if ($result !== true) { |
| 233 | 233 | $this->logger->errorClearCache($result); |
| 234 | 234 | } |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | public function getCacheItem($cacheKey, $key) |
| 246 | 246 | { |
| 247 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($key) { |
|
| 247 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($key) { |
|
| 248 | 248 | if ($arrayData && array_key_exists($key, $arrayData)) { |
| 249 | 249 | return $arrayData[$key]; |
| 250 | 250 | } else { |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | public function setCache($cacheKey, $key, $data) |
| 278 | 278 | { |
| 279 | - return $this->cache->get($cacheKey)->then(function ($arrayData) use ($key, $data, $cacheKey) { |
|
| 279 | + return $this->cache->get($cacheKey)->then(function($arrayData) use ($key, $data, $cacheKey) { |
|
| 280 | 280 | if (!$arrayData) { |
| 281 | 281 | $arrayData = array(); |
| 282 | 282 | $arrayData[$key] = $data; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $arrayData[$key] = $data; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - return $this->cache->set($cacheKey, $arrayData)->then(function ($result) { |
|
| 287 | + return $this->cache->set($cacheKey, $arrayData)->then(function($result) { |
|
| 288 | 288 | if ($result !== true) { |
| 289 | 289 | $this->logger->errorWriteCache($result); |
| 290 | 290 | } |
@@ -302,14 +302,14 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | public function callHandlerByChatId($chatId, $update, $container) |
| 304 | 304 | { |
| 305 | - return $this->cache->get($this->getKeyConversation($chatId))->then(function (array $conversation) use ($update, $chatId, $container) { |
|
| 305 | + return $this->cache->get($this->getKeyConversation($chatId))->then(function(array $conversation) use ($update, $chatId, $container) { |
|
| 306 | 306 | if (!empty($conversation)) { |
| 307 | 307 | $handler = $conversation["state"]; |
| 308 | 308 | $handler(new Context($update, $container)); |
| 309 | 309 | } |
| 310 | - }, function ($err) use ($container, $update) { |
|
| 310 | + }, function($err) use ($container, $update) { |
|
| 311 | 311 | $this->logger->errorUpdate($update, $err); |
| 312 | - })->otherwise(function ($err, $update, $chatId) { |
|
| 312 | + })->otherwise(function($err, $update, $chatId) { |
|
| 313 | 313 | $this->logger->errorUpdate($err, $update); |
| 314 | 314 | $this->deleteConversationCache($chatId); |
| 315 | 315 | }); |
@@ -1463,7 +1463,7 @@ discard block |
||
| 1463 | 1463 | $async = $this->container->get(Config::class)->isReactFileSystem(); |
| 1464 | 1464 | |
| 1465 | 1465 | if ($async) { |
| 1466 | - return $this->prepareMultipartDataAsync($params)->then(function ($result) use ($method) { |
|
| 1466 | + return $this->prepareMultipartDataAsync($params)->then(function($result) use ($method) { |
|
| 1467 | 1467 | $headers = array("Content-Length" => $result->getSize(), "Content-Type" => "multipart/form-data; boundary={$result->getBoundary()}"); |
| 1468 | 1468 | return $this->browser->post($method, $headers, $result); |
| 1469 | 1469 | }); |
@@ -1492,12 +1492,12 @@ discard block |
||
| 1492 | 1492 | foreach ($params as $key => $value) { |
| 1493 | 1493 | |
| 1494 | 1494 | if ($value instanceof InputFile) { |
| 1495 | - array_push($promises, $filesystem->getContents($value->getPath())->then(function ($contents) use ($value, $multipart_data, $key) { |
|
| 1495 | + array_push($promises, $filesystem->getContents($value->getPath())->then(function($contents) use ($value, $multipart_data, $key) { |
|
| 1496 | 1496 | $data = ['name' => $key]; |
| 1497 | 1497 | $data['contents'] = $contents; |
| 1498 | 1498 | $data['filename'] = basename($value->getPath()); |
| 1499 | 1499 | return $data; |
| 1500 | - }, function ($error) { |
|
| 1500 | + }, function($error) { |
|
| 1501 | 1501 | $this->container->get(ZanzaraLogger::class)->error($error); |
| 1502 | 1502 | return $error; |
| 1503 | 1503 | })); |
@@ -1509,12 +1509,12 @@ discard block |
||
| 1509 | 1509 | } |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | - return all($promises)->then(function ($files) use ($multipart_data) { |
|
| 1512 | + return all($promises)->then(function($files) use ($multipart_data) { |
|
| 1513 | 1513 | foreach ($files as $key => $value) { |
| 1514 | 1514 | array_push($multipart_data, $value); |
| 1515 | 1515 | } |
| 1516 | 1516 | return new MultipartStream($multipart_data); |
| 1517 | - }, function ($error) { |
|
| 1517 | + }, function($error) { |
|
| 1518 | 1518 | $this->container->get(ZanzaraLogger::class)->error($error); |
| 1519 | 1519 | return $error; |
| 1520 | 1520 | }); |
@@ -1562,8 +1562,8 @@ discard block |
||
| 1562 | 1562 | $logger = $this->container->get(ZanzaraLogger::class); |
| 1563 | 1563 | |
| 1564 | 1564 | return $promise |
| 1565 | - ->then(function (ResponseInterface $response) use ($class, $mapper) { |
|
| 1566 | - $json = (string)$response->getBody(); |
|
| 1565 | + ->then(function(ResponseInterface $response) use ($class, $mapper) { |
|
| 1566 | + $json = (string) $response->getBody(); |
|
| 1567 | 1567 | $object = json_decode($json); |
| 1568 | 1568 | |
| 1569 | 1569 | if (is_scalar($object->result) && $class === "Scalar") { |
@@ -1572,8 +1572,8 @@ discard block |
||
| 1572 | 1572 | |
| 1573 | 1573 | return $mapper->mapObject($object->result, $class); |
| 1574 | 1574 | |
| 1575 | - }, function (ResponseException $exception) use ($logger, $mapper) { |
|
| 1576 | - $json = (string)$exception->getResponse()->getBody(); |
|
| 1575 | + }, function(ResponseException $exception) use ($logger, $mapper) { |
|
| 1576 | + $json = (string) $exception->getResponse()->getBody(); |
|
| 1577 | 1577 | $telegramException = $mapper->mapJson($json, TelegramException::class); |
| 1578 | 1578 | $logger->error($telegramException); |
| 1579 | 1579 | throw $telegramException; |