@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | public function downloadFile(File $file): TelegramDocument |
133 | 133 | { |
134 | 134 | $this->logger->debug('Downloading file from Telegram, creating URL'); |
135 | - $url = 'https://api.telegram.org/file/bot' . $this->botToken . '/' . $file->file_path; |
|
135 | + $url = 'https://api.telegram.org/file/bot'.$this->botToken.'/'.$file->file_path; |
|
136 | 136 | $this->logger->debug('About to perform request to begin downloading file'); |
137 | 137 | return new TelegramDocument($this->requestHandler->get($url)); |
138 | 138 | } |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | public function downloadFileAsync(File $file): PromiseInterface |
146 | 146 | { |
147 | 147 | $this->logger->debug('Downloading file async from Telegram, creating URL'); |
148 | - $url = 'https://api.telegram.org/file/bot' . $this->botToken . '/' . $file->file_path; |
|
148 | + $url = 'https://api.telegram.org/file/bot'.$this->botToken.'/'.$file->file_path; |
|
149 | 149 | $this->logger->debug('About to perform request to begin downloading file'); |
150 | 150 | |
151 | 151 | $deferred = new Deferred(); |
152 | 152 | |
153 | - return $this->requestHandler->getAsync($url)->then(function (ResponseInterface $response) use ($deferred) |
|
153 | + return $this->requestHandler->getAsync($url)->then(function(ResponseInterface $response) use ($deferred) |
|
154 | 154 | { |
155 | 155 | $deferred->resolve(new TelegramDocument($response)); |
156 | 156 | }, |
157 | - function (\Exception $exception) use ($deferred) |
|
157 | + function(\Exception $exception) use ($deferred) |
|
158 | 158 | { |
159 | 159 | if (method_exists($exception, 'getResponse') && !empty($exception->getResponse()->getBody())) |
160 | 160 | $deferred->resolve(new TelegramDocument($exception->getResponse())); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | final private function constructApiUrl(): TgLog |
171 | 171 | { |
172 | - $this->apiUrl = 'https://api.telegram.org/bot' . $this->botToken . '/'; |
|
172 | + $this->apiUrl = 'https://api.telegram.org/bot'.$this->botToken.'/'; |
|
173 | 173 | $this->logger->debug('Built up the API URL'); |
174 | 174 | return $this; |
175 | 175 | } |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | $deferred = new Deferred(); |
213 | 213 | |
214 | 214 | $promise = $this->requestHandler->postAsync($this->composeApiMethodUrl($method), $formData); |
215 | - $promise->then(function (ResponseInterface $response) use ($deferred) |
|
215 | + $promise->then(function(ResponseInterface $response) use ($deferred) |
|
216 | 216 | { |
217 | - $deferred->resolve(new TelegramRawData((string) $response->getBody())); |
|
217 | + $deferred->resolve(new TelegramRawData((string)$response->getBody())); |
|
218 | 218 | }, |
219 | - function (\Exception $exception) use ($deferred) |
|
219 | + function(\Exception $exception) use ($deferred) |
|
220 | 220 | { |
221 | 221 | if (method_exists($exception, 'getResponse') && !empty($exception->getResponse()->getBody())) |
222 | - $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
222 | + $deferred->resolve(new TelegramRawData((string)$exception->getResponse()->getBody(), $exception)); |
|
223 | 223 | else |
224 | 224 | $deferred->reject($exception); |
225 | 225 | }); |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $this->methodName = substr($completeClassName, strrpos($completeClassName, '\\') + 1); |
335 | 335 | $this->logger->info('About to perform API request', ['method' => $this->methodName]); |
336 | 336 | |
337 | - return $this->apiUrl . $this->methodName; |
|
337 | + return $this->apiUrl.$this->methodName; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -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 | { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | } |
85 | 85 | finally { |
86 | - return new TelegramRawData((string) $response->getBody(), $e); |
|
86 | + return new TelegramRawData((string)$response->getBody(), $e); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | $deferred = new Deferred(); |
100 | 100 | |
101 | 101 | $promise = $this->httpClient->postAsync($uri, $formData); |
102 | - $promise->then(function (ResponseInterface $response) use ($deferred) { |
|
103 | - $deferred->resolve(new TelegramRawData((string) $response->getBody())); |
|
102 | + $promise->then(function(ResponseInterface $response) use ($deferred) { |
|
103 | + $deferred->resolve(new TelegramRawData((string)$response->getBody())); |
|
104 | 104 | }, |
105 | - function (RequestException $exception) use ($deferred) { |
|
105 | + function(RequestException $exception) use ($deferred) { |
|
106 | 106 | if (!empty($exception->getResponse()->getBody())) |
107 | - $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
107 | + $deferred->resolve(new TelegramRawData((string)$exception->getResponse()->getBody(), $exception)); |
|
108 | 108 | else |
109 | 109 | $deferred->reject($exception); |
110 | 110 | }); |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | $deferred = new Deferred(); |
124 | 124 | |
125 | 125 | $promise = $this->httpClient->getAsync($uri); |
126 | - $promise->then(function (ResponseInterface $response) use ($deferred) { |
|
127 | - $deferred->resolve(new TelegramRawData((string) $response->getBody())); |
|
126 | + $promise->then(function(ResponseInterface $response) use ($deferred) { |
|
127 | + $deferred->resolve(new TelegramRawData((string)$response->getBody())); |
|
128 | 128 | }, |
129 | - function (RequestException $exception) use ($deferred) { |
|
129 | + function(RequestException $exception) use ($deferred) { |
|
130 | 130 | if (!empty($exception->getResponse()->getBody())) |
131 | - $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception)); |
|
131 | + $deferred->resolve(new TelegramRawData((string)$exception->getResponse()->getBody(), $exception)); |
|
132 | 132 | else |
133 | 133 | $deferred->reject($exception); |
134 | 134 | }); |