Passed
Push — main ( e868ec...9f95cc )
by smiley
12:00
created
src/MusicBrainz.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
56 56
 
57
-		if($token === null){
57
+		if ($token === null) {
58 58
 			$token = $this->storage->getAccessToken($this->serviceName);
59 59
 		}
60 60
 
61 61
 		$refreshToken = $token->refreshToken;
62 62
 
63
-		if(empty($refreshToken)){
63
+		if (empty($refreshToken)) {
64 64
 			throw new ProviderException(
65 65
 				sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires))
66 66
 			);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 		$newToken = $this->parseTokenResponse($this->http->sendRequest($request));
84 84
 
85
-		if(empty($newToken->refreshToken)){
85
+		if (empty($newToken->refreshToken)) {
86 86
 			$newToken->refreshToken = $refreshToken;
87 87
 		}
88 88
 
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 		string $path,
99 99
 		array $params = null,
100 100
 		string $method = null,
101
-		StreamInterface|array|string $body = null,
101
+		StreamInterface | array | string $body = null,
102 102
 		array $headers = null
103 103
 	):ResponseInterface{
104 104
 		$params = $params ?? [];
105 105
 		$method = strtoupper($method ?? 'GET');
106 106
 		$token  = $this->storage->getAccessToken($this->serviceName);
107 107
 
108
-		if($token->isExpired()){
108
+		if ($token->isExpired()) {
109 109
 			$this->refreshAccessToken($token);
110 110
 		}
111 111
 
112
-		if(!isset($params['fmt'])){
112
+		if (!isset($params['fmt'])) {
113 113
 			$params['fmt'] = 'json';
114 114
 		}
115 115
 
116
-		if(in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])){
116
+		if (in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])) {
117 117
 			$params['client'] = $this->options->user_agent; // @codeCoverageIgnore
118 118
 		}
119 119
 
Please login to merge, or discard this patch.
src/Gitter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @see https://developer.gitter.im/
20 20
  * @see https://developer.gitter.im/docs/authentication
21 21
  */
22
-class Gitter extends OAuth2Provider implements CSRFToken{
22
+class Gitter extends OAuth2Provider implements CSRFToken {
23 23
 
24 24
 	public const SCOPE_FLOW            = 'flow';
25 25
 	public const SCOPE_PRIVATE         = 'private';
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 		$response = $this->request('/v1/user/me');
44 44
 		$status   = $response->getStatusCode();
45 45
 
46
-		if($status === 200){
46
+		if ($status === 200) {
47 47
 			return $response;
48 48
 		}
49 49
 
50 50
 		$json = MessageUtil::decodeJSON($response);
51 51
 
52
-		if(isset($json->error)){
52
+		if (isset($json->error)) {
53 53
 			throw new ProviderException($json->error);
54 54
 		}
55 55
 
Please login to merge, or discard this patch.
src/Instagram.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @see https://developers.facebook.com/docs/instagram
20 20
  * @see https://developers.facebook.com/docs/instagram-basic-display-api/reference/oauth-authorize
21 21
  */
22
-class Instagram extends OAuth2Provider implements CSRFToken{
22
+class Instagram extends OAuth2Provider implements CSRFToken {
23 23
 
24 24
 	public const SCOPE_BASIC          = 'basic';
25 25
 	public const SCOPE_COMMENTS       = 'comments';
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 		$response = $this->request('/me/');
49 49
 		$status   = $response->getStatusCode();
50 50
 
51
-		if($status === 200){
51
+		if ($status === 200) {
52 52
 			return $response;
53 53
 		}
54 54
 
55 55
 		$json = MessageUtil::decodeJSON($response);
56 56
 
57
-		if(isset($json->error, $json->error_description)){
57
+		if (isset($json->error, $json->error_description)) {
58 58
 			throw new ProviderException($json->error_description);
59 59
 		}
60 60
 
Please login to merge, or discard this patch.
src/Foursquare.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @see https://developer.foursquare.com/docs/
24 24
  * @see https://developer.foursquare.com/overview/auth
25 25
  */
26
-class Foursquare extends OAuth2Provider{
26
+class Foursquare extends OAuth2Provider {
27 27
 
28 28
 	protected const API_VERSIONDATE = '20190225';
29 29
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		string $path,
44 44
 		array $params = null,
45 45
 		string $method = null,
46
-		StreamInterface|array|string $body = null,
46
+		StreamInterface | array | string $body = null,
47 47
 		array $headers = null
48 48
 	):ResponseInterface{
49 49
 		$queryparams      = QueryUtil::parse(QueryUtil::parseUrl($this->apiURL.$path)['query'] ?? '');
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 		$response = $this->request('/v2/users/self');
61 61
 		$status   = $response->getStatusCode();
62 62
 
63
-		if($status === 200){
63
+		if ($status === 200) {
64 64
 			return $response;
65 65
 		}
66 66
 
67 67
 		$json = MessageUtil::decodeJSON($response);
68 68
 
69
-		if(isset($json->meta, $json->meta->errorDetail)){
69
+		if (isset($json->meta, $json->meta->errorDetail)) {
70 70
 			throw new ProviderException($json->meta->errorDetail);
71 71
 		}
72 72
 
Please login to merge, or discard this patch.
src/Stripe.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@
 block discarded – undo
46 46
 		$response = $this->request('/accounts');
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_description)){
55
+		if (isset($json->error, $json->error_description)) {
56 56
 			throw new ProviderException($json->error_description);
57 57
 		}
58 58
 
Please login to merge, or discard this patch.
src/Amazon.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@
 block discarded – undo
47 47
 		$response = $this->request('/user/profile');
48 48
 		$status   = $response->getStatusCode();
49 49
 
50
-		if($status === 200){
50
+		if ($status === 200) {
51 51
 			return $response;
52 52
 		}
53 53
 
54 54
 		$json = MessageUtil::decodeJSON($response);
55 55
 
56
-		if(isset($json->error, $json->error_description)){
56
+		if (isset($json->error, $json->error_description)) {
57 57
 			throw new ProviderException($json->error_description);
58 58
 		}
59 59
 
Please login to merge, or discard this patch.
src/GuildWars2.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @see https://api.guildwars2.com/v2
28 28
  * @see https://wiki.guildwars2.com/wiki/API:Main
29 29
  */
30
-class GuildWars2 extends OAuth2Provider{
30
+class GuildWars2 extends OAuth2Provider {
31 31
 
32 32
 	public const SCOPE_ACCOUNT        = 'account';
33 33
 	public const SCOPE_INVENTORIES    = 'inventories';
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function storeGW2Token(string $access_token):AccessToken{
58 58
 
59
-		if(!preg_match('/^[a-f\d\-]{72}$/i', $access_token)){
59
+		if (!preg_match('/^[a-f\d\-]{72}$/i', $access_token)) {
60 60
 			throw new ProviderException('invalid token');
61 61
 		}
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$tokeninfo = MessageUtil::decodeJSON($this->http->sendRequest($request));
69 69
 
70
-		if(isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)){
70
+		if (isset($tokeninfo->id) && str_starts_with($access_token, $tokeninfo->id)) {
71 71
 			$token                    = new AccessToken;
72 72
 			$token->provider          = $this->serviceName;
73 73
 			$token->accessToken       = $access_token;
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 		$response = $this->request('/v2/tokeninfo');
112 112
 		$status   = $response->getStatusCode();
113 113
 
114
-		if($status === 200){
114
+		if ($status === 200) {
115 115
 			return $response;
116 116
 		}
117 117
 
118 118
 		$json = MessageUtil::decodeJSON($response);
119 119
 
120
-		if(isset($json->text)){
120
+		if (isset($json->text)) {
121 121
 			throw new ProviderException($json->text);
122 122
 		}
123 123
 
Please login to merge, or discard this patch.
src/LastFM.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * @see https://www.last.fm/api/authentication
29 29
  */
30
-class LastFM extends OAuthProvider{
30
+class LastFM extends OAuthProvider {
31 31
 
32 32
 	public const PERIOD_OVERALL = 'overall';
33 33
 	public const PERIOD_7DAY    = '7day';
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 
71 71
 		$signature = '';
72 72
 
73
-		foreach($params as $k => $v){
74
-			if(!in_array($k, ['format', 'callback'])){
73
+		foreach ($params as $k => $v) {
74
+			if (!in_array($k, ['format', 'callback'])) {
75 75
 				$signature .= $k.$v;
76 76
 			}
77 77
 		}
@@ -104,21 +104,21 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function parseTokenResponse(ResponseInterface $response):AccessToken{
106 106
 
107
-		try{
107
+		try {
108 108
 			$data = MessageUtil::decodeJSON($response, true);
109 109
 
110
-			if(!$data || !is_array($data)){
110
+			if (!$data || !is_array($data)) {
111 111
 				trigger_error('');
112 112
 			}
113 113
 		}
114
-		catch(Throwable $e){
114
+		catch (Throwable $e) {
115 115
 			throw new ProviderException('unable to parse token response');
116 116
 		}
117 117
 
118
-		if(isset($data['error'])){
118
+		if (isset($data['error'])) {
119 119
 			throw new ProviderException('error retrieving access token: '.$data['message']);
120 120
 		}
121
-		elseif(!isset($data['session']['key'])){
121
+		elseif (!isset($data['session']['key'])) {
122 122
 			throw new ProviderException('token missing');
123 123
 		}
124 124
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 		string $path,
145 145
 		array $params = null,
146 146
 		string $method = null,
147
-		StreamInterface|array|string $body = null,
147
+		StreamInterface | array | string $body = null,
148 148
 		array $headers = null
149 149
 	):ResponseInterface{
150 150
 
151
-		if($body !== null && !is_array($body)){
151
+		if ($body !== null && !is_array($body)) {
152 152
 			throw new ProviderException('$body must be an array');
153 153
 		}
154 154
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
 		$params['api_sig'] = $this->getSignature($params);
167 167
 
168
-		if($method === 'POST'){
168
+		if ($method === 'POST') {
169 169
 			$body   = $params;
170 170
 			$params = [];
171 171
 		}
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		/** @phan-suppress-next-line PhanTypeMismatchArgumentNullable */
174 174
 		$request = $this->requestFactory->createRequest($method, QueryUtil::merge($this->apiURL, $params));
175 175
 
176
-		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
176
+		foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) {
177 177
 			$request = $request->withAddedHeader($header, $value);
178 178
 		}
179 179
 
180
-		if($method === 'POST'){
180
+		if ($method === 'POST') {
181 181
 			$request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded');
182 182
 			$body    = $this->streamFactory->createStream(QueryUtil::build($body, PHP_QUERY_RFC1738));
183 183
 			$request = $request->withBody($body);
@@ -201,13 +201,13 @@  discard block
 block discarded – undo
201 201
 		$response = $this->request('user.getInfo');
202 202
 		$status   = $response->getStatusCode();
203 203
 
204
-		if($status === 200){
204
+		if ($status === 200) {
205 205
 			return $response;
206 206
 		}
207 207
 
208 208
 		$json = MessageUtil::decodeJSON($response);
209 209
 
210
-		if(isset($json->error, $json->error_description)){
210
+		if (isset($json->error, $json->error_description)) {
211 211
 			throw new ProviderException($json->error_description);
212 212
 		}
213 213
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -166,15 +166,13 @@
 block discarded – undo
166 166
 			if(!$data || !is_array($data)){
167 167
 				trigger_error('');
168 168
 			}
169
-		}
170
-		catch(Throwable $e){
169
+		} catch(Throwable $e){
171 170
 			throw new ProviderException('unable to parse token response');
172 171
 		}
173 172
 
174 173
 		if(isset($data['error'])){
175 174
 			throw new ProviderException('error retrieving access token: '.$data['message']);
176
-		}
177
-		elseif(!isset($data['session']['key'])){
175
+		} elseif(!isset($data['session']['key'])){
178 176
 			throw new ProviderException('token missing');
179 177
 		}
180 178
 
Please login to merge, or discard this patch.
src/OpenCaching.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * @see https://www.opencaching.de/okapi/
21 21
  */
22
-class OpenCaching extends OAuth1Provider{
22
+class OpenCaching extends OAuth1Provider {
23 23
 
24 24
 	protected string  $requestTokenURL = 'https://www.opencaching.de/okapi/services/oauth/request_token';
25 25
 	protected string  $authURL         = 'https://www.opencaching.de/okapi/services/oauth/authorize';
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 		$response = $this->request('/users/user', ['fields' => 'uuid|username|profile_url|internal_id|date_registered|caches_found|caches_notfound|caches_hidden|rcmds_given|rcmds_left|rcmd_founds_needed|home_location']);
37 37
 		$status   = $response->getStatusCode();
38 38
 
39
-		if($status === 200){
39
+		if ($status === 200) {
40 40
 			return $response;
41 41
 		}
42 42
 
43 43
 		$json = MessageUtil::decodeJSON($response);
44 44
 
45
-		if(isset($json->error, $json->error_description)){
45
+		if (isset($json->error, $json->error_description)) {
46 46
 			throw new ProviderException($json->error_description);
47 47
 		}
48 48
 
Please login to merge, or discard this patch.