@@ -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 | |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | $deferred = new Deferred(); |
| 62 | 62 | |
| 63 | 63 | $receivedData = ''; |
| 64 | - $request->on('response', function (Response $response) use ($deferred, &$receivedData) { |
|
| 65 | - $response->on('data', function ($chunk) use (&$receivedData) { |
|
| 64 | + $request->on('response', function(Response $response) use ($deferred, &$receivedData) { |
|
| 65 | + $response->on('data', function($chunk) use (&$receivedData) { |
|
| 66 | 66 | $receivedData .= $chunk; |
| 67 | 67 | }); |
| 68 | 68 | |
| 69 | - $response->on('end', function () use (&$receivedData, $deferred, $response) { |
|
| 69 | + $response->on('end', function() use (&$receivedData, $deferred, $response) { |
|
| 70 | 70 | try { |
| 71 | 71 | $endResponse = new TelegramResponse($receivedData, $response->getHeaders()); |
| 72 | 72 | $deferred->resolve($endResponse); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | }); |
| 78 | 78 | }); |
| 79 | 79 | |
| 80 | - $request->on('error', function (\Exception $e) use ($deferred) { |
|
| 80 | + $request->on('error', function(\Exception $e) use ($deferred) { |
|
| 81 | 81 | $deferred->reject(new ClientException($e->getMessage(), $e->getCode(), $e)); |
| 82 | 82 | }); |
| 83 | 83 | |
@@ -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 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $this->requestHandler = $handler; |
| 72 | 72 | $this->formConstructor = new PostOptionsConstructor(); |
| 73 | - $this->apiUrl = 'https://api.telegram.org/bot' . $this->botToken . '/'; |
|
| 73 | + $this->apiUrl = 'https://api.telegram.org/bot'.$this->botToken.'/'; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | $this->resetObjectValues(); |
| 88 | 88 | $option = $this->formConstructor->constructOptions($method); |
| 89 | 89 | return $this->sendRequestToTelegram($method, $option) |
| 90 | - ->then(function (TelegramResponse $response) use ($method) { |
|
| 90 | + ->then(function(TelegramResponse $response) use ($method) { |
|
| 91 | 91 | return $method::bindToObject($response, $this->logger); |
| 92 | - }, function ($error) { |
|
| 92 | + }, function($error) { |
|
| 93 | 93 | $this->logger->error($error); |
| 94 | 94 | throw $error; |
| 95 | 95 | }); |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | public function downloadFile(File $file): PromiseInterface |
| 104 | 104 | { |
| 105 | - $url = 'https://api.telegram.org/file/bot' . $this->botToken . '/' . $file->file_path; |
|
| 105 | + $url = 'https://api.telegram.org/file/bot'.$this->botToken.'/'.$file->file_path; |
|
| 106 | 106 | $this->logger->debug('About to perform request to begin downloading file'); |
| 107 | 107 | |
| 108 | 108 | return $this->requestHandler->get($url)->then( |
| 109 | - function (TelegramResponse $rawData) { |
|
| 109 | + function(TelegramResponse $rawData) { |
|
| 110 | 110 | return new TelegramDocument($rawData); |
| 111 | 111 | } |
| 112 | 112 | ); |
@@ -152,6 +152,6 @@ discard block |
||
| 152 | 152 | $this->methodName = substr($completeClassName, strrpos($completeClassName, '\\') + 1); |
| 153 | 153 | $this->logger->info('About to perform API request', ['method' => $this->methodName]); |
| 154 | 154 | |
| 155 | - return $this->apiUrl . $this->methodName; |
|
| 155 | + return $this->apiUrl.$this->methodName; |
|
| 156 | 156 | } |
| 157 | 157 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $deferred = new Deferred(); |
| 23 | 23 | |
| 24 | - $promise->onResolve(function ($error = null, $result = null) use ($deferred) { |
|
| 24 | + $promise->onResolve(function($error = null, $result = null) use ($deferred) { |
|
| 25 | 25 | if ($error) { |
| 26 | 26 | $deferred->reject($error); |
| 27 | 27 | } else { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function processRequest(Request $request) |
| 90 | 90 | { |
| 91 | - return reactAdapt(\Amp\call(function () use ($request) { |
|
| 91 | + return reactAdapt(\Amp\call(function() use ($request) { |
|
| 92 | 92 | /** @var Response $response */ |
| 93 | 93 | $response = yield $this->client->request($request); |
| 94 | 94 | |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | /** |
| 30 | 30 | * Traverses through our $data, yielding the result set |
| 31 | 31 | * |
| 32 | - * @return Update[] |
|
| 32 | + * @return \Generator |
|
| 33 | 33 | */ |
| 34 | 34 | public function traverseObject() |
| 35 | 35 | { |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | foreach ($data as $id => $value) { |
| 117 | 117 | if ($id === $fileKeyName) { |
| 118 | 118 | $data = new MultipartData( |
| 119 | - (string) $id, |
|
| 119 | + (string)$id, |
|
| 120 | 120 | stream_get_contents($stream), |
| 121 | 121 | pathinfo($filename, PATHINFO_BASENAME) |
| 122 | 122 | ); |
| 123 | 123 | } else { |
| 124 | - $data = new MultipartData((string) $id, (string) $value); |
|
| 124 | + $data = new MultipartData((string)$id, (string)$value); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $builder->append($data); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $body = $builder->buildAll(); |
| 131 | 131 | $array = [ |
| 132 | 132 | 'headers' => [ |
| 133 | - 'Content-Type' => 'multipart/form-data; boundary="' . $builder->getBoundary() . '"', |
|
| 133 | + 'Content-Type' => 'multipart/form-data; boundary="'.$builder->getBoundary().'"', |
|
| 134 | 134 | 'Content-Length' => \strlen($body) |
| 135 | 135 | ], |
| 136 | 136 | 'body' => $body |