Passed
Push — master ( f23b67...61a6ec )
by smiley
01:37
created
src/functions.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,22 +14,22 @@
 block discarded – undo
14 14
 
15 15
 use function function_exists, hash, realpath, str_replace, strlen, substr;
16 16
 
17
-if(!function_exists(__NAMESPACE__.'\\getProviders')){
17
+if (!function_exists(__NAMESPACE__.'\\getProviders')) {
18 18
 
19 19
 	function getProviders():array{
20 20
 		$providers = [];
21 21
 
22 22
 		/** @var \SplFileInfo $e */
23
-		foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)) as $e){
23
+		foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS)) as $e) {
24 24
 
25
-			if($e->getExtension() !== 'php' || realpath($e->getPath()) === __DIR__){
25
+			if ($e->getExtension() !== 'php' || realpath($e->getPath()) === __DIR__) {
26 26
 				continue;
27 27
 			}
28 28
 
29 29
 			$class = __NAMESPACE__.str_replace('/', '\\', substr($e->getPathname(), strlen(__DIR__), -4));
30 30
 			$r     = new ReflectionClass($class);
31 31
 
32
-			if(!$r->implementsInterface(OAuthInterface::class) || $r->isAbstract()){
32
+			if (!$r->implementsInterface(OAuthInterface::class) || $r->isAbstract()) {
33 33
 				continue;
34 34
 			}
35 35
 
Please login to merge, or discard this patch.
src/Deezer/Deezer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	public function getAuthURL(array $params = null, array $scopes = null):UriInterface{
54 54
 		$params = $params ?? [];
55 55
 
56
-		if(isset($params['client_secret'])){
56
+		if (isset($params['client_secret'])) {
57 57
 			unset($params['client_secret']);
58 58
 		}
59 59
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	protected function parseTokenResponse(ResponseInterface $response):AccessToken{
102 102
 		parse_str(decompress_content($response), $data);
103 103
 
104
-		if(!is_array($data) || empty($data)){
104
+		if (!is_array($data) || empty($data)) {
105 105
 			throw new ProviderException('unable to parse token response');
106 106
 		}
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
 
Please login to merge, or discard this patch.
src/PayPal/PayPal.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
 	protected function parseTokenResponse(ResponseInterface $response):AccessToken{
50 50
 		$data = json_decode(decompress_content($response), true);
51 51
 
52
-		if(!is_array($data)){
52
+		if (!is_array($data)) {
53 53
 			throw new ProviderException('unable to parse token response');
54 54
 		}
55 55
 
56
-		foreach(['error_description', 'error'] as $field){
57
-			if(isset($data[$field])){
56
+		foreach (['error_description', 'error'] as $field) {
57
+			if (isset($data[$field])) {
58 58
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
59 59
 			}
60 60
 		}
61 61
 
62 62
 		// @codeCoverageIgnoreStart
63
-		if(isset($data['name'], $data['message'])){
63
+		if (isset($data['name'], $data['message'])) {
64 64
 			$msg = \sprintf('error retrieving access token: "%s" [%s]', $data['message'], $data['name']);
65 65
 
66
-			if(isset($data['links']) && is_array($data['links'])){
66
+			if (isset($data['links']) && is_array($data['links'])) {
67 67
 				$msg .= "\n".implode("\n", array_column($data['links'], 'href'));
68 68
 			}
69 69
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		}
72 72
 		// @codeCoverageIgnoreEnd
73 73
 
74
-		if(!isset($data['access_token'])){
74
+		if (!isset($data['access_token'])) {
75 75
 			throw new ProviderException('token missing');
76 76
 		}
77 77
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function getAccessToken(string $code, string $state = null):AccessToken{
99 99
 
100
-		if($this instanceof CSRFToken){
100
+		if ($this instanceof CSRFToken) {
101 101
 			$this->checkState($state);
102 102
 		}
103 103
 
Please login to merge, or discard this patch.
src/GuildWars2/GuildWars2.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
  * @method \Psr\Http\Message\ResponseInterface wvwUpgrades(array $params = ['lang'])
233 233
  * @method \Psr\Http\Message\ResponseInterface wvwUpgradesId(string $id, array $params = ['lang'])
234 234
  */
235
-class GuildWars2 extends OAuth2Provider{
235
+class GuildWars2 extends OAuth2Provider {
236 236
 
237 237
 	public const SCOPE_ACCOUNT     = 'account';
238 238
 	public const SCOPE_INVENTORIES = 'inventories';
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public function storeGW2Token(string $access_token):AccessToken{
264 264
 
265
-		if(!preg_match('/^[a-f\d\-]{72}$/i', $access_token)){
265
+		if (!preg_match('/^[a-f\d\-]{72}$/i', $access_token)) {
266 266
 			throw new ProviderException('invalid token');
267 267
 		}
268 268
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
 		$tokeninfo = get_json($this->http->sendRequest($request));
274 274
 
275
-		if(isset($tokeninfo->id) && \strpos($access_token, $tokeninfo->id) === 0){
275
+		if (isset($tokeninfo->id) && \strpos($access_token, $tokeninfo->id) === 0) {
276 276
 
277 277
 			$token = new AccessToken([
278 278
 				'provider'     => $this->serviceName,
Please login to merge, or discard this patch.
src/BattleNet/BattleNet.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param \chillerlan\Settings\SettingsContainerInterface $options
46 46
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
47 47
 	 */
48
-	public function __construct(ClientInterface $http, OAuthStorageInterface $storage, SettingsContainerInterface $options, LoggerInterface $logger = null){
48
+	public function __construct(ClientInterface $http, OAuthStorageInterface $storage, SettingsContainerInterface $options, LoggerInterface $logger = null) {
49 49
 		parent::__construct($http, $storage, $options, $logger);
50 50
 
51 51
 		$this->setRegion('eu');
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	public function setRegion(string $region):BattleNet{
61 61
 		$region = strtolower($region);
62 62
 
63
-		if(!in_array($region, ['apac', 'cn', 'eu', 'us'], true)){
63
+		if (!in_array($region, ['apac', 'cn', 'eu', 'us'], true)) {
64 64
 			throw new ProviderException('invalid region: '.$region);
65 65
 		}
66 66
 
Please login to merge, or discard this patch.
src/LastFM/LastFM.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use chillerlan\OAuth\Core\{AccessToken, OAuthProvider, ProviderException};
18 18
 use Psr\Http\Message\{RequestInterface, ResponseInterface, UriInterface};
19 19
 
20
-use function array_merge, http_build_query, in_array, is_array,ksort, md5;
20
+use function array_merge, http_build_query, in_array, is_array, ksort, md5;
21 21
 use function chillerlan\HTTP\Psr7\{get_json, merge_query};
22 22
 
23 23
 use const PHP_QUERY_RFC1738;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
  * @method \Psr\Http\Message\ResponseInterface userGetWeeklyArtistChart(array $params = ['user', 'from', 'to'])
77 77
  * @method \Psr\Http\Message\ResponseInterface userGetWeeklyTrackChart(array $params = ['user', 'from', 'to'])
78 78
  */
79
-class LastFM extends OAuthProvider{
79
+class LastFM extends OAuthProvider {
80 80
 
81 81
 	public const PERIOD_OVERALL = 'overall';
82 82
 	public const PERIOD_7DAY    = '7day';
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$signature = '';
125 125
 
126
-		foreach($params as $k => $v){
127
-			if(!in_array($k, ['format', 'callback'])){
126
+		foreach ($params as $k => $v) {
127
+			if (!in_array($k, ['format', 'callback'])) {
128 128
 				$signature .= $k.$v;
129 129
 			}
130 130
 		}
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
 	protected function parseTokenResponse(ResponseInterface $response):AccessToken{
163 163
 		$data = get_json($response, true);
164 164
 
165
-		if(!$data || !is_array($data)){
165
+		if (!$data || !is_array($data)) {
166 166
 			throw new ProviderException('unable to parse token response');
167 167
 		}
168
-		elseif(isset($data['error'])){
168
+		elseif (isset($data['error'])) {
169 169
 			throw new ProviderException('error retrieving access token: '.$data['message']);
170 170
 		}
171
-		elseif(!isset($data['session']['key'])){
171
+		elseif (!isset($data['session']['key'])) {
172 172
 			throw new ProviderException('token missing');
173 173
 		}
174 174
 
@@ -221,18 +221,18 @@  discard block
 block discarded – undo
221 221
 		$method = $method ?? 'GET';
222 222
 		$params = $this->requestParams($path, $params ?? [], $body ?? []);
223 223
 
224
-		if($method === 'POST'){
224
+		if ($method === 'POST') {
225 225
 			$body   = $params;
226 226
 			$params = [];
227 227
 		}
228 228
 
229 229
 		$request = $this->requestFactory->createRequest($method, merge_query($this->apiURL, $params));
230 230
 
231
-		foreach(array_merge($this->apiHeaders, $headers ?? []) as $header => $value){
231
+		foreach (array_merge($this->apiHeaders, $headers ?? []) as $header => $value) {
232 232
 			$request = $request->withAddedHeader($header, $value);
233 233
 		}
234 234
 
235
-		if($method === 'POST'){
235
+		if ($method === 'POST') {
236 236
 			$request = $request->withHeader('Content-Type', 'application/x-www-form-urlencoded');
237 237
 			$body    = $this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738));
238 238
 			$request = $request->withBody($body);
Please login to merge, or discard this patch.
src/NPR/NPROne.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,11 +60,11 @@
 block discarded – undo
60 60
 	public function sendRequest(RequestInterface $request):ResponseInterface{
61 61
 
62 62
 		// get authorization only if we request the provider API
63
-		if(strpos((string)$request->getUri(), '.api.npr.org/') !== false){ // silly resource subdomains >.<
63
+		if (strpos((string)$request->getUri(), '.api.npr.org/') !== false) { // silly resource subdomains >.<
64 64
 			$token = $this->storage->getAccessToken($this->serviceName);
65 65
 
66 66
 			// attempt to refresh an expired token
67
-			if($this->options->tokenAutoRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)){
67
+			if ($this->options->tokenAutoRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)) {
68 68
 				$token = $this->refreshAccessToken($token); // @codeCoverageIgnore
69 69
 			}
70 70
 
Please login to merge, or discard this patch.
src/MusicBrainz/MusicBrainz.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
88 88
 
89
-		if($token === null){
89
+		if ($token === null) {
90 90
 			$token = $this->storage->getAccessToken($this->serviceName);
91 91
 		}
92 92
 
93 93
 		$refreshToken = $token->refreshToken;
94 94
 
95
-		if(empty($refreshToken)){
95
+		if (empty($refreshToken)) {
96 96
 			throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
97 97
 		}
98 98
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$newToken = $this->parseTokenResponse($this->http->sendRequest($request));
114 114
 
115
-		if(empty($newToken->refreshToken)){
115
+		if (empty($newToken->refreshToken)) {
116 116
 			$newToken->refreshToken = $refreshToken;
117 117
 		}
118 118
 
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 		$method = strtoupper($method);
136 136
 		$token  = $this->storage->getAccessToken($this->serviceName);
137 137
 
138
-		if($token->isExpired()){
138
+		if ($token->isExpired()) {
139 139
 			$token = $this->refreshAccessToken($token);
140 140
 		}
141 141
 
142
-		if(!isset($params['fmt'])){
142
+		if (!isset($params['fmt'])) {
143 143
 			$params['fmt'] = 'json';
144 144
 		}
145 145
 
146
-		if(in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])){
146
+		if (in_array($method, ['POST', 'PUT', 'DELETE']) && !isset($params['client'])) {
147 147
 			$params['client'] = $this->options->user_agent; // @codeCoverageIgnore
148 148
 		}
149 149
 
Please login to merge, or discard this patch.