Completed
Push — master ( 9c41d8...ca3d4a )
by smiley
01:57
created
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.
bin/dbstorage_create.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 require_once __DIR__.'/../vendor/autoload.php';
20 20
 
21
-$CFGDIR         = __DIR__.'/../config';
21
+$CFGDIR = __DIR__.'/../config';
22 22
 const TABLE_TOKEN    = 'storagetest';
23 23
 const TABLE_PROVIDER = 'storagetest_providers';
24 24
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	->table(TABLE_TOKEN)
72 72
 	->primaryKey('label')
73 73
 	->varchar('label', 32, null, false)
74
-	->int('user_id',10, null, false)
74
+	->int('user_id', 10, null, false)
75 75
 	->varchar('provider_id', 30, '', false)
76 76
 	->text('token', null, true)
77 77
 	->text('state')
78
-	->int('expires',10, null, false)
78
+	->int('expires', 10, null, false)
79 79
 	->query();
80 80
 
81 81
 $db->raw('DROP TABLE IF EXISTS '.TABLE_PROVIDER);
82 82
 $db->create
83 83
 	->table(TABLE_PROVIDER)
84 84
 	->primaryKey('provider_id')
85
-	->tinyint('provider_id',10, null, false, 'UNSIGNED AUTO_INCREMENT')
85
+	->tinyint('provider_id', 10, null, false, 'UNSIGNED AUTO_INCREMENT')
86 86
 	->varchar('servicename', 30, '', false)
87 87
 	->query();
88 88
 
89
-foreach($providers as $i => $provider){
89
+foreach ($providers as $i => $provider) {
90 90
 	$db->insert
91 91
 		->into(TABLE_PROVIDER)
92 92
 		->values(['provider_id' => $i, 'servicename' => $provider])
Please login to merge, or discard this patch.