@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function refreshAccessToken(AccessToken $token = null):AccessToken{ |
| 88 | 88 | |
| 89 | - if($token === null){ |
|
| 89 | + if ($token === null) { |
|
| 90 | 90 | $token = $this->storage->getAccessToken($this->serviceName); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $refreshToken = $token->refreshToken; |
| 94 | 94 | |
| 95 | - if(empty($refreshToken)){ |
|
| 95 | + if (empty($refreshToken)) { |
|
| 96 | 96 | throw new ProviderException( |
| 97 | 97 | sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)) |
| 98 | 98 | ); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $newToken = $this->parseTokenResponse($this->http->sendRequest($request)); |
| 116 | 116 | |
| 117 | - if(empty($newToken->refreshToken)){ |
|
| 117 | + if (empty($newToken->refreshToken)) { |
|
| 118 | 118 | $newToken->refreshToken = $refreshToken; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | $method = strtoupper($method); |
| 144 | 144 | $token = $this->storage->getAccessToken($this->serviceName); |
| 145 | 145 | |
| 146 | - if($token->isExpired()){ |
|
| 146 | + if ($token->isExpired()) { |
|
| 147 | 147 | $token = $this->refreshAccessToken($token); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if(!isset($params['fmt'])){ |
|
| 150 | + if (!isset($params['fmt'])) { |
|
| 151 | 151 | $params['fmt'] = 'json'; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - if(in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])){ |
|
| 154 | + if (in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])) { |
|
| 155 | 155 | $params['client'] = $this->options->user_agent; // @codeCoverageIgnore |
| 156 | 156 | } |
| 157 | 157 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | protected $authHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
| 57 | 57 | protected $apiHeaders = ['Accept' => 'application/vnd.twitchtv.v5+json']; |
| 58 | - protected $authMethodHeader = 'OAuth'; // -> https://api.twitch.tv/kraken |
|
| 58 | + protected $authMethodHeader = 'OAuth'; // -> https://api.twitch.tv/kraken |
|
| 59 | 59 | # protected $authMethodHeader = 'Bearer'; // -> https://api.twitch.tv/helix |
| 60 | 60 | protected $endpointMap = TwitchEndpoints::class; |
| 61 | 61 | protected $apiDocs = 'https://dev.twitch.tv/docs/api/reference/'; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | 'grant_type' => 'client_credentials', |
| 76 | 76 | ]; |
| 77 | 77 | |
| 78 | - if($scopes !== null){ |
|
| 78 | + if ($scopes !== null) { |
|
| 79 | 79 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738))) |
| 86 | 86 | ; |
| 87 | 87 | |
| 88 | - foreach($this->authHeaders as $header => $value){ |
|
| 88 | + foreach ($this->authHeaders as $header => $value) { |
|
| 89 | 89 | $request = $request->withAddedHeader($header, $value); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | OAuthStorageInterface $storage, |
| 51 | 51 | SettingsContainerInterface $options, |
| 52 | 52 | LoggerInterface $logger = null |
| 53 | - ){ |
|
| 53 | + ) { |
|
| 54 | 54 | parent::__construct($http, $storage, $options, $logger); |
| 55 | 55 | |
| 56 | 56 | $this->setRegion('eu'); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | public function setRegion(string $region):BattleNet{ |
| 66 | 66 | $region = strtolower($region); |
| 67 | 67 | |
| 68 | - if(!in_array($region, ['apac', 'cn', 'eu', 'us'], true)){ |
|
| 68 | + if (!in_array($region, ['apac', 'cn', 'eu', 'us'], true)) { |
|
| 69 | 69 | throw new ProviderException('invalid region: '.$region); |
| 70 | 70 | } |
| 71 | 71 | |