@@ -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 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * Implements an abstract OAuth1 provider with all methods required by the OAuth1Interface. |
25 | 25 | */ |
26 | -abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{ |
|
26 | +abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * The request OAuth1 token URL |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ->withHeader('Content-Length', '0') // tumblr requires a content-length header set |
63 | 63 | ; |
64 | 64 | |
65 | - foreach($this->authHeaders as $header => $value){ |
|
65 | + foreach ($this->authHeaders as $header => $value) { |
|
66 | 66 | $request = $request->withAddedHeader($header, $value); |
67 | 67 | } |
68 | 68 | |
@@ -83,20 +83,20 @@ discard block |
||
83 | 83 | protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{ |
84 | 84 | $data = Query::parse(decompress_content($response)); |
85 | 85 | |
86 | - if(!$data || !is_array($data)){ |
|
86 | + if (!$data || !is_array($data)) { |
|
87 | 87 | throw new ProviderException('unable to parse token response'); |
88 | 88 | } |
89 | - elseif(isset($data['error'])){ |
|
89 | + elseif (isset($data['error'])) { |
|
90 | 90 | throw new ProviderException('error retrieving access token: '.$data['error']); |
91 | 91 | } |
92 | - elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){ |
|
92 | + elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) { |
|
93 | 93 | throw new ProviderException('invalid token'); |
94 | 94 | } |
95 | 95 | |
96 | - if( |
|
96 | + if ( |
|
97 | 97 | $checkCallbackConfirmed |
98 | 98 | && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true') |
99 | - ){ |
|
99 | + ) { |
|
100 | 100 | throw new ProviderException('oauth callback unconfirmed'); |
101 | 101 | } |
102 | 102 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{ |
147 | 147 | $parseURL = parse_url($url); |
148 | 148 | |
149 | - if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){ |
|
149 | + if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) { |
|
150 | 150 | throw new ProviderException('getSignature: invalid url'); |
151 | 151 | } |
152 | 152 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $token->accessTokenSecret |
207 | 207 | ); |
208 | 208 | |
209 | - if(isset($query['oauth_session_handle'])){ |
|
209 | + if (isset($query['oauth_session_handle'])) { |
|
210 | 210 | $parameters['oauth_session_handle'] = $query['oauth_session_handle']; // @codeCoverageIgnore |
211 | 211 | } |
212 | 212 |
@@ -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 |
@@ -15,6 +15,6 @@ |
||
15 | 15 | /** |
16 | 16 | * @property string $API_BASE |
17 | 17 | */ |
18 | -interface EndpointMapInterface extends SettingsContainerInterface{ |
|
18 | +interface EndpointMapInterface extends SettingsContainerInterface { |
|
19 | 19 | |
20 | 20 | } |