Completed
Push — master ( 16d4e0...d4025b )
by smiley
02:30
created
src/Storage/TokenStorageAbstract.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param \chillerlan\Traits\ContainerInterface|null $options
35 35
 	 * @param \Psr\Log\LoggerInterface|null              $logger
36 36
 	 */
37
-	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null){
37
+	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null) {
38 38
 		$this->options = $options ?? new OAuthOptions;
39 39
 		$this->logger  = $logger ?? new NullLogger;
40 40
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		unset($token);
51 51
 
52
-		if($this->options->useEncryption === true){
52
+		if ($this->options->useEncryption === true) {
53 53
 			return $this->encrypt($data);
54 54
 		}
55 55
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	public function fromStorage(string $data):Token{
65 65
 
66
-		if($this->options->useEncryption === true){
66
+		if ($this->options->useEncryption === true) {
67 67
 			$data = $this->decrypt($data);
68 68
 		}
69 69
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	protected function encrypt(string &$data):string {
80 80
 
81
-		if(function_exists('sodium_crypto_secretbox')){
81
+		if (function_exists('sodium_crypto_secretbox')) {
82 82
 			$box = sodium_crypto_secretbox($data, $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
83 83
 
84 84
 			sodium_memzero($data);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	protected function decrypt(string $box):string {
99 99
 
100
-		if(function_exists('sodium_crypto_secretbox_open')){
100
+		if (function_exists('sodium_crypto_secretbox_open')) {
101 101
 			return sodium_crypto_secretbox_open(sodium_hex2bin($box), $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
102 102
 		}
103 103
 
Please login to merge, or discard this patch.
src/Providers/OAuthProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param \chillerlan\Traits\ContainerInterface           $options
91 91
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
92 92
 	 */
93
-	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null){
93
+	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null) {
94 94
 		$this->setHTTPClient($http);
95 95
 
96 96
 		$this->storage     = $storage;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 		$this->serviceName = (new ReflectionClass($this))->getShortName();
101 101
 
102
-		if($this instanceof ApiClientInterface){
102
+		if ($this instanceof ApiClientInterface) {
103 103
 			$this->loadEndpoints();
104 104
 		}
105 105
 
Please login to merge, or discard this patch.
src/Providers/OAuth2Provider.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @method array setState(array $params)
27 27
  * @method \chillerlan\OAuth\Providers\OAuth2Interface checkState(string $state = null)
28 28
  */
29
-abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface{
29
+abstract class OAuth2Provider extends OAuthProvider implements OAuth2Interface {
30 30
 
31 31
 	/**
32 32
 	 * @var int
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 * @param \Psr\Log\LoggerInterface|null                   $logger
63 63
 	 * @param array                                           $scopes
64 64
 	 */
65
-	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null){
65
+	public function __construct(HTTPClientInterface $http, TokenStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null, array $scopes = null) {
66 66
 		parent::__construct($http, $storage, $options, $logger);
67 67
 
68
-		if($scopes !== null){
68
+		if ($scopes !== null) {
69 69
 			$this->scopes = $scopes;
70 70
 		}
71 71
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public function getAuthURL(array $params = null):string{
80 80
 		$params = $this->getAuthURLParams($params ?? []);
81 81
 
82
-		if($this instanceof CSRFToken){
82
+		if ($this instanceof CSRFToken) {
83 83
 			$params = $this->setState($params);
84 84
 		}
85 85
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	protected function getAuthURLParams(array $params):array {
95 95
 
96 96
 		// this should not be here
97
-		if(isset($params['client_secret'])){
97
+		if (isset($params['client_secret'])) {
98 98
 			unset($params['client_secret']);
99 99
 		}
100 100
 
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
 	protected function parseTokenResponse(HTTPResponseInterface $response):Token{
117 117
 		$data = $response->json_array;
118 118
 
119
-		if(!is_array($data)){
119
+		if (!is_array($data)) {
120 120
 			throw new ProviderException('unable to parse token response');
121 121
 		}
122 122
 
123
-		foreach(['error_description', 'error'] as $field){
123
+		foreach (['error_description', 'error'] as $field) {
124 124
 
125
-			if(isset($data[$field])){
125
+			if (isset($data[$field])) {
126 126
 				throw new ProviderException('error retrieving access token: "'.$data[$field].'"');
127 127
 			}
128 128
 
129 129
 		}
130 130
 
131
-		if(!isset($data['access_token'])){
131
+		if (!isset($data['access_token'])) {
132 132
 			throw new ProviderException('token missing');
133 133
 		}
134 134
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function getAccessToken(string $code, string $state = null):Token{
156 156
 
157
-		if($this instanceof CSRFToken){
157
+		if ($this instanceof CSRFToken) {
158 158
 			$this->checkState($state);
159 159
 		}
160 160
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 		$token = $this->storage->getAccessToken($this->serviceName);
209 209
 
210 210
 		// attempt to refresh an expired token
211
-		if($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)){
211
+		if ($this->options->tokenAutoRefresh && $this instanceof TokenRefresh && ($token->isExpired() || $token->expires === $token::EOL_UNKNOWN)) {
212 212
 			$token = $this->refreshAccessToken($token);
213 213
 		}
214 214
 
@@ -217,15 +217,15 @@  discard block
 block discarded – undo
217 217
 		$params  = array_merge($query, $params ?? []);
218 218
 		$headers = $headers ?? [];
219 219
 
220
-		if(array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)){
220
+		if (array_key_exists($this->authMethod, $this::AUTH_METHODS_HEADER)) {
221 221
 			$headers = array_merge($headers, [
222 222
 				'Authorization' => $this::AUTH_METHODS_HEADER[$this->authMethod].$token->accessToken,
223 223
 			]);
224 224
 		}
225
-		elseif(array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)){
225
+		elseif (array_key_exists($this->authMethod, $this::AUTH_METHODS_QUERY)) {
226 226
 			$params[$this::AUTH_METHODS_QUERY[$this->authMethod]] = $token->accessToken;
227 227
 		}
228
-		else{
228
+		else {
229 229
 			throw new ProviderException('invalid auth type');
230 230
 		}
231 231
 
Please login to merge, or discard this patch.