@@ -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 |
@@ -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 |
@@ -33,13 +33,13 @@ |
||
33 | 33 | $response = $this->request('/user'); |
34 | 34 | $status = $response->getStatusCode(); |
35 | 35 | |
36 | - if($status === 200){ |
|
36 | + if ($status === 200) { |
|
37 | 37 | return $response; |
38 | 38 | } |
39 | 39 | |
40 | 40 | $json = MessageUtil::decodeJSON($response); |
41 | 41 | |
42 | - if(isset($json->error, $json->error->message)){ |
|
42 | + if (isset($json->error, $json->error->message)) { |
|
43 | 43 | throw new ProviderException($json->error->message); |
44 | 44 | } |
45 | 45 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @see https://developers.google.com/identity/protocols/OAuth2ServiceAccount |
21 | 21 | * @see https://developers.google.com/oauthplayground/ |
22 | 22 | */ |
23 | -class Google extends OAuth2Provider implements CSRFToken{ |
|
23 | +class Google extends OAuth2Provider implements CSRFToken { |
|
24 | 24 | |
25 | 25 | public const SCOPE_EMAIL = 'email'; |
26 | 26 | public const SCOPE_PROFILE = 'profile'; |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | $response = $this->request('/userinfo/v2/me'); |
47 | 47 | $status = $response->getStatusCode(); |
48 | 48 | |
49 | - if($status === 200){ |
|
49 | + if ($status === 200) { |
|
50 | 50 | return $response; |
51 | 51 | } |
52 | 52 | |
53 | 53 | $json = MessageUtil::decodeJSON($response); |
54 | 54 | |
55 | - if(isset($json->error, $json->error->message)){ |
|
55 | + if (isset($json->error, $json->error->message)) { |
|
56 | 56 | throw new ProviderException($json->error->message); |
57 | 57 | } |
58 | 58 |