@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | use const PHP_QUERY_RFC1738; |
25 | 25 | |
26 | -abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{ |
|
26 | +abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function getAuthURL(array $params = null, array $scopes = null):UriInterface{ |
62 | 62 | $params ??= []; |
63 | 63 | |
64 | - if(isset($params['client_secret'])){ |
|
64 | + if (isset($params['client_secret'])) { |
|
65 | 65 | unset($params['client_secret']); |
66 | 66 | } |
67 | 67 | |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | 'type' => 'web_server', |
73 | 73 | ]); |
74 | 74 | |
75 | - if(!empty($scopes)){ |
|
75 | + if (!empty($scopes)) { |
|
76 | 76 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
77 | 77 | } |
78 | 78 | |
79 | - if($this instanceof CSRFToken){ |
|
79 | + if ($this instanceof CSRFToken) { |
|
80 | 80 | $params = $this->setState($params); |
81 | 81 | } |
82 | 82 | |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
93 | 93 | $data = json_decode(decompress_content($response), true); // silly amazon... |
94 | 94 | |
95 | - if(!is_array($data)){ |
|
95 | + if (!is_array($data)) { |
|
96 | 96 | throw new ProviderException('unable to parse token response'); |
97 | 97 | } |
98 | 98 | |
99 | - foreach(['error_description', 'error'] as $field){ |
|
99 | + foreach (['error_description', 'error'] as $field) { |
|
100 | 100 | |
101 | - if(isset($data[$field])){ |
|
101 | + if (isset($data[$field])) { |
|
102 | 102 | throw new ProviderException('error retrieving access token: "'.$data[$field].'"'); |
103 | 103 | } |
104 | 104 | |
105 | 105 | } |
106 | 106 | |
107 | - if(!isset($data['access_token'])){ |
|
107 | + if (!isset($data['access_token'])) { |
|
108 | 108 | throw new ProviderException('token missing'); |
109 | 109 | } |
110 | 110 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getAccessToken(string $code, string $state = null):AccessToken{ |
129 | 129 | |
130 | - if($this instanceof CSRFToken){ |
|
130 | + if ($this instanceof CSRFToken) { |
|
131 | 131 | $this->checkState($state); |
132 | 132 | } |
133 | 133 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | ->withHeader('Accept-Encoding', 'identity') |
146 | 146 | ->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738))); |
147 | 147 | |
148 | - foreach($this->authHeaders as $header => $value){ |
|
148 | + foreach ($this->authHeaders as $header => $value) { |
|
149 | 149 | $request = $request->withHeader($header, $value); |
150 | 150 | } |
151 | 151 | |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function getRequestAuthorization(RequestInterface $request, AccessToken $token):RequestInterface{ |
163 | 163 | |
164 | - if($this->authMethod === OAuth2Interface::AUTH_METHOD_HEADER){ |
|
164 | + if ($this->authMethod === OAuth2Interface::AUTH_METHOD_HEADER) { |
|
165 | 165 | return $request->withHeader('Authorization', $this->authMethodHeader.' '.$token->accessToken); |
166 | 166 | } |
167 | 167 | |
168 | - if($this->authMethod === OAuth2Interface::AUTH_METHOD_QUERY){ |
|
168 | + if ($this->authMethod === OAuth2Interface::AUTH_METHOD_QUERY) { |
|
169 | 169 | $uri = merge_query($request->getUri()->__toString(), [$this->authMethodQuery => $token->accessToken]); |
170 | 170 | |
171 | 171 | return $request->withUri($this->uriFactory->createUri($uri)); |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function getClientCredentialsToken(array $scopes = null):AccessToken{ |
182 | 182 | |
183 | - if(!$this instanceof ClientCredentials){ |
|
183 | + if (!$this instanceof ClientCredentials) { |
|
184 | 184 | throw new ProviderException('client credentials token not supported'); |
185 | 185 | } |
186 | 186 | |
187 | 187 | $params = ['grant_type' => 'client_credentials']; |
188 | 188 | |
189 | - if($scopes !== null){ |
|
189 | + if ($scopes !== null) { |
|
190 | 190 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
191 | 191 | } |
192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | ->withBody($this->streamFactory->createStream(http_build_query($params, '', '&', PHP_QUERY_RFC1738))) |
199 | 199 | ; |
200 | 200 | |
201 | - foreach($this->authHeaders as $header => $value){ |
|
201 | + foreach ($this->authHeaders as $header => $value) { |
|
202 | 202 | $request = $request->withAddedHeader($header, $value); |
203 | 203 | } |
204 | 204 | |
@@ -215,17 +215,17 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function refreshAccessToken(AccessToken $token = null):AccessToken{ |
217 | 217 | |
218 | - if(!$this instanceof TokenRefresh){ |
|
218 | + if (!$this instanceof TokenRefresh) { |
|
219 | 219 | throw new ProviderException('token refresh not supported'); |
220 | 220 | } |
221 | 221 | |
222 | - if($token === null){ |
|
222 | + if ($token === null) { |
|
223 | 223 | $token = $this->storage->getAccessToken($this->serviceName); |
224 | 224 | } |
225 | 225 | |
226 | 226 | $refreshToken = $token->refreshToken; |
227 | 227 | |
228 | - if(empty($refreshToken)){ |
|
228 | + if (empty($refreshToken)) { |
|
229 | 229 | throw new ProviderException( |
230 | 230 | sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)) |
231 | 231 | ); |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | ->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738))) |
247 | 247 | ; |
248 | 248 | |
249 | - foreach($this->authHeaders as $header => $value){ |
|
249 | + foreach ($this->authHeaders as $header => $value) { |
|
250 | 250 | $request = $request->withAddedHeader($header, $value); |
251 | 251 | } |
252 | 252 | |
253 | 253 | $newToken = $this->parseTokenResponse($this->http->sendRequest($request)); |
254 | 254 | |
255 | - if(empty($newToken->refreshToken)){ |
|
255 | + if (empty($newToken->refreshToken)) { |
|
256 | 256 | $newToken->refreshToken = $refreshToken; |
257 | 257 | } |
258 | 258 | |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | */ |
270 | 270 | protected function checkState(string $state = null):void{ |
271 | 271 | |
272 | - if(empty($state) || !$this->storage->hasCSRFState($this->serviceName)){ |
|
272 | + if (empty($state) || !$this->storage->hasCSRFState($this->serviceName)) { |
|
273 | 273 | throw new ProviderException('invalid state for '.$this->serviceName); |
274 | 274 | } |
275 | 275 | |
276 | 276 | $knownState = $this->storage->getCSRFState($this->serviceName); |
277 | 277 | |
278 | - if(!hash_equals($knownState, $state)){ |
|
278 | + if (!hash_equals($knownState, $state)) { |
|
279 | 279 | throw new ProviderException('invalid CSRF state: '.$this->serviceName.' '.$state); |
280 | 280 | } |
281 | 281 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | */ |
289 | 289 | protected function setState(array $params):array{ |
290 | 290 | |
291 | - if(!isset($params['state'])){ |
|
291 | + if (!isset($params['state'])) { |
|
292 | 292 | $params['state'] = sha1(random_bytes(256)); |
293 | 293 | } |
294 | 294 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | implode, in_array, is_array, parse_str, parse_url, random_bytes, strtoupper; |
20 | 20 | use function chillerlan\HTTP\Psr7\{build_http_query, decompress_content, merge_query, r_rawurlencode}; |
21 | 21 | |
22 | -abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{ |
|
22 | +abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * the request token URL |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ->withHeader('Accept-Encoding', 'identity') |
62 | 62 | ; |
63 | 63 | |
64 | - foreach($this->authHeaders as $header => $value){ |
|
64 | + foreach ($this->authHeaders as $header => $value) { |
|
65 | 65 | $request = $request->withAddedHeader($header, $value); |
66 | 66 | } |
67 | 67 | |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{ |
79 | 79 | parse_str(decompress_content($response), $data); |
80 | 80 | |
81 | - if(!$data || !is_array($data)){ |
|
81 | + if (!$data || !is_array($data)) { |
|
82 | 82 | throw new ProviderException('unable to parse token response'); |
83 | 83 | } |
84 | - elseif(isset($data['error'])){ |
|
84 | + elseif (isset($data['error'])) { |
|
85 | 85 | throw new ProviderException('error retrieving access token: '.$data['error']); |
86 | 86 | } |
87 | - elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
87 | + elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) { |
|
88 | 88 | throw new ProviderException('invalid token'); |
89 | 89 | } |
90 | 90 | |
91 | - if( |
|
91 | + if ( |
|
92 | 92 | $checkCallbackConfirmed |
93 | 93 | && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') |
94 | - ){ |
|
94 | + ) { |
|
95 | 95 | throw new ProviderException('oauth callback unconfirmed'); |
96 | 96 | } |
97 | 97 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ |
138 | 138 | $parseURL = parse_url($url); |
139 | 139 | |
140 | - if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){ |
|
140 | + if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) { |
|
141 | 141 | throw new ProviderException('getSignature: invalid url'); |
142 | 142 | } |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $signatureParams = array_merge($query, $params); |
147 | 147 | |
148 | - if(isset($signatureParams['oauth_signature'])){ |
|
148 | + if (isset($signatureParams['oauth_signature'])) { |
|
149 | 149 | unset($signatureParams['oauth_signature']); |
150 | 150 | } |
151 | 151 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $token->accessTokenSecret |
198 | 198 | ); |
199 | 199 | |
200 | - if(isset($query['oauth_session_handle'])){ |
|
200 | + if (isset($query['oauth_session_handle'])) { |
|
201 | 201 | $parameters['oauth_session_handle'] = $query['oauth_session_handle']; // @codeCoverageIgnore |
202 | 202 | } |
203 | 203 |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @property int $expires |
28 | 28 | * @property string $provider |
29 | 29 | */ |
30 | -class AccessToken extends SettingsContainerAbstract{ |
|
30 | +class AccessToken extends SettingsContainerAbstract { |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Denotes an unknown end of life time. |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param iterable|null $properties |
82 | 82 | */ |
83 | - public function __construct(iterable $properties = null){ |
|
83 | + public function __construct(iterable $properties = null) { |
|
84 | 84 | parent::__construct($properties); |
85 | 85 | |
86 | 86 | $this->setExpiry($this->expires); |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | public function setExpiry(int $expires = null):AccessToken{ |
104 | 104 | $now = time(); |
105 | 105 | |
106 | - if($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES){ |
|
106 | + if ($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES) { |
|
107 | 107 | $this->expires = $this::EOL_NEVER_EXPIRES; |
108 | 108 | } |
109 | - elseif($expires > $now){ |
|
109 | + elseif ($expires > $now) { |
|
110 | 110 | $this->expires = $expires; |
111 | 111 | } |
112 | - elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
112 | + elseif ($expires > 0 && $expires < $this::EXPIRY_MAX) { |
|
113 | 113 | $this->expires = $now + $expires; |
114 | 114 | } |
115 | - else{ |
|
115 | + else { |
|
116 | 116 | $this->expires = $this::EOL_UNKNOWN; |
117 | 117 | } |
118 | 118 |
@@ -105,14 +105,11 @@ |
||
105 | 105 | |
106 | 106 | if($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES){ |
107 | 107 | $this->expires = $this::EOL_NEVER_EXPIRES; |
108 | - } |
|
109 | - elseif($expires > $now){ |
|
108 | + } elseif($expires > $now){ |
|
110 | 109 | $this->expires = $expires; |
111 | - } |
|
112 | - elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
110 | + } elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
113 | 111 | $this->expires = $now + $expires; |
114 | - } |
|
115 | - else{ |
|
112 | + } else{ |
|
116 | 113 | $this->expires = $this::EOL_UNKNOWN; |
117 | 114 | } |
118 | 115 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @property string $serviceName |
40 | 40 | * @property string|null $userRevokeURL |
41 | 41 | */ |
42 | -abstract class OAuthProvider implements OAuthInterface{ |
|
42 | +abstract class OAuthProvider implements OAuthInterface { |
|
43 | 43 | use LoggerAwareTrait; |
44 | 44 | |
45 | 45 | protected const ALLOWED_PROPERTIES = [ |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | OAuthStorageInterface $storage, |
154 | 154 | SettingsContainerInterface $options, |
155 | 155 | LoggerInterface $logger = null |
156 | - ){ |
|
156 | + ) { |
|
157 | 157 | $this->http = $http; |
158 | 158 | $this->storage = $storage; |
159 | 159 | $this->options = $options; |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | |
166 | 166 | $this->serviceName = (new ReflectionClass($this))->getShortName(); |
167 | 167 | |
168 | - if($this instanceof ApiClientInterface && !empty($this->endpointMap) && class_exists($this->endpointMap)){ |
|
168 | + if ($this instanceof ApiClientInterface && !empty($this->endpointMap) && class_exists($this->endpointMap)) { |
|
169 | 169 | $this->endpoints = new $this->endpointMap; |
170 | 170 | |
171 | - if(!$this->endpoints instanceof EndpointMapInterface){ |
|
171 | + if (!$this->endpoints instanceof EndpointMapInterface) { |
|
172 | 172 | throw new ApiClientException('invalid endpoint map'); // @codeCoverageIgnore |
173 | 173 | } |
174 | 174 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return mixed|null |
183 | 183 | */ |
184 | - public function __get(string $name){ |
|
184 | + public function __get(string $name) { |
|
185 | 185 | |
186 | - if(in_array($name, $this::ALLOWED_PROPERTIES, true)){ |
|
186 | + if (in_array($name, $this::ALLOWED_PROPERTIES, true)) { |
|
187 | 187 | return $this->{$name}; |
188 | 188 | } |
189 | 189 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function __call(string $name, array $arguments):ResponseInterface{ |
246 | 246 | |
247 | - if(!$this instanceof ApiClientInterface || !$this->endpoints instanceof EndpointMap){ |
|
247 | + if (!$this instanceof ApiClientInterface || !$this->endpoints instanceof EndpointMap) { |
|
248 | 248 | throw new ApiClientException('MagicAPI not available'); |
249 | 249 | } |
250 | 250 | |
251 | - if(!$this->endpoints->__isset($name)){ |
|
251 | + if (!$this->endpoints->__isset($name)) { |
|
252 | 252 | throw new ApiClientException('endpoint not found: "'.$name.'"'); |
253 | 253 | } |
254 | 254 | |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | $path_elements = $m['path_elements'] ?? []; |
262 | 262 | $params_in_url = count($path_elements); |
263 | 263 | $params = $arguments[$params_in_url] ?? []; |
264 | - $urlparams = array_slice($arguments,0 , $params_in_url); |
|
264 | + $urlparams = array_slice($arguments, 0, $params_in_url); |
|
265 | 265 | |
266 | - if($params_in_url > 0){ |
|
266 | + if ($params_in_url > 0) { |
|
267 | 267 | |
268 | - if(count($urlparams) < $params_in_url){ |
|
268 | + if (count($urlparams) < $params_in_url) { |
|
269 | 269 | throw new APIClientException('too few URL params, required: '.implode(', ', $path_elements)); |
270 | 270 | } |
271 | 271 | |
272 | 272 | $endpoint = sprintf($endpoint, ...$urlparams); |
273 | 273 | } |
274 | 274 | |
275 | - if(in_array($method, ['POST', 'PATCH', 'PUT', 'DELETE'])){ |
|
275 | + if (in_array($method, ['POST', 'PATCH', 'PUT', 'DELETE'])) { |
|
276 | 276 | $body = $arguments[$params_in_url + 1] ?? $params; |
277 | 277 | |
278 | - if($params === $body){ |
|
278 | + if ($params === $body) { |
|
279 | 279 | $params = []; |
280 | 280 | } |
281 | 281 | |
@@ -325,24 +325,24 @@ discard block |
||
325 | 325 | $request = $this->requestFactory |
326 | 326 | ->createRequest($method ?? 'GET', merge_query($this->apiURL.$path, $params ?? [])); |
327 | 327 | |
328 | - foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){ |
|
328 | + foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) { |
|
329 | 329 | $request = $request->withAddedHeader($header, $value); |
330 | 330 | } |
331 | 331 | |
332 | - if(is_array($body) && $request->hasHeader('content-type')){ |
|
332 | + if (is_array($body) && $request->hasHeader('content-type')) { |
|
333 | 333 | $contentType = strtolower($request->getHeaderLine('content-type')); |
334 | 334 | |
335 | 335 | // @todo: content type support |
336 | - if($contentType === 'application/x-www-form-urlencoded'){ |
|
336 | + if ($contentType === 'application/x-www-form-urlencoded') { |
|
337 | 337 | $body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)); |
338 | 338 | } |
339 | - elseif($contentType === 'application/json'){ |
|
339 | + elseif ($contentType === 'application/json') { |
|
340 | 340 | $body = $this->streamFactory->createStream(json_encode($body)); |
341 | 341 | } |
342 | 342 | |
343 | 343 | } |
344 | 344 | |
345 | - if($body instanceof StreamInterface){ |
|
345 | + if ($body instanceof StreamInterface) { |
|
346 | 346 | $request = $request |
347 | 347 | ->withBody($body) |
348 | 348 | ->withHeader('Content-length', (string)$body->getSize()) |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | public function sendRequest(RequestInterface $request):ResponseInterface{ |
359 | 359 | |
360 | 360 | // get authorization only if we request the provider API |
361 | - if(strpos((string)$request->getUri(), $this->apiURL) === 0){ |
|
361 | + if (strpos((string)$request->getUri(), $this->apiURL) === 0) { |
|
362 | 362 | $token = $this->storage->getAccessToken($this->serviceName); |
363 | 363 | |
364 | 364 | // attempt to refresh an expired token |
365 | - if( |
|
365 | + if ( |
|
366 | 366 | $this instanceof TokenRefresh |
367 | 367 | && $this->options->tokenAutoRefresh |
368 | 368 | && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN) |
369 | - ){ |
|
369 | + ) { |
|
370 | 370 | $token = $this->refreshAccessToken($token); |
371 | 371 | } |
372 | 372 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | use function array_keys, array_key_exists; |
16 | 16 | |
17 | -class MemoryStorage extends OAuthStorageAbstract{ |
|
17 | +class MemoryStorage extends OAuthStorageAbstract { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * the token storage array |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function getAccessToken(string $service):AccessToken{ |
42 | 42 | |
43 | - if($this->hasAccessToken($service)){ |
|
43 | + if ($this->hasAccessToken($service)) { |
|
44 | 44 | return $this->tokens[$service]; |
45 | 45 | } |
46 | 46 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function clearAccessToken(string $service):bool{ |
61 | 61 | |
62 | - if(array_key_exists($service, $this->tokens)){ |
|
62 | + if (array_key_exists($service, $this->tokens)) { |
|
63 | 63 | unset($this->tokens[$service]); |
64 | 64 | } |
65 | 65 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function clearAllAccessTokens():bool{ |
73 | 73 | |
74 | - foreach(array_keys($this->tokens) as $service){ |
|
74 | + foreach (array_keys($this->tokens) as $service) { |
|
75 | 75 | unset($this->tokens[$service]); |
76 | 76 | } |
77 | 77 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function getCSRFState(string $service):string{ |
96 | 96 | |
97 | - if($this->hasCSRFState($service)){ |
|
97 | + if ($this->hasCSRFState($service)) { |
|
98 | 98 | return $this->states[$service]; |
99 | 99 | } |
100 | 100 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | public function clearCSRFState(string $service):bool{ |
115 | 115 | |
116 | - if(array_key_exists($service, $this->states)){ |
|
116 | + if (array_key_exists($service, $this->states)) { |
|
117 | 117 | unset($this->states[$service]); |
118 | 118 | } |
119 | 119 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | use const PHP_SESSION_NONE; |
19 | 19 | |
20 | -class SessionStorage extends OAuthStorageAbstract{ |
|
20 | +class SessionStorage extends OAuthStorageAbstract { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * the key name for the token storage array in $_SESSION |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param \chillerlan\Settings\SettingsContainerInterface|null $options |
36 | 36 | */ |
37 | - public function __construct(SettingsContainerInterface $options = null){ |
|
37 | + public function __construct(SettingsContainerInterface $options = null) { |
|
38 | 38 | parent::__construct($options); |
39 | 39 | |
40 | 40 | $this->tokenVar = $this->options->sessionTokenVar; |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | |
43 | 43 | // Determine if the session has started. |
44 | 44 | // @link http://stackoverflow.com/a/18542272/1470961 |
45 | - if($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)){ |
|
45 | + if ($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)) { |
|
46 | 46 | session_start(); |
47 | 47 | } |
48 | 48 | |
49 | - if(!isset($_SESSION[$this->tokenVar])){ |
|
49 | + if (!isset($_SESSION[$this->tokenVar])) { |
|
50 | 50 | $_SESSION[$this->tokenVar] = []; |
51 | 51 | } |
52 | 52 | |
53 | - if(!isset($_SESSION[$this->stateVar])){ |
|
53 | + if (!isset($_SESSION[$this->stateVar])) { |
|
54 | 54 | $_SESSION[$this->stateVar] = []; |
55 | 55 | } |
56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @codeCoverageIgnore |
63 | 63 | */ |
64 | - public function __destruct(){ |
|
65 | - if($this->options->sessionStart){ |
|
64 | + public function __destruct() { |
|
65 | + if ($this->options->sessionStart) { |
|
66 | 66 | session_write_close(); |
67 | 67 | } |
68 | 68 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function getAccessToken(string $service):AccessToken{ |
83 | 83 | |
84 | - if($this->hasAccessToken($service)){ |
|
84 | + if ($this->hasAccessToken($service)) { |
|
85 | 85 | return $this->fromStorage($_SESSION[$this->tokenVar][$service]); |
86 | 86 | } |
87 | 87 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function clearAccessToken(string $service):bool{ |
102 | 102 | |
103 | - if(array_key_exists($service, $_SESSION[$this->tokenVar])){ |
|
103 | + if (array_key_exists($service, $_SESSION[$this->tokenVar])) { |
|
104 | 104 | unset($_SESSION[$this->tokenVar][$service]); |
105 | 105 | } |
106 | 106 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public function clearAllAccessTokens():bool{ |
114 | 114 | |
115 | - foreach(array_keys($_SESSION[$this->tokenVar]) as $service){ |
|
115 | + foreach (array_keys($_SESSION[$this->tokenVar]) as $service) { |
|
116 | 116 | unset($_SESSION[$this->tokenVar][$service]); |
117 | 117 | } |
118 | 118 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getCSRFState(string $service):string{ |
137 | 137 | |
138 | - if($this->hasCSRFState($service)){ |
|
138 | + if ($this->hasCSRFState($service)) { |
|
139 | 139 | return $_SESSION[$this->stateVar][$service]; |
140 | 140 | } |
141 | 141 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function clearCSRFState(string $service):bool{ |
156 | 156 | |
157 | - if(array_key_exists($service, $_SESSION[$this->stateVar])){ |
|
157 | + if (array_key_exists($service, $_SESSION[$this->stateVar])) { |
|
158 | 158 | unset($_SESSION[$this->stateVar][$service]); |
159 | 159 | } |
160 | 160 |