Completed
Push — master ( dae459...74736c )
by smiley
02:06
created
src/Providers/ProviderException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,4 +14,4 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\OAuthException;
16 16
 
17
-class ProviderException extends OAuthException{}
17
+class ProviderException extends OAuthException {}
Please login to merge, or discard this patch.
src/Providers/TokenRefresh.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-interface TokenRefresh{
17
+interface TokenRefresh {
18 18
 
19 19
 	/**
20 20
 	 * @param \chillerlan\OAuth\Token|null $token
Please login to merge, or discard this patch.
src/Providers/ClientCredentials.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-interface ClientCredentials{
17
+interface ClientCredentials {
18 18
 
19 19
 	/**
20 20
 	 * @param array $scopes
Please login to merge, or discard this patch.
src/Providers/TokenExpires.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,6 +12,6 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Providers;
14 14
 
15
-interface TokenExpires{
15
+interface TokenExpires {
16 16
 
17 17
 }
Please login to merge, or discard this patch.
src/Providers/OAuth1Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-interface OAuth1Interface extends OAuthInterface{
17
+interface OAuth1Interface extends OAuthInterface {
18 18
 
19 19
 	/**
20 20
 	 * @return \chillerlan\OAuth\Token
Please login to merge, or discard this patch.
src/Providers/OAuth2Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 use chillerlan\OAuth\Token;
16 16
 
17
-interface OAuth2Interface extends OAuthInterface{
17
+interface OAuth2Interface extends OAuthInterface {
18 18
 
19 19
 	const HEADER_OAUTH              = 0;
20 20
 	const HEADER_BEARER             = 1;
Please login to merge, or discard this patch.
src/Providers/OAuth1Provider.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,11 +74,9 @@
 block discarded – undo
74 74
 
75 75
 		if(!$data || !is_array($data)){
76 76
 			throw new ProviderException('unable to parse token response');
77
-		}
78
-		elseif(isset($data['error'])){
77
+		} elseif(isset($data['error'])){
79 78
 			throw new ProviderException('error retrieving access token: '.$data['error']);
80
-		}
81
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
79
+		} elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
82 80
 			throw new ProviderException('token missing');
83 81
 		}
84 82
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\HTTP\HTTPResponseInterface;
17 17
 use DateTime;
18 18
 
19
-abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface{
19
+abstract class OAuth1Provider extends OAuthProvider implements OAuth1Interface {
20 20
 
21 21
 	/**
22 22
 	 * @var string
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @return \chillerlan\OAuth\Token
48 48
 	 */
49 49
 	public function getRequestToken():Token {
50
-		$params   = $this->getRequestTokenHeaderParams();
50
+		$params = $this->getRequestTokenHeaderParams();
51 51
 
52 52
 		return $this->parseTokenResponse(
53 53
 			$this->httpPOST(
@@ -72,19 +72,19 @@  discard block
 block discarded – undo
72 72
 	protected function parseTokenResponse(HTTPResponseInterface $response, bool $checkCallbackConfirmed = null):Token {
73 73
 		parse_str($response->body, $data);
74 74
 
75
-		if(!$data || !is_array($data)){
75
+		if (!$data || !is_array($data)) {
76 76
 			throw new ProviderException('unable to parse token response');
77 77
 		}
78
-		elseif(isset($data['error'])){
78
+		elseif (isset($data['error'])) {
79 79
 			throw new ProviderException('error retrieving access token: '.$data['error']);
80 80
 		}
81
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
81
+		elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) {
82 82
 			throw new ProviderException('token missing');
83 83
 		}
84 84
 
85
-		if(($checkCallbackConfirmed ?? false)
85
+		if (($checkCallbackConfirmed ?? false)
86 86
 		   && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')
87
-		){
87
+		) {
88 88
 			throw new ProviderException('oauth callback unconfirmed');
89 89
 		}
90 90
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	public function getSignature(string $url, array $params, string $method = null):string {
148 148
 		$parseURL = parse_url($url);
149 149
 
150
-		if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){
150
+		if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) {
151 151
 			throw new ProviderException('getSignature: invalid url');
152 152
 		}
153 153
 
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return string
173 173
 	 */
174
-	protected function getSignatureData(string $signatureURL, array $signatureParams, string $method){
174
+	protected function getSignatureData(string $signatureURL, array $signatureParams, string $method) {
175 175
 
176
-		if(isset($signatureParams['oauth_signature'])){
176
+		if (isset($signatureParams['oauth_signature'])) {
177 177
 			unset($signatureParams['oauth_signature']);
178 178
 		}
179 179
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	public function getAccessToken(string $token, string $verifier, string $tokenSecret = null):Token {
197 197
 		$this->tokenSecret = $tokenSecret;
198 198
 
199
-		if(empty($this->tokenSecret)){
199
+		if (empty($this->tokenSecret)) {
200 200
 			$this->tokenSecret = $this->storage->getAccessToken($this->serviceName)->requestTokenSecret;
201 201
 		}
202 202
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 		$parameters['oauth_signature'] = $this->getSignature($url, array_merge($params ?? [], $parameters), $method);
234 234
 
235
-		if(isset($params['oauth_session_handle'])){
235
+		if (isset($params['oauth_session_handle'])) {
236 236
 			$parameters['oauth_session_handle'] = $params['oauth_session_handle'];
237 237
 			unset($params['oauth_session_handle']);
238 238
 		}
Please login to merge, or discard this patch.
examples/OAuth1Testprovider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 /**
18 18
  *
19 19
  */
20
-class OAuth1Testprovider extends OAuth1Provider{
20
+class OAuth1Testprovider extends OAuth1Provider {
21 21
 
22 22
 	protected $apiURL          = 'https://api.example.com';
23 23
 	protected $requestTokenURL = 'https://example.com/oauth/request_token';
Please login to merge, or discard this patch.
src/Storage/DBTokenStorage.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 use chillerlan\OAuth\Token;
17 17
 use chillerlan\Traits\ContainerInterface;
18 18
 
19
-class DBTokenStorage extends TokenStorageAbstract{
19
+class DBTokenStorage extends TokenStorageAbstract {
20 20
 
21 21
 	/**
22 22
 	 * @var \chillerlan\Database\Database
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @throws \chillerlan\OAuth\Storage\TokenStorageException
33 33
 	 */
34
-	public function __construct(ContainerInterface $options, Database $db){
34
+	public function __construct(ContainerInterface $options, Database $db) {
35 35
 		parent::__construct($options);
36 36
 
37
-		if(!$this->options->dbTokenTable || !$this->options->dbProviderTable){
37
+		if (!$this->options->dbTokenTable || !$this->options->dbProviderTable) {
38 38
 			throw new TokenStorageException('invalid table config');
39 39
 		}
40 40
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function storeAccessToken(string $service, Token $token):TokenStorageInterface{
63 63
 		$providers = $this->getProviders();
64 64
 
65
-		if(empty($providers) || !isset($providers[$service])){
65
+		if (empty($providers) || !isset($providers[$service])) {
66 66
 			throw new TokenStorageException('unknown service');
67 67
 		}
68 68
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			$this->options->dbTokenTableExpires    => $token->expires,
74 74
 		];
75 75
 
76
-		if($this->hasAccessToken($service) === true){
76
+		if ($this->hasAccessToken($service) === true) {
77 77
 			$this->db->update
78 78
 				->table($this->options->dbTokenTable)
79 79
 				->set($values)
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
108 108
 			->query();
109 109
 
110
-		if(is_bool($r) || $r->length < 1){
110
+		if (is_bool($r) || $r->length < 1) {
111 111
 			throw new TokenStorageException('token not found');
112 112
 		}
113 113
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
188 188
 			->query();
189 189
 
190
-		if(is_bool($r) || $r->length < 1){
190
+		if (is_bool($r) || $r->length < 1) {
191 191
 			throw new TokenStorageException('state not found');
192 192
 		}
193 193
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			->where($this->options->dbTokenTableLabel, $this->getLabel($service))
208 208
 			->query();
209 209
 
210
-		if(is_bool($r) || $r->length < 1 || empty(trim($r[0]->state))){
210
+		if (is_bool($r) || $r->length < 1 || empty(trim($r[0]->state))) {
211 211
 			return false;
212 212
 		}
213 213
 
Please login to merge, or discard this patch.