@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @method array setState(array $params) |
21 | 21 | * @method \chillerlan\OAuth\Core\OAuth2Interface checkState(string $state = null) |
22 | 22 | */ |
23 | -abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{ |
|
23 | +abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var int |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function getAuthURL(array $params = null, array $scopes = null):UriInterface{ |
57 | 57 | $params = $params ?? []; |
58 | 58 | |
59 | - if(isset($params['client_secret'])){ |
|
59 | + if (isset($params['client_secret'])) { |
|
60 | 60 | unset($params['client_secret']); |
61 | 61 | } |
62 | 62 | |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | 'type' => 'web_server', |
68 | 68 | ]); |
69 | 69 | |
70 | - if($scopes !== null){ |
|
70 | + if ($scopes !== null) { |
|
71 | 71 | $params['scope'] = implode($this->scopesDelimiter, $scopes); |
72 | 72 | } |
73 | 73 | |
74 | - if($this instanceof CSRFToken){ |
|
74 | + if ($this instanceof CSRFToken) { |
|
75 | 75 | $params = $this->setState($params); |
76 | 76 | } |
77 | 77 | |
@@ -87,19 +87,19 @@ discard block |
||
87 | 87 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
88 | 88 | $data = json_decode(Psr7\decompress_content($response), true); // silly amazon... |
89 | 89 | |
90 | - if(!is_array($data)){ |
|
90 | + if (!is_array($data)) { |
|
91 | 91 | throw new ProviderException('unable to parse token response'); |
92 | 92 | } |
93 | 93 | |
94 | - foreach(['error_description', 'error'] as $field){ |
|
94 | + foreach (['error_description', 'error'] as $field) { |
|
95 | 95 | |
96 | - if(isset($data[$field])){ |
|
96 | + if (isset($data[$field])) { |
|
97 | 97 | throw new ProviderException('error retrieving access token: "'.$data[$field].'"'); |
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
101 | 101 | |
102 | - if(!isset($data['access_token'])){ |
|
102 | + if (!isset($data['access_token'])) { |
|
103 | 103 | throw new ProviderException('token missing'); |
104 | 104 | } |
105 | 105 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getAccessToken(string $code, string $state = null):AccessToken{ |
127 | 127 | |
128 | - if($this instanceof CSRFToken){ |
|
128 | + if ($this instanceof CSRFToken) { |
|
129 | 129 | $this->checkState($state); |
130 | 130 | } |
131 | 131 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ->withHeader('Accept-Encoding', 'identity') |
144 | 144 | ->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738))); |
145 | 145 | |
146 | - foreach($this->authHeaders as $header => $value){ |
|
146 | + foreach ($this->authHeaders as $header => $value) { |
|
147 | 147 | $request = $request->withHeader($header, $value); |
148 | 148 | } |
149 | 149 | |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function getRequestAuthorization(RequestInterface $request, AccessToken $token):RequestInterface{ |
165 | 165 | |
166 | - if(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_HEADER)){ |
|
166 | + if (array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_HEADER)) { |
|
167 | 167 | $request = $request->withHeader('Authorization', OAuth2Interface::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken); |
168 | 168 | } |
169 | - elseif(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)){ |
|
169 | + elseif (array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)) { |
|
170 | 170 | $uri = Psr7\merge_query((string)$request->getUri(), [OAuth2Interface::AUTH_METHODS_QUERY[$this->authMethod] => $token->accessToken]); |
171 | 171 | |
172 | 172 | $request = $request->withUri($this->uriFactory->createUri($uri)); |
173 | 173 | } |
174 | - else{ |
|
174 | + else { |
|
175 | 175 | throw new ProviderException('invalid auth type'); |
176 | 176 | } |
177 | 177 |