Passed
Branch main (fe64e0)
by smiley
06:14 queued 04:33
created
src/OAuthException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,4 +12,4 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth;
14 14
 
15
-class OAuthException extends \Exception{}
15
+class OAuthException extends \Exception {}
Please login to merge, or discard this patch.
src/Core/ProviderException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,4 +14,4 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\OAuthException;
16 16
 
17
-class ProviderException extends OAuthException{}
17
+class ProviderException extends OAuthException {}
Please login to merge, or discard this patch.
src/Storage/OAuthStorageException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,4 +14,4 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\OAuthException;
16 16
 
17
-class OAuthStorageException extends OAuthException{}
17
+class OAuthStorageException extends OAuthException {}
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
@@ -78,11 +78,9 @@
 block discarded – undo
78 78
 
79 79
 		if(!$data || !is_array($data)){
80 80
 			throw new ProviderException('unable to parse token response');
81
-		}
82
-		elseif(isset($data['error'])){
81
+		} elseif(isset($data['error'])){
83 82
 			throw new ProviderException('error retrieving access token: '.$data['error']);
84
-		}
85
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
83
+		} elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
86 84
 			throw new ProviderException('invalid token');
87 85
 		}
88 86
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 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/Core/OAuthProvider.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -296,8 +296,7 @@
 block discarded – undo
296 296
 			// @todo: content type support
297 297
 			if($contentType === 'application/x-www-form-urlencoded'){
298 298
 				$body = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
299
-			}
300
-			elseif($contentType === 'application/json'){
299
+			} elseif($contentType === 'application/json'){
301 300
 				$body = $this->streamFactory->createStream(json_encode($body));
302 301
 			}
303 302
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Core/CSRFToken.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,6 @@
 block discarded – undo
18 18
  * checkState(string $state = null):void
19 19
  * setState(array $params):array
20 20
  */
21
-interface CSRFToken{
21
+interface CSRFToken {
22 22
 
23 23
 }
Please login to merge, or discard this patch.
src/OAuthOptionsTrait.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth;
14 14
 
15
-trait OAuthOptionsTrait{
15
+trait OAuthOptionsTrait {
16 16
 
17 17
 	/**
18 18
 	 * The application key (or id) given by your provider
Please login to merge, or discard this patch.
src/Core/TokenRefresh.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface TokenRefresh{
15
+interface TokenRefresh {
16 16
 
17 17
 	/**
18 18
 	 * Tries to refresh an existing access token with an associated refresh token
Please login to merge, or discard this patch.
src/Core/OAuth1Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface OAuth1Interface extends OAuthInterface{
15
+interface OAuth1Interface extends OAuthInterface {
16 16
 
17 17
 	/**
18 18
 	 * Obtains an OAuth1 request token and returns an AccessToken
Please login to merge, or discard this patch.