@@ -12,4 +12,4 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\OAuth; |
| 14 | 14 | |
| 15 | -class OAuthException extends \Exception{} |
|
| 15 | +class OAuthException extends \Exception {} |
|
@@ -14,4 +14,4 @@ |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\OAuth\OAuthException; |
| 16 | 16 | |
| 17 | -class ProviderException extends OAuthException{} |
|
| 17 | +class ProviderException extends OAuthException {} |
|
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\OAuth\Core; |
| 14 | 14 | |
| 15 | -interface TokenRefresh{ |
|
| 15 | +interface TokenRefresh { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @param \chillerlan\OAuth\Core\AccessToken|null $token |
@@ -12,7 +12,7 @@ |
||
| 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 | * @return \chillerlan\OAuth\Core\AccessToken |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\OAuth\Core; |
| 14 | 14 | |
| 15 | -interface ClientCredentials{ |
|
| 15 | +interface ClientCredentials { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @param array $scopes |
@@ -138,11 +138,9 @@ |
||
| 138 | 138 | |
| 139 | 139 | if($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES){ |
| 140 | 140 | $this->expires = $this::EOL_NEVER_EXPIRES; |
| 141 | - } |
|
| 142 | - elseif($expires > $now){ |
|
| 141 | + } elseif($expires > $now){ |
|
| 143 | 142 | $this->expires = $expires; |
| 144 | - } |
|
| 145 | - elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
| 143 | + } elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
| 146 | 144 | $this->expires = $now + $expires; |
| 147 | 145 | } |
| 148 | 146 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @property int $expires |
| 30 | 30 | * @property string $provider |
| 31 | 31 | */ |
| 32 | -class AccessToken extends SettingsContainerAbstract{ |
|
| 32 | +class AccessToken extends SettingsContainerAbstract { |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Denotes an unknown end of life time. |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param iterable|null $properties |
| 86 | 86 | */ |
| 87 | - public function __construct(iterable $properties = null){ |
|
| 87 | + public function __construct(iterable $properties = null) { |
|
| 88 | 88 | parent::__construct($properties); |
| 89 | 89 | |
| 90 | 90 | $this->setExpiry($this->expires); |
@@ -109,19 +109,19 @@ discard block |
||
| 109 | 109 | public function setExpiry(int $expires = null):AccessToken{ |
| 110 | 110 | $now = time(); |
| 111 | 111 | |
| 112 | - if($expires!== null){ |
|
| 112 | + if ($expires !== null) { |
|
| 113 | 113 | $expires = intval($expires); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $this->expires = $this::EOL_UNKNOWN; |
| 117 | 117 | |
| 118 | - if($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES){ |
|
| 118 | + if ($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES) { |
|
| 119 | 119 | $this->expires = $this::EOL_NEVER_EXPIRES; |
| 120 | 120 | } |
| 121 | - elseif($expires > $now){ |
|
| 121 | + elseif ($expires > $now) { |
|
| 122 | 122 | $this->expires = $expires; |
| 123 | 123 | } |
| 124 | - elseif($expires > 0 && $expires < $this::EXPIRY_MAX){ |
|
| 124 | + elseif ($expires > 0 && $expires < $this::EXPIRY_MAX) { |
|
| 125 | 125 | $this->expires = $now + $expires; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -14,4 +14,4 @@ |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\OAuth\OAuthException; |
| 16 | 16 | |
| 17 | -class OAuthStorageException extends OAuthException{} |
|
| 17 | +class OAuthStorageException extends OAuthException {} |
|
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\OAuth; |
| 14 | 14 | |
| 15 | -trait OAuthOptionsTrait{ |
|
| 15 | +trait OAuthOptionsTrait { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @var string |
@@ -78,11 +78,9 @@ |
||
| 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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | implode, in_array, is_array, parse_str, parse_url, random_bytes, strtoupper; |
| 22 | 22 | use function chillerlan\HTTP\Psr7\{build_http_query, decompress_content, merge_query, r_rawurlencode}; |
| 23 | 23 | |
| 24 | -abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{ |
|
| 24 | +abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface { |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @var string |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ->withHeader('Accept-Encoding', 'identity') |
| 66 | 66 | ; |
| 67 | 67 | |
| 68 | - foreach($this->authHeaders as $header => $value){ |
|
| 68 | + foreach ($this->authHeaders as $header => $value) { |
|
| 69 | 69 | $request = $request->withAddedHeader($header, $value); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{ |
| 83 | 83 | parse_str(decompress_content($response), $data); |
| 84 | 84 | |
| 85 | - if(!$data || !is_array($data)){ |
|
| 85 | + if (!$data || !is_array($data)) { |
|
| 86 | 86 | throw new ProviderException('unable to parse token response'); |
| 87 | 87 | } |
| 88 | - elseif(isset($data['error'])){ |
|
| 88 | + elseif (isset($data['error'])) { |
|
| 89 | 89 | throw new ProviderException('error retrieving access token: '.$data['error']); |
| 90 | 90 | } |
| 91 | - elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
| 91 | + elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) { |
|
| 92 | 92 | throw new ProviderException('invalid token'); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if($checkCallbackConfirmed && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')){ |
|
| 95 | + if ($checkCallbackConfirmed && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')) { |
|
| 96 | 96 | throw new ProviderException('oauth callback unconfirmed'); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ |
| 139 | 139 | $parseURL = parse_url($url); |
| 140 | 140 | |
| 141 | - if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){ |
|
| 141 | + if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) { |
|
| 142 | 142 | throw new ProviderException('getSignature: invalid url'); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $signatureParams = array_merge($query, $params); |
| 148 | 148 | |
| 149 | - if(isset($signatureParams['oauth_signature'])){ |
|
| 149 | + if (isset($signatureParams['oauth_signature'])) { |
|
| 150 | 150 | unset($signatureParams['oauth_signature']); |
| 151 | 151 | } |
| 152 | 152 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $token->accessTokenSecret |
| 205 | 205 | ); |
| 206 | 206 | |
| 207 | - if(isset($query['oauth_session_handle'])){ |
|
| 207 | + if (isset($query['oauth_session_handle'])) { |
|
| 208 | 208 | $parameters['oauth_session_handle'] = $query['oauth_session_handle']; // @codeCoverageIgnore |
| 209 | 209 | } |
| 210 | 210 | |