@@ -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 {} |
|
@@ -14,4 +14,4 @@ |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\OAuth\OAuthException; |
| 16 | 16 | |
| 17 | -class OAuthStorageException extends OAuthException{} |
|
| 17 | +class OAuthStorageException extends OAuthException {} |
|
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Implements an abstract OAuth1 provider with all methods required by the OAuth1Interface. |
| 24 | 24 | */ |
| 25 | -abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{ |
|
| 25 | +abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface { |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * The request OAuth1 token URL |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ->withHeader('Content-Length', '0') // tumblr requires a content-length header set |
| 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 | |
@@ -82,20 +82,20 @@ 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( |
|
| 95 | + if ( |
|
| 96 | 96 | $checkCallbackConfirmed |
| 97 | 97 | && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') |
| 98 | - ){ |
|
| 98 | + ) { |
|
| 99 | 99 | throw new ProviderException('oauth callback unconfirmed'); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ |
| 146 | 146 | $parseURL = parse_url($url); |
| 147 | 147 | |
| 148 | - if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){ |
|
| 148 | + if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) { |
|
| 149 | 149 | throw new ProviderException('getSignature: invalid url'); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $token->accessTokenSecret |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - if(isset($query['oauth_session_handle'])){ |
|
| 208 | + if (isset($query['oauth_session_handle'])) { |
|
| 209 | 209 | $parameters['oauth_session_handle'] = $query['oauth_session_handle']; // @codeCoverageIgnore |
| 210 | 210 | } |
| 211 | 211 | |
@@ -40,6 +40,6 @@ |
||
| 40 | 40 | * @property int $retries |
| 41 | 41 | * @property array $curl_multi_options |
| 42 | 42 | */ |
| 43 | -class OAuthOptions extends SettingsContainerAbstract{ |
|
| 43 | +class OAuthOptions extends SettingsContainerAbstract { |
|
| 44 | 44 | use OAuthOptionsTrait, HTTPOptionsTrait; |
| 45 | 45 | } |
@@ -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 | |
@@ -12,4 +12,4 @@ |
||
| 12 | 12 | |
| 13 | 13 | use Exception; |
| 14 | 14 | |
| 15 | -class ApiClientException extends Exception{} |
|
| 15 | +class ApiClientException extends Exception {} |
|
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | use chillerlan\Settings\SettingsContainerAbstract; |
| 14 | 14 | |
| 15 | -abstract class EndpointMap extends SettingsContainerAbstract implements EndpointMapInterface{ |
|
| 15 | +abstract class EndpointMap extends SettingsContainerAbstract implements EndpointMapInterface { |
|
| 16 | 16 | |
| 17 | 17 | protected string $API_BASE = ''; |
| 18 | 18 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | use Psr\Http\Message\ResponseInterface; |
| 14 | 14 | |
| 15 | -interface ApiClientInterface{ |
|
| 15 | +interface ApiClientInterface { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Implements the Magic API client |