@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | public function __get(string $resource) |
| 142 | 142 | { |
| 143 | - $resolve = function (string $resource) { |
|
| 143 | + $resolve = function(string $resource) { |
|
| 144 | 144 | switch ($resource) { |
| 145 | 145 | // == RESOURCES == |
| 146 | 146 | case 'users': |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | case 'groups': |
| 275 | 275 | case 'messages': |
| 276 | 276 | case 'rooms': |
| 277 | - throw new \LogicException('Resource ' . $name . ' can not be removed'); |
|
| 277 | + throw new \LogicException('Resource '.$name.' can not be removed'); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -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 | /** |
@@ -306,7 +306,7 @@ |
||
| 306 | 306 | |
| 307 | 307 | yield from $response = $this->fetch($route); |
| 308 | 308 | |
| 309 | - } while(count($response) >= $limit && ($skip += $limit)); |
|
| 309 | + } while (count($response) >= $limit && ($skip += $limit)); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected function fetch(Route $route): array |
| 59 | 59 | { |
| 60 | - $rescue = (new Evacuator(function () use ($route) { |
|
| 61 | - return (array)$this->viaHttp()->request($route); |
|
| 60 | + $rescue = (new Evacuator(function() use ($route) { |
|
| 61 | + return (array) $this->viaHttp()->request($route); |
|
| 62 | 62 | })) |
| 63 | 63 | // If response has status code 4xx |
| 64 | - ->onError(function (ClientException $e) { |
|
| 65 | - $this->client->logger->error(get_class($e) . ' ' . $e->getMessage()); |
|
| 64 | + ->onError(function(ClientException $e) { |
|
| 65 | + $this->client->logger->error(get_class($e).' '.$e->getMessage()); |
|
| 66 | 66 | |
| 67 | 67 | switch ($e->getResponse()->getStatusCode()) { |
| 68 | 68 | case 429: // 429 Too Many Requests |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | throw $e; |
| 74 | 74 | }) |
| 75 | 75 | // Other |
| 76 | - ->onError(function (\Exception $e) { |
|
| 76 | + ->onError(function(\Exception $e) { |
|
| 77 | 77 | $this->client->logger->error($e->getMessage()); |
| 78 | 78 | throw $e; |
| 79 | 79 | }) |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return (new Evacuator(function() use ($route) { |
| 95 | 95 | return $this->viaStream()->request($route); |
| 96 | 96 | })) |
| 97 | - ->onError(function (\Exception $e) { |
|
| 97 | + ->onError(function(\Exception $e) { |
|
| 98 | 98 | $this->client->logger->error($e->getMessage()); |
| 99 | 99 | }) |
| 100 | 100 | ->retries($this->client->getRetriesCount()) |
@@ -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 | /** |