Passed
Push — master ( 74736c...41514f )
by smiley
02:15
created
src/Core/OAuth2Interface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface OAuth2Interface extends OAuthInterface{
15
+interface OAuth2Interface extends OAuthInterface {
16 16
 
17 17
 	const HEADER_OAUTH              = 0;
18 18
 	const HEADER_BEARER             = 1;
Please login to merge, or discard this patch.
src/Core/ClientCredentials.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 
13 13
 namespace chillerlan\OAuth\Core;
14 14
 
15
-interface ClientCredentials{
15
+interface ClientCredentials {
16 16
 
17 17
 	/**
18 18
 	 * @param array $scopes
Please login to merge, or discard this patch.
src/Core/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, OAuthStorageInterface $storage, ContainerInterface $options, LoggerInterface $logger = null){
93
+	public function __construct(HTTPClientInterface $http, OAuthStorageInterface $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/Core/OAuth2TokenRefreshTrait.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @property \chillerlan\OAuth\Storage\OAuthStorageInterface $storage
20 20
  * @property \chillerlan\OAuth\OAuthOptions                  $options
21 21
  */
22
-trait OAuth2TokenRefreshTrait{
22
+trait OAuth2TokenRefreshTrait {
23 23
 
24 24
 	/**
25 25
 	 * @param \chillerlan\OAuth\Core\AccessToken $token
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function refreshAccessToken(AccessToken $token = null):AccessToken{
31 31
 
32
-		if($token === null){
32
+		if ($token === null) {
33 33
 			$token = $this->storage->getAccessToken($this->serviceName);
34 34
 		}
35 35
 
36 36
 		$refreshToken = $token->refreshToken;
37 37
 
38
-		if(empty($refreshToken)){
38
+		if (empty($refreshToken)) {
39 39
 
40
-			if(!$this instanceof AccessTokenForRefresh){
40
+			if (!$this instanceof AccessTokenForRefresh) {
41 41
 				throw new ProviderException(sprintf('no refresh token available, token expired [%s]', date('Y-m-d h:i:s A', $token->expires)));
42 42
 			}
43 43
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			)
54 54
 		);
55 55
 
56
-		if(!$newToken->refreshToken){
56
+		if (!$newToken->refreshToken) {
57 57
 			$newToken->refreshToken = $refreshToken;
58 58
 		}
59 59
 
Please login to merge, or discard this patch.
src/Core/AccessToken.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @property int    $expires
32 32
  * @property string $provider
33 33
  */
34
-class AccessToken implements ContainerInterface{
34
+class AccessToken implements ContainerInterface {
35 35
 	use MemzeroDestructorTrait, Container{
36 36
 		__construct as constructContainer;
37 37
 	}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @param array|null $properties
100 100
 	 */
101
-	public function __construct(array $properties = null){
101
+	public function __construct(array $properties = null) {
102 102
 		$this->constructContainer($properties);
103 103
 
104 104
 		$this->setExpiry($this->expires);
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return void
114 114
 	 */
115
-	public function __set(string $property, $value){
115
+	public function __set(string $property, $value) {
116 116
 
117
-		if(property_exists($this, $property)){
117
+		if (property_exists($this, $property)) {
118 118
 			$property === 'expires'
119 119
 				? $this->setExpiry($value)
120 120
 				: $this->{$property} = $value;
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	public function setExpiry(int $expires = null):AccessToken{
131 131
 		$now = time();
132 132
 
133
-		if($expires!== null){
134
-			$expires =  intval($expires);
133
+		if ($expires !== null) {
134
+			$expires = intval($expires);
135 135
 		}
136 136
 
137 137
 		$this->expires = $this::EOL_UNKNOWN;
138 138
 
139
-		if($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES){
139
+		if ($expires === 0 || $expires === $this::EOL_NEVER_EXPIRES) {
140 140
 			$this->expires = $this::EOL_NEVER_EXPIRES;
141 141
 		}
142
-		elseif($expires > $now){
142
+		elseif ($expires > $now) {
143 143
 			$this->expires = $expires;
144 144
 		}
145
-		elseif($expires > 0 && $expires < $this::EXPIRY_MAX){
145
+		elseif ($expires > 0 && $expires < $this::EXPIRY_MAX) {
146 146
 			$this->expires = $now + $expires;
147 147
 		}
148 148
 
Please login to merge, or discard this patch.
src/Storage/OAuthStorageAbstract.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param \chillerlan\Traits\ContainerInterface|null $options
37 37
 	 * @param \Psr\Log\LoggerInterface|null              $logger
38 38
 	 */
39
-	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null){
39
+	public function __construct(ContainerInterface $options = null, LoggerInterface $logger = null) {
40 40
 		$this->options = $options ?? new OAuthOptions;
41 41
 		$this->logger  = $logger ?? new NullLogger;
42 42
 	}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 		unset($token);
53 53
 
54
-		if($this->options->useEncryption === true){
54
+		if ($this->options->useEncryption === true) {
55 55
 			return $this->encrypt($data);
56 56
 		}
57 57
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function fromStorage(string $data):AccessToken{
67 67
 
68
-		if($this->options->useEncryption === true){
68
+		if ($this->options->useEncryption === true) {
69 69
 			$data = $this->decrypt($data);
70 70
 		}
71 71
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	protected function encrypt(string &$data):string {
82 82
 
83
-		if(function_exists('sodium_crypto_secretbox')){
83
+		if (function_exists('sodium_crypto_secretbox')) {
84 84
 			$box = sodium_crypto_secretbox($data, $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
85 85
 
86 86
 			sodium_memzero($data);
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	protected function decrypt(string $box):string {
101 101
 
102
-		if(function_exists('sodium_crypto_secretbox_open')){
102
+		if (function_exists('sodium_crypto_secretbox_open')) {
103 103
 			return sodium_crypto_secretbox_open(sodium_hex2bin($box), $this::TOKEN_NONCE, sodium_hex2bin($this->options->storageCryptoKey));
104 104
 		}
105 105
 
Please login to merge, or discard this patch.
src/Storage/OAuthStorageException.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 OAuthStorageException extends OAuthException{}
17
+class OAuthStorageException extends OAuthException {}
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
 	/**
20 20
 	 * @param string                             $service
Please login to merge, or discard this patch.
src/Storage/DBStorage.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\Core\AccessToken;
17 17
 use chillerlan\Traits\ContainerInterface;
18 18
 
19
-class DBStorage extends OAuthStorageAbstract{
19
+class DBStorage extends OAuthStorageAbstract {
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\OAuthStorageException
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 OAuthStorageException('invalid table config');
39 39
 		}
40 40
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function storeAccessToken(string $service, AccessToken $token):OAuthStorageInterface{
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 OAuthStorageException('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 OAuthStorageException('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 OAuthStorageException('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.