@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | Mastodon::SCOPE_FOLLOW, |
39 | 39 | ]; |
40 | 40 | |
41 | - protected string $instance = ''; |
|
41 | + protected string $instance = ''; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * set the internal URLs for the given Mastodon instance |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function setInstance(string $instance):Mastodon{ |
49 | 49 | $instance = QueryUtil::parseUrl($instance); |
50 | 50 | |
51 | - if(!isset($instance['host'])){ |
|
51 | + if (!isset($instance['host'])) { |
|
52 | 52 | throw new OAuthException('invalid instance URL'); |
53 | 53 | } |
54 | 54 | |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | $response = $this->request('/v1/accounts/verify_credentials'); |
100 | 100 | $status = $response->getStatusCode(); |
101 | 101 | |
102 | - if($status === 200){ |
|
102 | + if ($status === 200) { |
|
103 | 103 | return $response; |
104 | 104 | } |
105 | 105 | |
106 | 106 | $json = MessageUtil::decodeJSON($response); |
107 | 107 | |
108 | - if(isset($json->error)){ |
|
108 | + if (isset($json->error)) { |
|
109 | 109 | throw new ProviderException($json->error); |
110 | 110 | } |
111 | 111 |
@@ -82,13 +82,13 @@ |
||
82 | 82 | $response = $this->request('/v1/me'); |
83 | 83 | $status = $response->getStatusCode(); |
84 | 84 | |
85 | - if($status === 200){ |
|
85 | + if ($status === 200) { |
|
86 | 86 | return $response; |
87 | 87 | } |
88 | 88 | |
89 | 89 | $json = MessageUtil::decodeJSON($response); |
90 | 90 | |
91 | - if(isset($json->error, $json->error->message)){ |
|
91 | + if (isset($json->error, $json->error->message)) { |
|
92 | 92 | throw new ProviderException($json->error->message); |
93 | 93 | } |
94 | 94 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @see https://www.discogs.com/developers/ |
21 | 21 | * @see https://www.discogs.com/developers/#page:authentication,header:authentication-oauth-flow |
22 | 22 | */ |
23 | -class Discogs extends OAuth1Provider{ |
|
23 | +class Discogs extends OAuth1Provider { |
|
24 | 24 | |
25 | 25 | protected string $requestTokenURL = 'https://api.discogs.com/oauth/request_token'; |
26 | 26 | protected string $authURL = 'https://www.discogs.com/oauth/authorize'; |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | $response = $this->request('/oauth/identity'); |
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->message)){ |
|
48 | + if (isset($json->message)) { |
|
49 | 49 | throw new ProviderException($json->message); |
50 | 50 | } |
51 | 51 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @see https://developers.bigcartel.com/api/v1 |
22 | 22 | * @see https://bigcartel.wufoo.com/confirm/big-cartel-api-application/ |
23 | 23 | */ |
24 | -class BigCartel extends OAuth2Provider implements CSRFToken{ |
|
24 | +class BigCartel extends OAuth2Provider implements CSRFToken { |
|
25 | 25 | |
26 | 26 | protected string $authURL = 'https://my.bigcartel.com/oauth/authorize'; |
27 | 27 | protected string $accessTokenURL = 'https://api.bigcartel.com/oauth/token'; |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | $response = $this->request('/accounts'); |
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->error)){ |
|
48 | + if (isset($json->error)) { |
|
49 | 49 | throw new ProviderException($json->error); |
50 | 50 | } |
51 | 51 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @see https://www.mixcloud.com/developers/ |
23 | 23 | */ |
24 | -class Mixcloud extends OAuth2Provider{ |
|
24 | +class Mixcloud extends OAuth2Provider { |
|
25 | 25 | |
26 | 26 | protected string $authURL = 'https://www.mixcloud.com/oauth/authorize'; |
27 | 27 | protected string $accessTokenURL = 'https://www.mixcloud.com/oauth/access_token'; |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | $response = $this->request('/me/'); |
39 | 39 | $status = $response->getStatusCode(); |
40 | 40 | |
41 | - if($status === 200){ |
|
41 | + if ($status === 200) { |
|
42 | 42 | return $response; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $json = MessageUtil::decodeJSON($response); |
46 | 46 | |
47 | - if(isset($json->error, $json->error->message)){ |
|
47 | + if (isset($json->error, $json->error->message)) { |
|
48 | 48 | throw new ProviderException($json->error->message); |
49 | 49 | } |
50 | 50 |
@@ -51,13 +51,13 @@ |
||
51 | 51 | $response = $this->request('/user/whoami'); |
52 | 52 | $status = $response->getStatusCode(); |
53 | 53 | |
54 | - if($status === 200){ |
|
54 | + if ($status === 200) { |
|
55 | 55 | return $response; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $json = MessageUtil::decodeJSON($response); |
59 | 59 | |
60 | - if(isset($json->error, $json->error_description)){ |
|
60 | + if (isset($json->error, $json->error_description)) { |
|
61 | 61 | throw new ProviderException($json->error_description); |
62 | 62 | } |
63 | 63 |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | protected function getRequestTarget(string $uri):string{ |
47 | 47 | $parsedURL = QueryUtil::parseUrl($uri); |
48 | 48 | |
49 | - if(!isset($parsedURL['path'])){ |
|
49 | + if (!isset($parsedURL['path'])) { |
|
50 | 50 | throw new ProviderException('invalid path'); // @codeCoverageIgnore |
51 | 51 | } |
52 | 52 | |
53 | 53 | // for some reason we were given a host name |
54 | - if(isset($parsedURL['host'])){ |
|
54 | + if (isset($parsedURL['host'])) { |
|
55 | 55 | |
56 | 56 | // back out if it doesn't match |
57 | - if(!str_contains($parsedURL['host'], '.api.npr.org')){ |
|
57 | + if (!str_contains($parsedURL['host'], '.api.npr.org')) { |
|
58 | 58 | throw new ProviderException('given host does not match provider host'); // @codeCoverageIgnore |
59 | 59 | } |
60 | 60 | |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | public function sendRequest(RequestInterface $request):ResponseInterface{ |
73 | 73 | |
74 | 74 | // get authorization only if we request the provider API |
75 | - if(str_contains((string)$request->getUri(), '.api.npr.org')){ |
|
75 | + if (str_contains((string)$request->getUri(), '.api.npr.org')) { |
|
76 | 76 | $token = $this->storage->getAccessToken($this->serviceName); |
77 | 77 | |
78 | 78 | // attempt to refresh an expired token |
79 | - if( |
|
79 | + if ( |
|
80 | 80 | $this->options->tokenAutoRefresh |
81 | 81 | && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN) |
82 | - ){ |
|
82 | + ) { |
|
83 | 83 | $token = $this->refreshAccessToken($token); // @codeCoverageIgnore |
84 | 84 | } |
85 | 85 | |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | $response = $this->request('https://identity.api.npr.org/v2/user'); |
97 | 97 | $status = $response->getStatusCode(); |
98 | 98 | |
99 | - if($status === 200){ |
|
99 | + if ($status === 200) { |
|
100 | 100 | return $response; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $json = MessageUtil::decodeJSON($response); |
104 | 104 | |
105 | - if(isset($json->errors)){ |
|
105 | + if (isset($json->errors)) { |
|
106 | 106 | throw new ProviderException($json->errors[0]->text); |
107 | 107 | } |
108 | 108 |
@@ -54,13 +54,13 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -19,7 +19,7 @@ discard block |
||
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 |
||
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 |