@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | $observer = new Observer(); |
| 73 | 73 | |
| 74 | - $this->promise($route)->then(function (ResponseInterface $response) use ($observer) { |
|
| 74 | + $this->promise($route)->then(function(ResponseInterface $response) use ($observer) { |
|
| 75 | 75 | $this->onConnect($response, $observer); |
| 76 | 76 | }); |
| 77 | 77 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | list($method, $uri) = [$route->method(), $route->build()]; |
| 89 | 89 | |
| 90 | 90 | // Log request |
| 91 | - $this->debugLog($this->client, ' -> ' . $method . ' ' . $uri); |
|
| 91 | + $this->debugLog($this->client, ' -> '.$method.' '.$uri); |
|
| 92 | 92 | |
| 93 | 93 | return $this->browser |
| 94 | 94 | ->withOptions(['streaming' => true]) |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | $json = new JsonStream(); |
| 105 | 105 | |
| 106 | 106 | // Log response |
| 107 | - $this->debugLog($this->client, ' <- ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 107 | + $this->debugLog($this->client, ' <- '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 108 | 108 | |
| 109 | 109 | /* @var $body ReadableStreamInterface */ |
| 110 | 110 | $body = $response->getBody(); |
| 111 | 111 | |
| 112 | - $body->on('data', function ($chunk) use ($json, $observer) { |
|
| 112 | + $body->on('data', function($chunk) use ($json, $observer) { |
|
| 113 | 113 | // Log response chunk |
| 114 | - $this->debugLog($this->client, ' <- ' . $chunk); |
|
| 114 | + $this->debugLog($this->client, ' <- '.$chunk); |
|
| 115 | 115 | |
| 116 | - $json->push($chunk, function ($object) use ($observer) { |
|
| 116 | + $json->push($chunk, function($object) use ($observer) { |
|
| 117 | 117 | $observer->fire($object); |
| 118 | 118 | }); |
| 119 | 119 | }); |
@@ -64,7 +64,7 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public function currentUserId(): string |
| 66 | 66 | { |
| 67 | - return (string)($this->current()['id'] ?? null); |
|
| 67 | + return (string) ($this->current()['id'] ?? null); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $route = Route::get('rooms/{roomId}/chatMessages') |
| 93 | 93 | ->with('roomId', $roomId) |
| 94 | - ->with('limit', (string)$limit); |
|
| 94 | + ->with('limit', (string) $limit); |
|
| 95 | 95 | |
| 96 | 96 | if ($query !== null) { |
| 97 | 97 | $route->with('q', $query); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $route->with('afterId', $afterId); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $response = (array)$this->fetch($route); |
|
| 126 | + $response = (array) $this->fetch($route); |
|
| 127 | 127 | |
| 128 | 128 | foreach ($response as $message) { |
| 129 | 129 | yield $message; |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | $options = $this->prepareRequestOptions($route); |
| 69 | 69 | |
| 70 | 70 | // Log request |
| 71 | - $this->debugLog($this->client, ' -> ' . $method . ' ' . $uri); |
|
| 71 | + $this->debugLog($this->client, ' -> '.$method.' '.$uri); |
|
| 72 | 72 | if ($options['body'] ?? false) { |
| 73 | - $this->debugLog($this->client, ' -> body ' . $options['body']); |
|
| 73 | + $this->debugLog($this->client, ' -> body '.$options['body']); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // End log request |
| 77 | 77 | $response = $this->guzzle->request($method, $uri, $options); |
| 78 | 78 | |
| 79 | 79 | // Log response |
| 80 | - $this->debugLog($this->client, ' <- ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 81 | - $this->debugLog($this->client, ' <- ' . (string)$response->getBody()); |
|
| 80 | + $this->debugLog($this->client, ' <- '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 81 | + $this->debugLog($this->client, ' <- '.(string) $response->getBody()); |
|
| 82 | 82 | // End log response |
| 83 | 83 | |
| 84 | 84 | return $this->parseResponse($response); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | private function parseResponse(ResponseInterface $response): array |
| 108 | 108 | { |
| 109 | - $data = json_decode((string)$response->getBody(), true); |
|
| 109 | + $data = json_decode((string) $response->getBody(), true); |
|
| 110 | 110 | |
| 111 | 111 | if (json_last_error() !== JSON_ERROR_NONE) { |
| 112 | 112 | throw new \RuntimeException(json_last_error_msg()); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | public function with(string $parameter, $value): Route |
| 148 | 148 | { |
| 149 | - $this->parameters[$parameter] = (string)$value; |
|
| 149 | + $this->parameters[$parameter] = (string) $value; |
|
| 150 | 150 | |
| 151 | 151 | return $this; |
| 152 | 152 | } |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $route = $updatedRoute; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return $this->url . $route . '?' . http_build_query($query); |
|
| 215 | + return $this->url.$route.'?'.http_build_query($query); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -88,7 +88,7 @@ |
||
| 88 | 88 | */ |
| 89 | 89 | private function shouldStarts(string $data): bool |
| 90 | 90 | { |
| 91 | - return $this->buffer === '' && \in_array($data[0], self::JSON_STARTS_WITH, true);; |
|
| 91 | + return $this->buffer === '' && \in_array($data[0], self::JSON_STARTS_WITH, true); ; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function __get(string $resource) |
| 184 | 184 | { |
| 185 | - $resolve = function (string $resource) { |
|
| 185 | + $resolve = function(string $resource) { |
|
| 186 | 186 | switch ($resource) { |
| 187 | 187 | // == RESOURCES == |
| 188 | 188 | case 'users': |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | return null; |
| 207 | 207 | }; |
| 208 | 208 | |
| 209 | - if (! isset($this->storage[$resource])) { |
|
| 209 | + if (!isset($this->storage[$resource])) { |
|
| 210 | 210 | $this->storage[$resource] = $resolve($resource); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | case 'groups': |
| 323 | 323 | case 'messages': |
| 324 | 324 | case 'rooms': |
| 325 | - throw new \LogicException('Resource ' . $name . ' can not be removed'); |
|
| 325 | + throw new \LogicException('Resource '.$name.' can not be removed'); |
|
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | |
@@ -286,7 +286,7 @@ |
||
| 286 | 286 | |
| 287 | 287 | yield from $response = $this->fetch($route); |
| 288 | 288 | |
| 289 | - } while(\count($response) >= $limit && ($skip += $limit)); |
|
| 289 | + } while (\count($response) >= $limit && ($skip += $limit)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | protected function fetch(Route $route): array |
| 57 | 57 | { |
| 58 | - $rescue = (new Evacuator(function () use ($route) { |
|
| 59 | - return (array)$this->viaHttp()->request($route); |
|
| 58 | + $rescue = (new Evacuator(function() use ($route) { |
|
| 59 | + return (array) $this->viaHttp()->request($route); |
|
| 60 | 60 | })) |
| 61 | 61 | // If response has status code 4xx |
| 62 | - ->onError(function (ClientException $e) { |
|
| 63 | - $this->client->logger->error(\get_class($e) . ' ' . $e->getMessage()); |
|
| 62 | + ->onError(function(ClientException $e) { |
|
| 63 | + $this->client->logger->error(\get_class($e).' '.$e->getMessage()); |
|
| 64 | 64 | |
| 65 | 65 | switch ($e->getResponse()->getStatusCode()) { |
| 66 | 66 | case 429: // 429 Too Many Requests |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | throw $e; |
| 72 | 72 | }) |
| 73 | 73 | // Other |
| 74 | - ->onError(function (\Exception $e) { |
|
| 74 | + ->onError(function(\Exception $e) { |
|
| 75 | 75 | $this->client->logger->error($e->getMessage()); |
| 76 | 76 | throw $e; |
| 77 | 77 | }) |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | return (new Evacuator(function() use ($route) { |
| 93 | 93 | return $this->viaStream()->request($route); |
| 94 | 94 | })) |
| 95 | - ->onError(function (\Exception $e) { |
|
| 95 | + ->onError(function(\Exception $e) { |
|
| 96 | 96 | $this->client->logger->error($e->getMessage()); |
| 97 | 97 | }) |
| 98 | 98 | ->retries($this->client->getRetriesCount()) |