@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of GitterApi package. |
| 4 | 4 | * |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of GitterApi package. |
| 4 | 4 | * |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | do { |
| 50 | 50 | $route = Route::get('rooms/{roomId}/chatMessages') |
| 51 | 51 | ->with('roomId', $roomId) |
| 52 | - ->with('limit', (string)$limit); |
|
| 52 | + ->with('limit', (string) $limit); |
|
| 53 | 53 | |
| 54 | 54 | if ($beforeId !== null) { |
| 55 | - $route->with('beforeId', (string)$beforeId); |
|
| 55 | + $route->with('beforeId', (string) $beforeId); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if ($query !== null) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $response = array_reverse($this->fetch($route)); |
| 63 | 63 | |
| 64 | 64 | foreach ($response as $message) { |
| 65 | - $beforeId = (string)$message['id']; |
|
| 65 | + $beforeId = (string) $message['id']; |
|
| 66 | 66 | yield $message; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | return $this->fetch( |
| 84 | 84 | Route::get('rooms/{roomId}/chatMessages/{messageId}') |
| 85 | - ->withMany([ 'roomId' => $roomId, 'messageId' => $messageId ]) |
|
| 85 | + ->withMany(['roomId' => $roomId, 'messageId' => $messageId]) |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | return $this->fetch( |
| 120 | 120 | Route::put('rooms/{roomId}/chatMessages/{messageId}') |
| 121 | - ->withMany([ 'roomId' => $roomId, 'messageId' => $messageId ]) |
|
| 121 | + ->withMany(['roomId' => $roomId, 'messageId' => $messageId]) |
|
| 122 | 122 | ->withBody('text', $content) |
| 123 | 123 | ); |
| 124 | 124 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of GitterApi package. |
| 4 | 4 | * |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function currentUserId(): string |
| 58 | 58 | { |
| 59 | - return (string)($this->current()['id'] ?? null); |
|
| 59 | + return (string) ($this->current()['id'] ?? null); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -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 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of GitterApi package. |
| 4 | 4 | * |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | $options = $this->prepareRequestOptions($route); |
| 79 | 79 | |
| 80 | 80 | // Log request |
| 81 | - $this->debugLog($this->client, ' -> ' . $method . ' ' . $uri); |
|
| 81 | + $this->debugLog($this->client, ' -> '.$method.' '.$uri); |
|
| 82 | 82 | if ($options['body'] ?? false) { |
| 83 | - $this->debugLog($this->client, ' -> body ' . $options['body']); |
|
| 83 | + $this->debugLog($this->client, ' -> body '.$options['body']); |
|
| 84 | 84 | } |
| 85 | 85 | // End log request |
| 86 | 86 | |
| 87 | 87 | $response = $this->guzzle->request($method, $uri, $options); |
| 88 | 88 | |
| 89 | 89 | // Log response |
| 90 | - $this->debugLog($this->client, ' <- ' . $response->getStatusCode() . ' ' . $response->getReasonPhrase()); |
|
| 91 | - $this->debugLog($this->client, ' <- ' . (string)$response->getBody()); |
|
| 90 | + $this->debugLog($this->client, ' <- '.$response->getStatusCode().' '.$response->getReasonPhrase()); |
|
| 91 | + $this->debugLog($this->client, ' <- '.(string) $response->getBody()); |
|
| 92 | 92 | // End log response |
| 93 | 93 | |
| 94 | 94 | return $this->parseResponse($response); |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | private function parseResponse(ResponseInterface $response): array |
| 118 | 118 | { |
| 119 | - $data = json_decode((string)$response->getBody(), true); |
|
| 119 | + $data = json_decode((string) $response->getBody(), true); |
|
| 120 | 120 | |
| 121 | 121 | if (json_last_error() !== JSON_ERROR_NONE) { |
| 122 | 122 | throw new \RuntimeException(json_last_error_msg()); |
@@ -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 | }); |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * This file is part of GitterApi package. |
| 4 | 4 | * |
@@ -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 | // On internal errors |
| 76 | - ->onError(function (RequestException $e) { |
|
| 76 | + ->onError(function(RequestException $e) { |
|
| 77 | 77 | $this->client->logger->error($e->getMessage()); |
| 78 | 78 | |
| 79 | 79 | // Throws request exception if SSL error |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | }) |
| 84 | 84 | // Other |
| 85 | - ->onError(function (\Exception $e) { |
|
| 85 | + ->onError(function(\Exception $e) { |
|
| 86 | 86 | $this->client->logger->error($e->getMessage()); |
| 87 | 87 | throw $e; |
| 88 | 88 | }) |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | return (new Evacuator(function() use ($route) { |
| 104 | 104 | return $this->viaStream()->request($route); |
| 105 | 105 | })) |
| 106 | - ->onError(function (\Exception $e) { |
|
| 106 | + ->onError(function(\Exception $e) { |
|
| 107 | 107 | $this->client->logger->error($e->getMessage()); |
| 108 | 108 | }) |
| 109 | 109 | ->retries($this->client->getRetriesCount()) |