@@ -93,8 +93,8 @@ |
||
93 | 93 | public function getDefaultScopes(): array |
94 | 94 | { |
95 | 95 | $result = $this->query() |
96 | - ->where('is_default')->is(1) |
|
97 | - ->all(); |
|
96 | + ->where('is_default')->is(1) |
|
97 | + ->all(); |
|
98 | 98 | $scopes = []; |
99 | 99 | foreach ($result as $row) { |
100 | 100 | $scopes[] = Scope::createNewScope( |
@@ -58,14 +58,12 @@ discard block |
||
58 | 58 | * @package Platine\Framework\OAuth2\Repository |
59 | 59 | * @extends Repository<OauthScope> |
60 | 60 | */ |
61 | -class ScopeRepository extends Repository implements ScopeRepositoryInterface |
|
62 | -{ |
|
61 | +class ScopeRepository extends Repository implements ScopeRepositoryInterface { |
|
63 | 62 | /** |
64 | 63 | * Create new instance |
65 | 64 | * @param EntityManager<OauthScope> $manager |
66 | 65 | */ |
67 | - public function __construct(EntityManager $manager) |
|
68 | - { |
|
66 | + public function __construct(EntityManager $manager) { |
|
69 | 67 | parent::__construct($manager, OauthScope::class); |
70 | 68 | } |
71 | 69 | |
@@ -76,7 +74,7 @@ discard block |
||
76 | 74 | { |
77 | 75 | $result = $this->all(); |
78 | 76 | $scopes = []; |
79 | - foreach ($result as $row) { |
|
77 | + foreach ($result as $row) { |
|
80 | 78 | $scopes[] = Scope::createNewScope( |
81 | 79 | $row->id, |
82 | 80 | $row->name, |
@@ -96,7 +94,7 @@ discard block |
||
96 | 94 | ->where('is_default')->is(1) |
97 | 95 | ->all(); |
98 | 96 | $scopes = []; |
99 | - foreach ($result as $row) { |
|
97 | + foreach ($result as $row) { |
|
100 | 98 | $scopes[] = Scope::createNewScope( |
101 | 99 | $row->id, |
102 | 100 | $row->name, |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function cleanExpiredTokens(): void |
87 | 87 | { |
88 | 88 | $this->query()->where('expires')->lte(date('Y-m-d H:i:s')) |
89 | - ->delete(); |
|
89 | + ->delete(); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function deleteToken(BaseToken $token): bool |
96 | 96 | { |
97 | 97 | return $this->query()->where('authorization_code')->is($token->getToken()) |
98 | - ->delete() >= 0; |
|
98 | + ->delete() >= 0; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @package Platine\Framework\OAuth2\Repository |
62 | 62 | * @extends Repository<OauthAuthorizationCode> |
63 | 63 | */ |
64 | -class AuthorizationCodeRepository extends Repository implements AuthorizationCodeRepositoryInterface |
|
65 | -{ |
|
64 | +class AuthorizationCodeRepository extends Repository implements AuthorizationCodeRepositoryInterface { |
|
66 | 65 | /** |
67 | 66 | * The Client Service |
68 | 67 | * @var ClientService |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | * @param EntityManager<OauthAuthorizationCode> $manager |
75 | 74 | * @param ClientService $clientService |
76 | 75 | */ |
77 | - public function __construct(EntityManager $manager, ClientService $clientService) |
|
78 | - { |
|
76 | + public function __construct(EntityManager $manager, ClientService $clientService) { |
|
79 | 77 | parent::__construct($manager, OauthAuthorizationCode::class); |
80 | 78 | $this->clientService = $clientService; |
81 | 79 | } |
@@ -104,12 +102,12 @@ discard block |
||
104 | 102 | public function getByToken(string $token): ?BaseToken |
105 | 103 | { |
106 | 104 | $code = $this->find($token); |
107 | - if ($code === null) { |
|
105 | + if ($code === null) { |
|
108 | 106 | return null; |
109 | 107 | } |
110 | 108 | |
111 | 109 | $client = null; |
112 | - if ($code->client_id !== null) { |
|
110 | + if ($code->client_id !== null) { |
|
113 | 111 | $client = $this->clientService->find($code->client_id); |
114 | 112 | } |
115 | 113 | |
@@ -137,12 +135,12 @@ discard block |
||
137 | 135 | public function saveCode(AuthorizationCode $token): AuthorizationCode |
138 | 136 | { |
139 | 137 | $clientId = null; |
140 | - if ($token->getClient() !== null) { |
|
138 | + if ($token->getClient() !== null) { |
|
141 | 139 | $clientId = $token->getClient()->getId(); |
142 | 140 | } |
143 | 141 | |
144 | 142 | $ownerId = null; |
145 | - if ($token->getOwner() !== null) { |
|
143 | + if ($token->getOwner() !== null) { |
|
146 | 144 | $ownerId = $token->getOwner()->getOwnerId(); |
147 | 145 | } |
148 | 146 |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function cleanExpiredTokens(): void |
87 | 87 | { |
88 | 88 | $this->query()->where('expires')->lte(date('Y-m-d H:i:s')) |
89 | - ->delete(); |
|
89 | + ->delete(); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | public function deleteToken(BaseToken $token): bool |
96 | 96 | { |
97 | 97 | return $this->query()->where('access_token')->is($token->getToken()) |
98 | - ->delete() >= 0; |
|
98 | + ->delete() >= 0; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | * @package Platine\Framework\OAuth2\Repository |
62 | 62 | * @extends Repository<OauthAccessToken> |
63 | 63 | */ |
64 | -class AccessTokenRepository extends Repository implements AccessTokenRepositoryInterface |
|
65 | -{ |
|
64 | +class AccessTokenRepository extends Repository implements AccessTokenRepositoryInterface { |
|
66 | 65 | /** |
67 | 66 | * The Client Service |
68 | 67 | * @var ClientService |
@@ -74,8 +73,7 @@ discard block |
||
74 | 73 | * @param EntityManager<OauthAccessToken> $manager |
75 | 74 | * @param ClientService $clientService |
76 | 75 | */ |
77 | - public function __construct(EntityManager $manager, ClientService $clientService) |
|
78 | - { |
|
76 | + public function __construct(EntityManager $manager, ClientService $clientService) { |
|
79 | 77 | parent::__construct($manager, OauthAccessToken::class); |
80 | 78 | $this->clientService = $clientService; |
81 | 79 | } |
@@ -104,12 +102,12 @@ discard block |
||
104 | 102 | public function getByToken(string $token): ?BaseToken |
105 | 103 | { |
106 | 104 | $accessToken = $this->find($token); |
107 | - if ($accessToken === null) { |
|
105 | + if ($accessToken === null) { |
|
108 | 106 | return null; |
109 | 107 | } |
110 | 108 | |
111 | 109 | $client = null; |
112 | - if ($accessToken->client_id !== null) { |
|
110 | + if ($accessToken->client_id !== null) { |
|
113 | 111 | $client = $this->clientService->find($accessToken->client_id); |
114 | 112 | } |
115 | 113 | |
@@ -136,12 +134,12 @@ discard block |
||
136 | 134 | public function saveAccessToken(AccessToken $token): AccessToken |
137 | 135 | { |
138 | 136 | $clientId = null; |
139 | - if ($token->getClient() !== null) { |
|
137 | + if ($token->getClient() !== null) { |
|
140 | 138 | $clientId = $token->getClient()->getId(); |
141 | 139 | } |
142 | 140 | |
143 | 141 | $ownerId = null; |
144 | - if ($token->getOwner() !== null) { |
|
142 | + if ($token->getOwner() !== null) { |
|
145 | 143 | $ownerId = $token->getOwner()->getOwnerId(); |
146 | 144 | } |
147 | 145 |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | public static function mapEntity(EntityMapperInterface $mapper): void |
23 | 23 | { |
24 | - $mapper->primaryKey('access_token'); |
|
25 | - $mapper->useTimestamp(); |
|
26 | - $mapper->casts([ |
|
24 | + $mapper->primaryKey('access_token'); |
|
25 | + $mapper->useTimestamp(); |
|
26 | + $mapper->casts([ |
|
27 | 27 | 'expires' => 'date', |
28 | 28 | 'created_at' => 'date', |
29 | 29 | 'updated_at' => '?date', |
30 | - ]); |
|
30 | + ]); |
|
31 | 31 | } |
32 | 32 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | * @extends Entity<OauthAccessToken> |
14 | 14 | */ |
15 | -class OauthAccessToken extends Entity |
|
16 | -{ |
|
15 | +class OauthAccessToken extends Entity { |
|
17 | 16 | /** |
18 | 17 | * |
19 | 18 | * @param EntityMapperInterface<OauthAccessToken> $mapper |
@@ -20,12 +20,12 @@ |
||
20 | 20 | */ |
21 | 21 | public static function mapEntity(EntityMapperInterface $mapper): void |
22 | 22 | { |
23 | - $mapper->primaryKey('refresh_token'); |
|
24 | - $mapper->useTimestamp(); |
|
25 | - $mapper->casts([ |
|
23 | + $mapper->primaryKey('refresh_token'); |
|
24 | + $mapper->useTimestamp(); |
|
25 | + $mapper->casts([ |
|
26 | 26 | 'expires' => 'date', |
27 | 27 | 'created_at' => 'date', |
28 | 28 | 'updated_at' => '?date', |
29 | - ]); |
|
29 | + ]); |
|
30 | 30 | } |
31 | 31 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | * @extends Entity<OauthRefreshToken> |
14 | 14 | */ |
15 | -class OauthRefreshToken extends Entity |
|
16 | -{ |
|
15 | +class OauthRefreshToken extends Entity { |
|
17 | 16 | /** |
18 | 17 | * @param EntityMapperInterface<OauthRefreshToken> $mapper |
19 | 18 | * @return void |
@@ -21,10 +21,10 @@ |
||
21 | 21 | */ |
22 | 22 | public static function mapEntity(EntityMapperInterface $mapper): void |
23 | 23 | { |
24 | - $mapper->useTimestamp(); |
|
25 | - $mapper->casts([ |
|
24 | + $mapper->useTimestamp(); |
|
25 | + $mapper->casts([ |
|
26 | 26 | 'created_at' => 'date', |
27 | 27 | 'updated_at' => '?date', |
28 | - ]); |
|
28 | + ]); |
|
29 | 29 | } |
30 | 30 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | * @extends Entity<OauthClient> |
14 | 14 | */ |
15 | -class OauthClient extends Entity |
|
16 | -{ |
|
15 | +class OauthClient extends Entity { |
|
17 | 16 | /** |
18 | 17 | * |
19 | 18 | * @param EntityMapperInterface<OauthClient> $mapper |
@@ -21,10 +21,10 @@ |
||
21 | 21 | */ |
22 | 22 | public static function mapEntity(EntityMapperInterface $mapper): void |
23 | 23 | { |
24 | - $mapper->useTimestamp(); |
|
25 | - $mapper->casts([ |
|
24 | + $mapper->useTimestamp(); |
|
25 | + $mapper->casts([ |
|
26 | 26 | 'created_at' => 'date', |
27 | 27 | 'updated_at' => '?date', |
28 | - ]); |
|
28 | + ]); |
|
29 | 29 | } |
30 | 30 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | * @extends Entity<OauthScope> |
14 | 14 | */ |
15 | -class OauthScope extends Entity |
|
16 | -{ |
|
15 | +class OauthScope extends Entity { |
|
17 | 16 | /** |
18 | 17 | * |
19 | 18 | * @param EntityMapperInterface<OauthScope> $mapper |
@@ -21,12 +21,12 @@ |
||
21 | 21 | */ |
22 | 22 | public static function mapEntity(EntityMapperInterface $mapper): void |
23 | 23 | { |
24 | - $mapper->primaryKey('authorization_code'); |
|
25 | - $mapper->useTimestamp(); |
|
26 | - $mapper->casts([ |
|
24 | + $mapper->primaryKey('authorization_code'); |
|
25 | + $mapper->useTimestamp(); |
|
26 | + $mapper->casts([ |
|
27 | 27 | 'expires' => 'date', |
28 | 28 | 'created_at' => 'date', |
29 | 29 | 'updated_at' => '?date', |
30 | - ]); |
|
30 | + ]); |
|
31 | 31 | } |
32 | 32 | } |
@@ -12,8 +12,7 @@ |
||
12 | 12 | * @package Platine\Framework\OAuth2\Entity |
13 | 13 | * @extends Entity<OauthAuthorizationCode> |
14 | 14 | */ |
15 | -class OauthAuthorizationCode extends Entity |
|
16 | -{ |
|
15 | +class OauthAuthorizationCode extends Entity { |
|
17 | 16 | /** |
18 | 17 | * |
19 | 18 | * @param EntityMapperInterface<OauthAuthorizationCode> $mapper |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class RequestData |
55 | 55 | * @package Platine\Framework\Http |
56 | 56 | */ |
57 | -class RequestData |
|
58 | -{ |
|
57 | +class RequestData { |
|
59 | 58 | /** |
60 | 59 | * The request body or post data |
61 | 60 | * @var array<string, mixed> |
@@ -96,8 +95,7 @@ discard block |
||
96 | 95 | * Create new instance |
97 | 96 | * @param ServerRequestInterface $request |
98 | 97 | */ |
99 | - public function __construct(ServerRequestInterface $request) |
|
100 | - { |
|
98 | + public function __construct(ServerRequestInterface $request) { |
|
101 | 99 | $this->posts = (array) $request->getParsedBody(); |
102 | 100 | $this->gets = $request->getQueryParams(); |
103 | 101 | $this->servers = $request->getServerParams(); |
@@ -169,8 +167,7 @@ discard block |
||
169 | 167 | * |
170 | 168 | * @return mixed |
171 | 169 | */ |
172 | - public function get(string $key, $default = null) |
|
173 | - { |
|
170 | + public function get(string $key, $default = null) { |
|
174 | 171 | $gets = $this->applyInputClean($this->gets); |
175 | 172 | return Arr::get($gets, $key, $default); |
176 | 173 | } |
@@ -182,8 +179,7 @@ discard block |
||
182 | 179 | * |
183 | 180 | * @return mixed |
184 | 181 | */ |
185 | - public function post(string $key, $default = null) |
|
186 | - { |
|
182 | + public function post(string $key, $default = null) { |
|
187 | 183 | $posts = $this->applyInputClean($this->posts); |
188 | 184 | return Arr::get($posts, $key, $default); |
189 | 185 | } |
@@ -195,8 +191,7 @@ discard block |
||
195 | 191 | * |
196 | 192 | * @return mixed |
197 | 193 | */ |
198 | - public function server(string $key, $default = null) |
|
199 | - { |
|
194 | + public function server(string $key, $default = null) { |
|
200 | 195 | $servers = $this->applyInputClean($this->servers); |
201 | 196 | return Arr::get($servers, $key, $default); |
202 | 197 | } |
@@ -208,8 +203,7 @@ discard block |
||
208 | 203 | * |
209 | 204 | * @return mixed |
210 | 205 | */ |
211 | - public function cookie(string $key, $default = null) |
|
212 | - { |
|
206 | + public function cookie(string $key, $default = null) { |
|
213 | 207 | $cookies = $this->applyInputClean($this->cookies); |
214 | 208 | return Arr::get($cookies, $key, $default); |
215 | 209 | } |
@@ -220,8 +214,7 @@ discard block |
||
220 | 214 | * |
221 | 215 | * @return mixed |
222 | 216 | */ |
223 | - public function file(string $key) |
|
224 | - { |
|
217 | + public function file(string $key) { |
|
225 | 218 | $files = $this->files; |
226 | 219 | return Arr::get($files, $key, null); |
227 | 220 | } |
@@ -231,14 +224,13 @@ discard block |
||
231 | 224 | * @param mixed $str |
232 | 225 | * @return mixed |
233 | 226 | */ |
234 | - protected function cleanInput($str) |
|
235 | - { |
|
236 | - if (is_array($str)) { |
|
227 | + protected function cleanInput($str) { |
|
228 | + if (is_array($str)) { |
|
237 | 229 | return array_map([$this, 'cleanInput'], $str); |
238 | 230 | } |
239 | - if (is_object($str)) { |
|
231 | + if (is_object($str)) { |
|
240 | 232 | $obj = $str; |
241 | - foreach ($str as $var => $value) { |
|
233 | + foreach ($str as $var => $value) { |
|
242 | 234 | $obj->{$var} = $this->cleanInput($value); |
243 | 235 | } |
244 | 236 | return $obj; |
@@ -254,7 +246,7 @@ discard block |
||
254 | 246 | */ |
255 | 247 | protected function applyInputClean(array $data): array |
256 | 248 | { |
257 | - if ($this->autoEscape) { |
|
249 | + if ($this->autoEscape) { |
|
258 | 250 | $data = $this->cleanInput($data); |
259 | 251 | } |
260 | 252 |