Passed
Push — master ( 9cb0d3...47e940 )
by smiley
01:29
created
examples/OAuth1Testprovider.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\Core\OAuth1Provider;
16 16
 
17
-class OAuth1Testprovider extends OAuth1Provider{
17
+class OAuth1Testprovider extends OAuth1Provider {
18 18
 
19 19
 	protected $apiURL          = 'https://api.example.com';
20 20
 	protected $requestTokenURL = 'https://example.com/oauth/request_token';
Please login to merge, or discard this patch.
examples/TestEndpoints.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\HTTP\MagicAPI\EndpointMap;
16 16
 
17
-class TestEndpoints extends EndpointMap{
17
+class TestEndpoints extends EndpointMap {
18 18
 
19 19
 	protected $test = [
20 20
 		'path'          => '/test/%1$s',
Please login to merge, or discard this patch.
examples/OAuth2Testprovider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 	protected $authURL        = 'https://example.com/oauth2/authorize';
25 25
 	protected $accessTokenURL = 'https://example.com/oauth2/token';
26 26
 	protected $userRevokeURL  = 'https://account.example.com/apps/';
27
-	protected $endpointMap     = TestEndpoints::class;
27
+	protected $endpointMap = TestEndpoints::class;
28 28
 	protected $authHeaders    = ['foo' => 'bar'];
29 29
 	protected $apiHeaders     = ['foo' => 'bar'];
30 30
 
Please login to merge, or discard this patch.
src/Core/OAuth1Provider.php 2 patches
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 DateTime;
17 17
 use Psr\Http\Message\{RequestInterface, ResponseInterface, UriInterface};
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
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 			->withHeader('Authorization', 'OAuth '.Psr7\build_http_query($params, true, ', ', '"'));
60 60
 		;
61 61
 
62
-		foreach($this->authHeaders as $header => $value){
62
+		foreach ($this->authHeaders as $header => $value) {
63 63
 			$request = $request->withAddedHeader($header, $value);
64 64
 		}
65 65
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
 	protected function parseTokenResponse(ResponseInterface $response, bool $checkCallbackConfirmed = null):AccessToken{
77 77
 		parse_str($response->getBody()->getContents(), $data);
78 78
 
79
-		if(!$data || !is_array($data)){
79
+		if (!$data || !is_array($data)) {
80 80
 			throw new ProviderException('unable to parse token response');
81 81
 		}
82
-		elseif(isset($data['error'])){
82
+		elseif (isset($data['error'])) {
83 83
 			throw new ProviderException('error retrieving access token: '.$data['error']);
84 84
 		}
85
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
85
+		elseif (!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])) {
86 86
 			throw new ProviderException('invalid token');
87 87
 		}
88 88
 
89
-		if($checkCallbackConfirmed && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')){
89
+		if ($checkCallbackConfirmed && (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] !== 'true')) {
90 90
 			throw new ProviderException('oauth callback unconfirmed');
91 91
 		}
92 92
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{
132 132
 		$parseURL = parse_url($url);
133 133
 
134
-		if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){
134
+		if (!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)) {
135 135
 			throw new ProviderException('getSignature: invalid url');
136 136
 		}
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 		$signatureParams = array_merge($query, $params);
141 141
 
142
-		if(isset($signatureParams['oauth_signature'])){
142
+		if (isset($signatureParams['oauth_signature'])) {
143 143
 			unset($signatureParams['oauth_signature']);
144 144
 		}
145 145
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -78,11 +78,9 @@
 block discarded – undo
78 78
 
79 79
 		if(!$data || !is_array($data)){
80 80
 			throw new ProviderException('unable to parse token response');
81
-		}
82
-		elseif(isset($data['error'])){
81
+		} elseif(isset($data['error'])){
83 82
 			throw new ProviderException('error retrieving access token: '.$data['error']);
84
-		}
85
-		elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
83
+		} elseif(!isset($data['oauth_token']) || !isset($data['oauth_token_secret'])){
86 84
 			throw new ProviderException('invalid token');
87 85
 		}
88 86
 
Please login to merge, or discard this patch.
src/Core/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 Psr\Http\Message\UriInterface;
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/Core/OAuth2Provider.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @method array setState(array $params)
21 21
  * @method \chillerlan\OAuth\Core\OAuth2Interface checkState(string $state = null)
22 22
  */
23
-abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{
23
+abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface {
24 24
 
25 25
 	/**
26 26
 	 * @var int
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	public function getAuthURL(array $params = null, array $scopes = null):UriInterface{
57 57
 		$params = $params ?? [];
58 58
 
59
-		if(isset($params['client_secret'])){
59
+		if (isset($params['client_secret'])) {
60 60
 			unset($params['client_secret']);
61 61
 		}
62 62
 
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 			'type'          => 'web_server',
68 68
 		]);
69 69
 
70
-		if($scopes !== null){
70
+		if ($scopes !== null) {
71 71
 			$params['scope'] = implode($this->scopesDelimiter, $scopes);
72 72
 		}
73 73
 
74
-		if($this instanceof CSRFToken){
74
+		if ($this instanceof CSRFToken) {
75 75
 			$params = $this->setState($params);
76 76
 		}
77 77
 
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 	protected function parseTokenResponse(ResponseInterface $response):AccessToken{
88 88
 		$data = Psr7\get_json($response, true);
89 89
 
90
-		if(!is_array($data)){
90
+		if (!is_array($data)) {
91 91
 			throw new ProviderException('unable to parse token response');
92 92
 		}
93 93
 
94
-		foreach(['error_description', 'error'] as $field){
94
+		foreach (['error_description', 'error'] as $field) {
95 95
 
96
-			if(isset($data[$field])){
96
+			if (isset($data[$field])) {
97 97
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
98 98
 			}
99 99
 
100 100
 		}
101 101
 
102
-		if(!isset($data['access_token'])){
102
+		if (!isset($data['access_token'])) {
103 103
 			throw new ProviderException('token missing');
104 104
 		}
105 105
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function getAccessToken(string $code, string $state = null):AccessToken{
127 127
 
128
-		if($this instanceof CSRFToken){
128
+		if ($this instanceof CSRFToken) {
129 129
 			$this->checkState($state);
130 130
 		}
131 131
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 			->withHeader('Content-Type', 'application/x-www-form-urlencoded')
143 143
 			->withBody($this->streamFactory->createStream(http_build_query($body, '', '&', PHP_QUERY_RFC1738)));
144 144
 
145
-		foreach($this->authHeaders as $header => $value){
145
+		foreach ($this->authHeaders as $header => $value) {
146 146
 			$request = $request->withHeader($header, $value);
147 147
 		}
148 148
 
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public function getRequestAuthorization(RequestInterface $request, AccessToken $token):RequestInterface{
164 164
 
165
-		if(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_HEADER)){
165
+		if (array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_HEADER)) {
166 166
 			$request = $request->withHeader('Authorization', $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken);
167 167
 		}
168
-		elseif(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)){
168
+		elseif (array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)) {
169 169
 			$uri = Psr7\merge_query((string)$request->getUri(), [$this::AUTH_METHODS_QUERY[$this->authMethod] => $token->accessToken]);
170 170
 
171 171
 			$request = $request->withUri($this->uriFactory->createUri($uri));
172 172
 		}
173
-		else{
173
+		else {
174 174
 			throw new ProviderException('invalid auth type');
175 175
 		}
176 176
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,13 +164,11 @@
 block discarded – undo
164 164
 
165 165
 		if(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_HEADER)){
166 166
 			$request = $request->withHeader('Authorization', $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken);
167
-		}
168
-		elseif(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)){
167
+		} elseif(array_key_exists($this->authMethod, OAuth2Interface::AUTH_METHODS_QUERY)){
169 168
 			$uri = Psr7\merge_query((string)$request->getUri(), [$this::AUTH_METHODS_QUERY[$this->authMethod] => $token->accessToken]);
170 169
 
171 170
 			$request = $request->withUri($this->uriFactory->createUri($uri));
172
-		}
173
-		else{
171
+		} else{
174 172
 			throw new ProviderException('invalid auth type');
175 173
 		}
176 174
 
Please login to merge, or discard this patch.
src/Storage/OAuthStorageInterface.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\Core\AccessToken;
16 16
 
17
-interface OAuthStorageInterface{
17
+interface OAuthStorageInterface {
18 18
 
19 19
 	const TOKEN_NONCE = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01";
20 20
 
Please login to merge, or discard this patch.
src/OAuthOptions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,6 +36,6 @@
 block discarded – undo
36 36
  * @property bool       $ssl_verifypeer
37 37
  * @property string     $curlHandle
38 38
  */
39
-class OAuthOptions extends SettingsContainerAbstract{
39
+class OAuthOptions extends SettingsContainerAbstract {
40 40
 	use OAuthOptionsTrait, HTTPOptionsTrait;
41 41
 }
Please login to merge, or discard this patch.