Completed
Pull Request — master (#53)
by Rick
02:35
created
src/TgLog.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
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,15 +145,15 @@  discard block
 block discarded – undo
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
             $deferred->resolve(new TelegramDocument($response));
155 155
         },
156
-        function (\Exception $exception) use ($deferred) {
156
+        function(\Exception $exception) use ($deferred) {
157 157
             if (method_exists($exception, 'getResponse') && !empty($exception->getResponse()->getBody())) {
158 158
                 $deferred->resolve(new TelegramDocument($exception->getResponse()));
159 159
             } else {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     final private function constructApiUrl(): TgLog
170 170
     {
171
-        $this->apiUrl = 'https://api.telegram.org/bot' . $this->botToken . '/';
171
+        $this->apiUrl = 'https://api.telegram.org/bot'.$this->botToken.'/';
172 172
         $this->logger->debug('Built up the API URL');
173 173
         return $this;
174 174
     }
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
         $deferred = new Deferred();
212 212
 
213 213
         $promise = $this->requestHandler->postAsync($this->composeApiMethodUrl($method), $formData);
214
-        $promise->then(function (ResponseInterface $response) use ($deferred)
214
+        $promise->then(function(ResponseInterface $response) use ($deferred)
215 215
         {
216
-            $deferred->resolve(new TelegramRawData((string) $response->getBody()));
216
+            $deferred->resolve(new TelegramRawData((string)$response->getBody()));
217 217
         },
218
-        function (\Exception $exception) use ($deferred) {
218
+        function(\Exception $exception) use ($deferred) {
219 219
             if (method_exists($exception, 'getResponse') && !empty($exception->getResponse()->getBody())) {
220
-                $deferred->resolve(new TelegramRawData((string) $exception->getResponse()->getBody(), $exception));
220
+                $deferred->resolve(new TelegramRawData((string)$exception->getResponse()->getBody(), $exception));
221 221
             } else {
222 222
                 $deferred->reject($exception);
223 223
             }
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         $this->methodName = substr($completeClassName, strrpos($completeClassName, '\\') + 1);
334 334
         $this->logger->info('About to perform API request', ['method' => $this->methodName]);
335 335
 
336
-        return $this->apiUrl . $this->methodName;
336
+        return $this->apiUrl.$this->methodName;
337 337
     }
338 338
 
339 339
     /**
Please login to merge, or discard this patch.
src/GuzzleRequestHandler.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
         },
103 103
             function (RequestException $exception) use ($deferred) {
104 104
                 if (!empty($exception->getResponse()->getBody())) {
105
-	                $deferred->resolve(new TelegramRawData((string) $exception->getResponse()
106
-		                ->getBody(), $exception));
105
+                 $deferred->resolve(new TelegramRawData((string) $exception->getResponse()
106
+                  ->getBody(), $exception));
107 107
                 } else {
108
-	                $deferred->reject($exception);
108
+                 $deferred->reject($exception);
109 109
                 }
110 110
             });
111 111
 
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
         },
129 129
             function (RequestException $exception) use ($deferred) {
130 130
                 if (!empty($exception->getResponse()->getBody())) {
131
-	                $deferred->resolve(new TelegramRawData((string) $exception->getResponse()
132
-		                ->getBody(), $exception));
131
+                 $deferred->resolve(new TelegramRawData((string) $exception->getResponse()
132
+                  ->getBody(), $exception));
133 133
                 } else {
134
-	                $deferred->reject($exception);
134
+                 $deferred->reject($exception);
135 135
                 }
136 136
             });
137 137
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
             $logger = new DummyLogger();
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             }
82 82
         }
83 83
         finally {
84
-            return new TelegramRawData((string) $response->getBody(), $e);
84
+            return new TelegramRawData((string)$response->getBody(), $e);
85 85
         }
86 86
     }
87 87
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
         $deferred = new Deferred();
98 98
 
99 99
         $promise = $this->httpClient->postAsync($uri, $formData);
100
-        $promise->then(function (ResponseInterface $response) use ($deferred) {
101
-            $deferred->resolve(new TelegramRawData((string) $response->getBody()));
100
+        $promise->then(function(ResponseInterface $response) use ($deferred) {
101
+            $deferred->resolve(new TelegramRawData((string)$response->getBody()));
102 102
         },
103
-            function (RequestException $exception) use ($deferred) {
103
+            function(RequestException $exception) use ($deferred) {
104 104
                 if (!empty($exception->getResponse()->getBody())) {
105
-	                $deferred->resolve(new TelegramRawData((string) $exception->getResponse()
105
+	                $deferred->resolve(new TelegramRawData((string)$exception->getResponse()
106 106
 		                ->getBody(), $exception));
107 107
                 } else {
108 108
 	                $deferred->reject($exception);
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
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()
131
+	                $deferred->resolve(new TelegramRawData((string)$exception->getResponse()
132 132
 		                ->getBody(), $exception));
133 133
                 } else {
134 134
 	                $deferred->reject($exception);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -72,15 +72,13 @@
 block discarded – undo
72 72
         try {
73 73
             $response = $this->httpClient->post($uri, $formData);
74 74
             $this->logger->debug('Got response back from Telegram, applying json_decode');
75
-        }
76
-        catch (ClientException $e) {
75
+        } catch (ClientException $e) {
77 76
             $response = $e->getResponse();
78 77
             // It can happen that we have a network problem, in such case, we can't do nothing about it, so rethrow
79 78
             if (empty($response)) {
80 79
                 throw $e;
81 80
             }
82
-        }
83
-        finally {
81
+        } finally {
84 82
             return new TelegramRawData((string) $response->getBody(), $e);
85 83
         }
86 84
     }
Please login to merge, or discard this patch.