Passed
Push — main ( 8b7853...c05ac9 )
by smiley
02:10
created
src/Core/CSRFToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
  *
16 16
  * @link https://tools.ietf.org/html/rfc6749#section-10.12
17 17
  */
18
-interface CSRFToken{
18
+interface CSRFToken {
19 19
 
20 20
 	/**
21 21
 	 * Checks whether the CSRF state was set and verifies against the last known state.
Please login to merge, or discard this patch.
src/Core/OAuth1Provider.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,11 +83,9 @@
 block discarded – undo
83 83
 
84 84
 		if(empty($data)){
85 85
 			throw new ProviderException('unable to parse token response');
86
-		}
87
-		elseif(isset($data['error'])){
86
+		} elseif(isset($data['error'])){
88 87
 			throw new ProviderException('error retrieving access token: '.$data['error']);
89
-		}
90
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
88
+		} elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
91 89
 			throw new ProviderException('invalid token');
92 90
 		}
93 91
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 /**
29 29
  * Implements an abstract OAuth1 provider with all methods required by the OAuth1Interface.
30 30
  */
31
-abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{
31
+abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface {
32 32
 
33 33
 	/**
34 34
 	 * The request OAuth1 token URL
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			->withHeader('Content-Length', '0') // tumblr requires a content-length header set
68 68
 		;
69 69
 
70
-		foreach($this->authHeaders as $header => $value){
70
+		foreach ($this->authHeaders as $header => $value) {
71 71
 			$request = $request->withAddedHeader($header, $value);
72 72
 		}
73 73
 
@@ -84,20 +84,20 @@  discard block
 block discarded – undo
84 84
 	protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{
85 85
 		$data = QueryUtil::parse(MessageUtil::decompress($response));
86 86
 
87
-		if(empty($data)){
87
+		if (empty($data)) {
88 88
 			throw new ProviderException('unable to parse token response');
89 89
 		}
90
-		elseif(isset($data['error'])){
90
+		elseif (isset($data['error'])) {
91 91
 			throw new ProviderException('error retrieving access token: '.$data['error']);
92 92
 		}
93
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
93
+		elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) {
94 94
 			throw new ProviderException('invalid token');
95 95
 		}
96 96
 
97
-		if(
97
+		if (
98 98
 			$checkCallbackConfirmed
99 99
 			&& (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')
100
-		){
100
+		) {
101 101
 			throw new ProviderException('oauth callback unconfirmed');
102 102
 		}
103 103
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{
134 134
 		$parsed = QueryUtil::parseUrl($url);
135 135
 
136
-		if(!isset($parsed['host']) || !isset($parsed['scheme']) || !in_array($parsed['scheme'], ['http', 'https'], true)){
136
+		if (!isset($parsed['host']) || !isset($parsed['scheme']) || !in_array($parsed['scheme'], ['http', 'https'], true)) {
137 137
 			throw new ProviderException('getSignature: invalid url');
138 138
 		}
139 139
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		]);
151 151
 
152 152
 		// https://tools.ietf.org/html/rfc5849#section-3.4.2
153
-		$key  = array_map('rawurlencode', [
153
+		$key = array_map('rawurlencode', [
154 154
 			$this->options->secret,
155 155
 			$accessTokenSecret ?? ''
156 156
 		]);
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Storage/MemoryStorage.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Implements a memory storage adapter. Memory storage is not persistent as tokens are only stored during script runtime.
19 19
  */
20
-class MemoryStorage extends OAuthStorageAbstract{
20
+class MemoryStorage extends OAuthStorageAbstract {
21 21
 
22 22
 	/**
23 23
 	 * the token storage array
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function getAccessToken(string $service):AccessToken{
45 45
 
46
-		if($this->hasAccessToken($service)){
46
+		if ($this->hasAccessToken($service)) {
47 47
 			return $this->tokens[$service];
48 48
 		}
49 49
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function clearAccessToken(string $service):OAuthStorageInterface{
64 64
 
65
-		if(array_key_exists($service, $this->tokens)){
65
+		if (array_key_exists($service, $this->tokens)) {
66 66
 			unset($this->tokens[$service]);
67 67
 		}
68 68
 
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	public function clearAllAccessTokens():OAuthStorageInterface{
76 76
 
77
-		foreach(array_keys($this->tokens) as $service){
77
+		foreach (array_keys($this->tokens) as $service) {
78 78
 			unset($this->tokens[$service]);
79 79
 		}
80 80
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function getCSRFState(string $service):string{
99 99
 
100
-		if($this->hasCSRFState($service)){
100
+		if ($this->hasCSRFState($service)) {
101 101
 			return $this->states[$service];
102 102
 		}
103 103
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function clearCSRFState(string $service):OAuthStorageInterface{
118 118
 
119
-		if(array_key_exists($service, $this->states)){
119
+		if (array_key_exists($service, $this->states)) {
120 120
 			unset($this->states[$service]);
121 121
 		}
122 122
 
Please login to merge, or discard this patch.
src/Storage/SessionStorage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * Implements a session storage adapter. Session storage is half persistent as tokens are stored for the duration of the session.
22 22
  */
23
-class SessionStorage extends OAuthStorageAbstract{
23
+class SessionStorage extends OAuthStorageAbstract {
24 24
 
25 25
 	/**
26 26
 	 * the key name for the token storage array in $_SESSION
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * SessionStorage constructor.
37 37
 	 */
38
-	public function __construct(SettingsContainerInterface $options = null){
38
+	public function __construct(SettingsContainerInterface $options = null) {
39 39
 		parent::__construct($options);
40 40
 
41 41
 		$this->tokenVar = $this->options->sessionTokenVar;
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 
44 44
 		// Determine if the session has started.
45 45
 		// @link http://stackoverflow.com/a/18542272/1470961
46
-		if($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)){
46
+		if ($this->options->sessionStart && !(session_status() !== PHP_SESSION_NONE)) {
47 47
 			session_start();
48 48
 		}
49 49
 
50
-		if(!isset($_SESSION[$this->tokenVar])){
50
+		if (!isset($_SESSION[$this->tokenVar])) {
51 51
 			$_SESSION[$this->tokenVar] = [];
52 52
 		}
53 53
 
54
-		if(!isset($_SESSION[$this->stateVar])){
54
+		if (!isset($_SESSION[$this->stateVar])) {
55 55
 			$_SESSION[$this->stateVar] = [];
56 56
 		}
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @codeCoverageIgnore
64 64
 	 */
65
-	public function __destruct(){
66
-		if($this->options->sessionStart){
65
+	public function __destruct() {
66
+		if ($this->options->sessionStart) {
67 67
 			session_write_close();
68 68
 		}
69 69
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function getAccessToken(string $service):AccessToken{
84 84
 
85
-		if($this->hasAccessToken($service)){
85
+		if ($this->hasAccessToken($service)) {
86 86
 			return $this->fromStorage($_SESSION[$this->tokenVar][$service]);
87 87
 		}
88 88
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function clearAccessToken(string $service):OAuthStorageInterface{
103 103
 
104
-		if(array_key_exists($service, $_SESSION[$this->tokenVar])){
104
+		if (array_key_exists($service, $_SESSION[$this->tokenVar])) {
105 105
 			unset($_SESSION[$this->tokenVar][$service]);
106 106
 		}
107 107
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function clearAllAccessTokens():OAuthStorageInterface{
115 115
 
116
-		foreach(array_keys($_SESSION[$this->tokenVar]) as $service){
116
+		foreach (array_keys($_SESSION[$this->tokenVar]) as $service) {
117 117
 			unset($_SESSION[$this->tokenVar][$service]);
118 118
 		}
119 119
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function getCSRFState(string $service):string{
138 138
 
139
-		if($this->hasCSRFState($service)){
139
+		if ($this->hasCSRFState($service)) {
140 140
 			return $_SESSION[$this->stateVar][$service];
141 141
 		}
142 142
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function clearCSRFState(string $service):OAuthStorageInterface{
157 157
 
158
-		if(array_key_exists($service, $_SESSION[$this->stateVar])){
158
+		if (array_key_exists($service, $_SESSION[$this->stateVar])) {
159 159
 			unset($_SESSION[$this->stateVar][$service]);
160 160
 		}
161 161
 
Please login to merge, or discard this patch.
src/OAuthOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,6 +16,6 @@
 block discarded – undo
16 16
 /**
17 17
  * This class holds all settings related to the OAuth provider as well as the default HTTP client.
18 18
  */
19
-class OAuthOptions extends SettingsContainerAbstract{
19
+class OAuthOptions extends SettingsContainerAbstract {
20 20
 	use OAuthOptionsTrait, HTTPOptionsTrait;
21 21
 }
Please login to merge, or discard this patch.
src/Core/OAuth2Provider.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * Implements an abstract OAuth2 provider with all methods required by the OAuth2Interface.
35 35
  * It also implements the ClientCredentials, CSRFToken and TokenRefresh interfaces in favor over traits.
36 36
  */
37
-abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{
37
+abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface {
38 38
 
39 39
 	/**
40 40
 	 * Specifies the authentication method:
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 			'type'          => 'web_server',
92 92
 		]);
93 93
 
94
-		if(!empty($scopes)){
94
+		if (!empty($scopes)) {
95 95
 			$params['scope'] = implode($this->scopesDelimiter, $scopes);
96 96
 		}
97 97
 
98
-		if($this instanceof CSRFToken){
98
+		if ($this instanceof CSRFToken) {
99 99
 			$params = $this->setState($params);
100 100
 		}
101 101
 
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 		// silly amazon sends compressed data...
115 115
 		$data = json_decode(MessageUtil::decompress($response), true, 512, JSON_THROW_ON_ERROR);
116 116
 
117
-		if(!is_array($data)){
117
+		if (!is_array($data)) {
118 118
 			throw new ProviderException('unable to parse token response');
119 119
 		}
120 120
 
121
-		foreach(['error_description', 'error'] as $field){
121
+		foreach (['error_description', 'error'] as $field) {
122 122
 
123
-			if(isset($data[$field])){
123
+			if (isset($data[$field])) {
124 124
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
125 125
 			}
126 126
 
127 127
 		}
128 128
 
129
-		if(!isset($data['access_token'])){
129
+		if (!isset($data['access_token'])) {
130 130
 			throw new ProviderException('token missing');
131 131
 		}
132 132
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function getAccessToken(string $code, string $state = null):AccessToken{
150 150
 
151
-		if($this instanceof CSRFToken){
151
+		if ($this instanceof CSRFToken) {
152 152
 			$this->checkState($state);
153 153
 		}
154 154
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 			->withHeader('Accept-Encoding', 'identity')
167 167
 			->withBody($this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738)));
168 168
 
169
-		foreach($this->authHeaders as $header => $value){
169
+		foreach ($this->authHeaders as $header => $value) {
170 170
 			$request = $request->withHeader($header, $value);
171 171
 		}
172 172
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function getRequestAuthorization(RequestInterface $request, AccessToken $token):RequestInterface{
184 184
 
185
-		if($this->authMethod === OAuth2Interface::AUTH_METHOD_HEADER){
185
+		if ($this->authMethod === OAuth2Interface::AUTH_METHOD_HEADER) {
186 186
 			return $request->withHeader('Authorization', $this->authMethodHeader.' '.$token->accessToken);
187 187
 		}
188 188
 
189
-		if($this->authMethod === OAuth2Interface::AUTH_METHOD_QUERY){
189
+		if ($this->authMethod === OAuth2Interface::AUTH_METHOD_QUERY) {
190 190
 			$uri = QueryUtil::merge((string)$request->getUri(), [$this->authMethodQuery => $token->accessToken]);
191 191
 
192 192
 			return $request->withUri($this->uriFactory->createUri($uri));
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function getClientCredentialsToken(array $scopes = null):AccessToken{
206 206
 
207
-		if(!$this instanceof ClientCredentials){
207
+		if (!$this instanceof ClientCredentials) {
208 208
 			throw new ProviderException('client credentials token not supported');
209 209
 		}
210 210
 
211 211
 		$params = ['grant_type' => 'client_credentials'];
212 212
 
213
-		if($scopes !== null){
213
+		if ($scopes !== null) {
214 214
 			$params['scope'] = implode($this->scopesDelimiter, $scopes);
215 215
 		}
216 216
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			->withBody($this->streamFactory->createStream(QueryUtil::build($params, PHP_QUERY_RFC1738)))
223 223
 		;
224 224
 
225
-		foreach($this->authHeaders as $header => $value){
225
+		foreach ($this->authHeaders as $header => $value) {
226 226
 			$request = $request->withAddedHeader($header, $value);
227 227
 		}
228 228
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
244 244
 
245
-		if(!$this instanceof TokenRefresh){
245
+		if (!$this instanceof TokenRefresh) {
246 246
 			throw new ProviderException('token refresh not supported');
247 247
 		}
248 248
 
249
-		if($token === null){
249
+		if ($token === null) {
250 250
 			$token = $this->storage->getAccessToken($this->serviceName);
251 251
 		}
252 252
 
253 253
 		$refreshToken = $token->refreshToken;
254 254
 
255
-		if(empty($refreshToken)){
255
+		if (empty($refreshToken)) {
256 256
 			throw new ProviderException(
257 257
 				sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires))
258 258
 			);
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
 			->withBody($this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738)))
274 274
 		;
275 275
 
276
-		foreach($this->authHeaders as $header => $value){
276
+		foreach ($this->authHeaders as $header => $value) {
277 277
 			$request = $request->withAddedHeader($header, $value);
278 278
 		}
279 279
 
280 280
 		$newToken = $this->parseTokenResponse($this->http->sendRequest($request));
281 281
 
282
-		if(empty($newToken->refreshToken)){
282
+		if (empty($newToken->refreshToken)) {
283 283
 			$newToken->refreshToken = $refreshToken;
284 284
 		}
285 285
 
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
 	 */
300 300
 	public function checkState(string $state = null):void{
301 301
 
302
-		if(!$this instanceof CSRFToken){
302
+		if (!$this instanceof CSRFToken) {
303 303
 			throw new ProviderException('CSRF protection not supported');
304 304
 		}
305 305
 
306
-		if(empty($state) || !$this->storage->hasCSRFState($this->serviceName)){
306
+		if (empty($state) || !$this->storage->hasCSRFState($this->serviceName)) {
307 307
 			throw new ProviderException('invalid state for '.$this->serviceName);
308 308
 		}
309 309
 
310 310
 		$knownState = $this->storage->getCSRFState($this->serviceName);
311 311
 
312
-		if(!hash_equals($knownState, $state)){
312
+		if (!hash_equals($knownState, $state)) {
313 313
 			throw new ProviderException('invalid CSRF state: '.$this->serviceName.' '.$state);
314 314
 		}
315 315
 
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function setState(array $params):array{
328 328
 
329
-		if(!$this instanceof CSRFToken){
329
+		if (!$this instanceof CSRFToken) {
330 330
 			throw new ProviderException('CSRF protection not supported');
331 331
 		}
332 332
 
333
-		if(!isset($params['state'])){
333
+		if (!isset($params['state'])) {
334 334
 			$params['state'] = sha1(random_bytes(256));
335 335
 		}
336 336
 
Please login to merge, or discard this patch.
src/Core/OAuthProvider.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @property string      $serviceName
43 43
  * @property string|null $userRevokeURL
44 44
  */
45
-abstract class OAuthProvider implements OAuthInterface{
45
+abstract class OAuthProvider implements OAuthInterface {
46 46
 	use LoggerAwareTrait;
47 47
 
48 48
 	protected const ALLOWED_PROPERTIES = [
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		OAuthStorageInterface $storage,
138 138
 		OAuthOptions|SettingsContainerInterface $options,
139 139
 		LoggerInterface $logger = null
140
-	){
140
+	) {
141 141
 		$this->http    = $http;
142 142
 		$this->storage = $storage;
143 143
 		$this->options = $options;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function __get(string $name):mixed{
160 160
 
161
-		if(in_array($name, $this::ALLOWED_PROPERTIES, true)){
161
+		if (in_array($name, $this::ALLOWED_PROPERTIES, true)) {
162 162
 			return $this->{$name};
163 163
 		}
164 164
 
@@ -234,28 +234,28 @@  discard block
 block discarded – undo
234 234
 		$request = $this->requestFactory
235 235
 			->createRequest($method ?? 'GET', QueryUtil::merge($this->getRequestTarget($path), $params ?? []));
236 236
 
237
-		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
237
+		foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) {
238 238
 			$request = $request->withAddedHeader($header, $value);
239 239
 		}
240 240
 
241
-		if($request->hasHeader('content-type')){
241
+		if ($request->hasHeader('content-type')) {
242 242
 			$contentType = strtolower($request->getHeaderLine('content-type'));
243 243
 
244
-			if(is_array($body)){
245
-				if($contentType === 'application/x-www-form-urlencoded'){
244
+			if (is_array($body)) {
245
+				if ($contentType === 'application/x-www-form-urlencoded') {
246 246
 					$body = $this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738));
247 247
 				}
248
-				elseif(in_array($contentType, ['application/json', 'application/vnd.api+json'])){
248
+				elseif (in_array($contentType, ['application/json', 'application/vnd.api+json'])) {
249 249
 					$body = $this->streamFactory->createStream(json_encode($body));
250 250
 				}
251 251
 			}
252
-			elseif(is_string($body)){
252
+			elseif (is_string($body)) {
253 253
 				// we don't check if the given string matches the content type - this is the implementor's responsibility
254 254
 				$body = $this->streamFactory->createStream($body);
255 255
 			}
256 256
 		}
257 257
 
258
-		if($body instanceof StreamInterface){
258
+		if ($body instanceof StreamInterface) {
259 259
 			$request = $request
260 260
 				->withBody($body)
261 261
 				->withHeader('Content-length', (string)$body->getSize())
@@ -277,18 +277,18 @@  discard block
 block discarded – undo
277 277
 	protected function getRequestTarget(string $uri):string{
278 278
 		$parsedURL = QueryUtil::parseUrl($uri);
279 279
 
280
-		if(!isset($parsedURL['path'])){
280
+		if (!isset($parsedURL['path'])) {
281 281
 			throw new ProviderException('invalid path');
282 282
 		}
283 283
 
284 284
 		// for some reason we were given a host name
285
-		if(isset($parsedURL['host'])){
285
+		if (isset($parsedURL['host'])) {
286 286
 			$api  = QueryUtil::parseUrl($this->apiURL);
287 287
 			$host = $api['host'] ?? null;
288 288
 
289 289
 			// back out if it doesn't match
290
-			if($parsedURL['host'] !== $host){
291
-				throw new ProviderException(sprintf('given host (%s) does not match provider (%s)', $parsedURL['host'] , $host));
290
+			if ($parsedURL['host'] !== $host) {
291
+				throw new ProviderException(sprintf('given host (%s) does not match provider (%s)', $parsedURL['host'], $host));
292 292
 			}
293 293
 
294 294
 			// we explicitly ignore any existing parameters here
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 	public function sendRequest(RequestInterface $request):ResponseInterface{
306 306
 
307 307
 		// get authorization only if we request the provider API
308
-		if(str_starts_with((string)$request->getUri(), $this->apiURL)){
308
+		if (str_starts_with((string)$request->getUri(), $this->apiURL)) {
309 309
 			$token = $this->storage->getAccessToken($this->serviceName);
310 310
 
311 311
 			// attempt to refresh an expired token
312
-			if(
312
+			if (
313 313
 				$this instanceof TokenRefresh
314 314
 				&& $this->options->tokenAutoRefresh
315 315
 				&& ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)
316
-			){
316
+			) {
317 317
 				$token = $this->refreshAccessToken($token);
318 318
 			}
319 319
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -244,12 +244,10 @@
 block discarded – undo
244 244
 			if(is_array($body)){
245 245
 				if($contentType === 'application/x-www-form-urlencoded'){
246 246
 					$body = $this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738));
247
-				}
248
-				elseif(in_array($contentType, ['application/json', 'application/vnd.api+json'])){
247
+				} elseif(in_array($contentType, ['application/json', 'application/vnd.api+json'])){
249 248
 					$body = $this->streamFactory->createStream(json_encode($body));
250 249
 				}
251
-			}
252
-			elseif(is_string($body)){
250
+			} elseif(is_string($body)){
253 251
 				// we don't check if the given string matches the content type - this is the implementor's responsibility
254 252
 				$body = $this->streamFactory->createStream($body);
255 253
 			}
Please login to merge, or discard this patch.
src/Storage/OAuthStorageAbstract.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * Implements ab anstract OAuth storage adapter
21 21
  */
22
-abstract class OAuthStorageAbstract implements OAuthStorageInterface{
22
+abstract class OAuthStorageAbstract implements OAuthStorageInterface {
23 23
 	use LoggerAwareTrait;
24 24
 
25 25
 	protected OAuthOptions|SettingsContainerInterface $options;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * OAuthStorageAbstract constructor.
29 29
 	 */
30
-	public function __construct(OAuthOptions|SettingsContainerInterface $options = null, LoggerInterface $logger = null){
30
+	public function __construct(OAuthOptions|SettingsContainerInterface $options = null, LoggerInterface $logger = null) {
31 31
 		$this->options = $options ?? new OAuthOptions;
32 32
 		$this->logger  = $logger ?? new NullLogger;
33 33
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function fromStorage(mixed $data):AccessToken{
49 49
 
50
-		if(!is_string($data)){
50
+		if (!is_string($data)) {
51 51
 			throw new OAuthStorageException('invalid data');
52 52
 		}
53 53
 
Please login to merge, or discard this patch.