@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace unreal4u\TelegramAPI; |
6 | 6 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param ClientInterface $client |
35 | 35 | * @param LoggerInterface $logger |
36 | 36 | */ |
37 | - public function __construct(?ClientInterface $client = null, LoggerInterface $logger = null) |
|
37 | + public function __construct(? ClientInterface $client = null, LoggerInterface $logger = null) |
|
38 | 38 | { |
39 | 39 | if ($logger === null) |
40 | 40 | { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | } |
79 | 79 | } |
80 | 80 | finally { |
81 | - return new TelegramRawData((string) $response->getBody(), $e); |
|
81 | + return new TelegramRawData((string)$response->getBody(), $e); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | $deferred = new Deferred(); |
95 | 95 | |
96 | 96 | $promise = $this->httpClient->postAsync($uri, $formData); |
97 | - $promise->then(function (ResponseInterface $response) use ($deferred) { |
|
98 | - $deferred->resolve(new TelegramRawData((string) $response->getBody())); |
|
97 | + $promise->then(function(ResponseInterface $response) use ($deferred) { |
|
98 | + $deferred->resolve(new TelegramRawData((string)$response->getBody())); |
|
99 | 99 | }, |
100 | - function (RequestException $exception) use ($deferred) { |
|
100 | + function(RequestException $exception) use ($deferred) { |
|
101 | 101 | if (!empty($exception->getResponse()->getBody())) |
102 | - $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
102 | + $deferred->resolve(new TelegramRawData((string)$exception->getResponse()->getBody(), $exception)); |
|
103 | 103 | else |
104 | 104 | $deferred->reject($exception); |
105 | 105 | }); |
@@ -69,15 +69,13 @@ discard block |
||
69 | 69 | try { |
70 | 70 | $response = $this->httpClient->post($uri, $formData); |
71 | 71 | $this->logger->debug('Got response back from Telegram, applying json_decode'); |
72 | - } |
|
73 | - catch (ClientException $e) { |
|
72 | + } catch (ClientException $e) { |
|
74 | 73 | $response = $e->getResponse(); |
75 | 74 | // It can happen that we have a network problem, in such case, we can't do nothing about it, so rethrow |
76 | 75 | if (empty($response)) { |
77 | 76 | throw $e; |
78 | 77 | } |
79 | - } |
|
80 | - finally { |
|
78 | + } finally { |
|
81 | 79 | return new TelegramRawData((string) $response->getBody(), $e); |
82 | 80 | } |
83 | 81 | } |
@@ -98,10 +96,11 @@ discard block |
||
98 | 96 | $deferred->resolve(new TelegramRawData((string) $response->getBody())); |
99 | 97 | }, |
100 | 98 | function (RequestException $exception) use ($deferred) { |
101 | - if (!empty($exception->getResponse()->getBody())) |
|
102 | - $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
103 | - else |
|
104 | - $deferred->reject($exception); |
|
99 | + if (!empty($exception->getResponse()->getBody())) { |
|
100 | + $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
101 | + } else { |
|
102 | + $deferred->reject($exception); |
|
103 | + } |
|
105 | 104 | }); |
106 | 105 | |
107 | 106 | return $deferred->promise(); |