@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @see http://developer.mailchimp.com/ |
| 22 | 22 | * @see http://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-oauth2/ |
| 23 | 23 | */ |
| 24 | -class MailChimp extends OAuth2Provider implements CSRFToken{ |
|
| 24 | +class MailChimp extends OAuth2Provider implements CSRFToken { |
|
| 25 | 25 | |
| 26 | 26 | protected const API_BASE = 'https://%s.api.mailchimp.com'; |
| 27 | 27 | protected const METADATA_ENDPOINT = 'https://login.mailchimp.com/oauth2/metadata'; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | $token ??= $this->storage->getAccessToken($this->serviceName); |
| 41 | 41 | |
| 42 | - if(!$token instanceof AccessToken){ |
|
| 42 | + if (!$token instanceof AccessToken) { |
|
| 43 | 43 | throw new OAuthException('invalid token'); // @codeCoverageIgnore |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | $response = $this->http->sendRequest($request); |
| 52 | 52 | |
| 53 | - if($response->getStatusCode() !== 200){ |
|
| 53 | + if ($response->getStatusCode() !== 200) { |
|
| 54 | 54 | throw new OAuthException('metadata response error'); // @codeCoverageIgnore |
| 55 | 55 | } |
| 56 | 56 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | string $path, |
| 71 | 71 | array $params = null, |
| 72 | 72 | string $method = null, |
| 73 | - StreamInterface|array|string $body = null, |
|
| 73 | + StreamInterface | array | string $body = null, |
|
| 74 | 74 | array $headers = null |
| 75 | 75 | ):ResponseInterface{ |
| 76 | 76 | $token = $this->storage->getAccessToken($this->serviceName); |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | $response = $this->request('/3.0/'); // trailing slash! |
| 89 | 89 | $status = $response->getStatusCode(); |
| 90 | 90 | |
| 91 | - if($status === 200){ |
|
| 91 | + if ($status === 200) { |
|
| 92 | 92 | return $response; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $json = MessageUtil::decodeJSON($response); |
| 96 | 96 | |
| 97 | - if(isset($json->detail)){ |
|
| 97 | + if (isset($json->detail)) { |
|
| 98 | 98 | throw new ProviderException($json->detail); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -39,13 +39,13 @@ |
||
| 39 | 39 | $response = $this->request('/3/account/me'); |
| 40 | 40 | $status = $response->getStatusCode(); |
| 41 | 41 | |
| 42 | - if($status === 200){ |
|
| 42 | + if ($status === 200) { |
|
| 43 | 43 | return $response; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $json = MessageUtil::decodeJSON($response); |
| 47 | 47 | |
| 48 | - if(isset($json->data, $json->data->error)){ |
|
| 48 | + if (isset($json->data, $json->data->error)) { |
|
| 49 | 49 | throw new ProviderException($json->data->error); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @see https://wiki.openstreetmap.org/wiki/API |
| 22 | 22 | * @see https://wiki.openstreetmap.org/wiki/OAuth |
| 23 | 23 | */ |
| 24 | -class OpenStreetmap extends OAuth1Provider{ |
|
| 24 | +class OpenStreetmap extends OAuth1Provider { |
|
| 25 | 25 | |
| 26 | 26 | protected string $requestTokenURL = 'https://www.openstreetmap.org/oauth/request_token'; |
| 27 | 27 | protected string $authURL = 'https://www.openstreetmap.org/oauth/authorize'; |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | $response = $this->request('/api/0.6/user/details'.($json ? '.json' : '')); |
| 38 | 38 | $status = $response->getStatusCode(); |
| 39 | 39 | |
| 40 | - if($status === 200){ |
|
| 40 | + if ($status === 200) { |
|
| 41 | 41 | return $response; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $body = MessageUtil::getContents($response); |
| 45 | 45 | |
| 46 | - if(!empty($body)){ |
|
| 46 | + if (!empty($body)) { |
|
| 47 | 47 | throw new ProviderException(strip_tags($body)); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -57,13 +57,13 @@ |
||
| 57 | 57 | $response = $this->request('/users/@me'); |
| 58 | 58 | $status = $response->getStatusCode(); |
| 59 | 59 | |
| 60 | - if($status === 200){ |
|
| 60 | + if ($status === 200) { |
|
| 61 | 61 | return $response; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $json = MessageUtil::decodeJSON($response); |
| 65 | 65 | |
| 66 | - if(isset($json->message)){ |
|
| 66 | + if (isset($json->message)) { |
|
| 67 | 67 | throw new ProviderException($json->message); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * sure, you *can* use different parameter names than the standard ones... and what about JSON? |
| 26 | 26 | * https://xkcd.com/927/ |
| 27 | 27 | */ |
| 28 | -class Deezer extends OAuth2Provider implements CSRFToken{ |
|
| 28 | +class Deezer extends OAuth2Provider implements CSRFToken { |
|
| 29 | 29 | |
| 30 | 30 | public const SCOPE_BASIC = 'basic_access'; |
| 31 | 31 | public const SCOPE_EMAIL = 'email'; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function getAuthURL(array $params = null, array $scopes = null):UriInterface{ |
| 58 | 58 | $params ??= []; |
| 59 | 59 | |
| 60 | - if(isset($params['client_secret'])){ |
|
| 60 | + if (isset($params['client_secret'])) { |
|
| 61 | 61 | unset($params['client_secret']); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | protected function parseTokenResponse(ResponseInterface $response):AccessToken{ |
| 106 | 106 | $data = QueryUtil::parse(MessageUtil::decompress($response)); |
| 107 | 107 | |
| 108 | - if(isset($data['error_reason'])){ |
|
| 108 | + if (isset($data['error_reason'])) { |
|
| 109 | 109 | throw new ProviderException('error retrieving access token: "'.$data['error_reason'].'"'); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if(!isset($data['access_token'])){ |
|
| 112 | + if (!isset($data['access_token'])) { |
|
| 113 | 113 | throw new ProviderException('token missing'); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -137,11 +137,11 @@ discard block |
||
| 137 | 137 | $status = $response->getStatusCode(); |
| 138 | 138 | $json = MessageUtil::decodeJSON($response); |
| 139 | 139 | |
| 140 | - if($status === 200 && !isset($json->error)){ |
|
| 140 | + if ($status === 200 && !isset($json->error)) { |
|
| 141 | 141 | return $response; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if(isset($json->error)){ |
|
| 144 | + if (isset($json->error)) { |
|
| 145 | 145 | throw new ProviderException($json->error->message); |
| 146 | 146 | } |
| 147 | 147 | |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | /** |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class PayPalSandbox extends PayPal{ |
|
| 16 | +class PayPalSandbox extends PayPal { |
|
| 17 | 17 | |
| 18 | 18 | protected string $authURL = 'https://www.sandbox.paypal.com/connect'; |
| 19 | 19 | protected string $accessTokenURL = 'https://api.sandbox.paypal.com/v1/oauth2/token'; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @todo: https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_token |
| 21 | 21 | */ |
| 22 | -class TwitterCC extends OAuth2Provider implements ClientCredentials{ |
|
| 22 | +class TwitterCC extends OAuth2Provider implements ClientCredentials { |
|
| 23 | 23 | |
| 24 | 24 | protected const AUTH_ERRMSG = 'TwitterCC only supports Client Credentials Grant, use the Twitter OAuth1 class for authentication instead.'; |
| 25 | 25 | |
@@ -59,28 +59,28 @@ |
||
| 59 | 59 | $token = $this->storage->getAccessToken($this->serviceName); |
| 60 | 60 | $scopes = explode(' ', $token->extraParams['scope']); |
| 61 | 61 | |
| 62 | - if(in_array(self::SCOPE_V2_IDENTITY, $scopes)){ |
|
| 62 | + if (in_array(self::SCOPE_V2_IDENTITY, $scopes)) { |
|
| 63 | 63 | $endpoint = '/v2/identity'; |
| 64 | 64 | $params = ['fields[user]' => 'about,created,email,first_name,full_name,image_url,last_name,social_connections,thumb_url,url,vanity']; |
| 65 | 65 | } |
| 66 | - elseif(in_array(self::SCOPE_V1_USERS, $scopes)){ |
|
| 66 | + elseif (in_array(self::SCOPE_V1_USERS, $scopes)) { |
|
| 67 | 67 | $endpoint = '/api/current_user'; |
| 68 | 68 | $params = []; |
| 69 | 69 | } |
| 70 | - else{ |
|
| 70 | + else { |
|
| 71 | 71 | throw new ProviderException('invalid scopes for the identity endpoint'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $response = $this->request($endpoint, $params); |
| 75 | 75 | $status = $response->getStatusCode(); |
| 76 | 76 | |
| 77 | - if($status === 200){ |
|
| 77 | + if ($status === 200) { |
|
| 78 | 78 | return $response; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $json = MessageUtil::decodeJSON($response); |
| 82 | 82 | |
| 83 | - if(isset($json->errors[0]->code_name)){ |
|
| 83 | + if (isset($json->errors[0]->code_name)) { |
|
| 84 | 84 | throw new ProviderException($json->errors[0]->code_name); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -62,12 +62,10 @@ |
||
| 62 | 62 | if(in_array(self::SCOPE_V2_IDENTITY, $scopes)){ |
| 63 | 63 | $endpoint = '/v2/identity'; |
| 64 | 64 | $params = ['fields[user]' => 'about,created,email,first_name,full_name,image_url,last_name,social_connections,thumb_url,url,vanity']; |
| 65 | - } |
|
| 66 | - elseif(in_array(self::SCOPE_V1_USERS, $scopes)){ |
|
| 65 | + } elseif(in_array(self::SCOPE_V1_USERS, $scopes)){ |
|
| 67 | 66 | $endpoint = '/api/current_user'; |
| 68 | 67 | $params = []; |
| 69 | - } |
|
| 70 | - else{ |
|
| 68 | + } else{ |
|
| 71 | 69 | throw new ProviderException('invalid scopes for the identity endpoint'); |
| 72 | 70 | } |
| 73 | 71 | |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function __construct( |
| 52 | 52 | ClientInterface $http, |
| 53 | - OAuthOptions|SettingsContainerInterface $options, |
|
| 53 | + OAuthOptions | SettingsContainerInterface $options, |
|
| 54 | 54 | LoggerInterface $logger = null |
| 55 | - ){ |
|
| 55 | + ) { |
|
| 56 | 56 | parent::__construct($http, $options, $logger); |
| 57 | 57 | |
| 58 | 58 | $this->setRegion('eu'); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function setRegion(string $region):BattleNet{ |
| 67 | 67 | $region = strtolower($region); |
| 68 | 68 | |
| 69 | - if(!in_array($region, ['apac', 'cn', 'eu', 'us'], true)){ |
|
| 69 | + if (!in_array($region, ['apac', 'cn', 'eu', 'us'], true)) { |
|
| 70 | 70 | throw new ProviderException('invalid region: '.$region); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | $response = $this->request('/oauth/userinfo'); |
| 87 | 87 | $status = $response->getStatusCode(); |
| 88 | 88 | |
| 89 | - if($status === 200){ |
|
| 89 | + if ($status === 200) { |
|
| 90 | 90 | return $response; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $json = MessageUtil::decodeJSON($response); |
| 94 | 94 | |
| 95 | - if(isset($json->error, $json->error_description)){ |
|
| 95 | + if (isset($json->error, $json->error_description)) { |
|
| 96 | 96 | throw new ProviderException($json->error_description); |
| 97 | 97 | } |
| 98 | 98 | |