@@ -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 |
@@ -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,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 | } |
@@ -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 |
@@ -53,14 +53,12 @@ |
||
53 | 53 | * @class RedirectResponse |
54 | 54 | * @package Platine\Framework\Http\Response |
55 | 55 | */ |
56 | -class RedirectResponse extends Response |
|
57 | -{ |
|
56 | +class RedirectResponse extends Response { |
|
58 | 57 | /** |
59 | 58 | * Create new instance |
60 | 59 | * @param string $url |
61 | 60 | */ |
62 | - public function __construct(string $url = '/') |
|
63 | - { |
|
61 | + public function __construct(string $url = '/') { |
|
64 | 62 | parent::__construct(302); |
65 | 63 | $this->headers['location'] = [$url]; |
66 | 64 | } |
@@ -81,7 +81,7 @@ |
||
81 | 81 | |
82 | 82 | $this->headers['content-description'] = ['File Transfer']; |
83 | 83 | $this->headers['content-type'] = [$mimetype]; |
84 | - $this->headers['content-disposition'] = ['attachment; filename="' . $filename . '"']; |
|
84 | + $this->headers['content-disposition'] = ['attachment; filename="' . $filename . '"']; |
|
85 | 85 | $this->headers['expires'] = ['0']; |
86 | 86 | $this->headers['cache-control'] = ['must-revalidate']; |
87 | 87 | $this->headers['pragma'] = ['public']; |
@@ -55,25 +55,23 @@ |
||
55 | 55 | * @class FileResponse |
56 | 56 | * @package Platine\Framework\Http\Response |
57 | 57 | */ |
58 | -class FileResponse extends Response |
|
59 | -{ |
|
58 | +class FileResponse extends Response { |
|
60 | 59 | /** |
61 | 60 | * Create new instance |
62 | 61 | * @param string $path |
63 | 62 | * @param string|null $filename |
64 | 63 | */ |
65 | - public function __construct(string $path, ?string $filename = null) |
|
66 | - { |
|
64 | + public function __construct(string $path, ?string $filename = null) { |
|
67 | 65 | parent::__construct(200); |
68 | 66 | |
69 | 67 | $realpath = Path::realPath($path); |
70 | 68 | $extension = pathinfo($realpath, PATHINFO_EXTENSION); |
71 | 69 | $mimetype = 'application/octet-stream'; |
72 | - if (!empty($extension)) { |
|
70 | + if (!empty($extension)) { |
|
73 | 71 | $mimetype = Path::getMimeByExtension($extension); |
74 | 72 | } |
75 | 73 | |
76 | - if (empty($filename)) { |
|
74 | + if (empty($filename)) { |
|
77 | 75 | $filename = basename($realpath); |
78 | 76 | } |
79 | 77 |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class TemplateResponse |
55 | 55 | * @package Platine\Framework\Http\Response |
56 | 56 | */ |
57 | -class TemplateResponse extends Response |
|
58 | -{ |
|
57 | +class TemplateResponse extends Response { |
|
59 | 58 | /** |
60 | 59 | * The template instance |
61 | 60 | * @var Template |
@@ -76,7 +75,7 @@ discard block |
||
76 | 75 | array $context = [], |
77 | 76 | int $statusCode = 200, |
78 | 77 | string $reasonPhrase = '' |
79 | - ) { |
|
78 | + ) { |
|
80 | 79 | parent::__construct($statusCode, $reasonPhrase); |
81 | 80 | $this->template = $template; |
82 | 81 | $this->getBody()->write($template->render($name, $context)); |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * @class JsonResponse |
55 | 55 | * @package Platine\Framework\Http\Response |
56 | 56 | */ |
57 | -class JsonResponse extends Response |
|
58 | -{ |
|
57 | +class JsonResponse extends Response { |
|
59 | 58 | /** |
60 | 59 | * Create new instance |
61 | 60 | * @param mixed $data |
@@ -66,7 +65,7 @@ discard block |
||
66 | 65 | $data, |
67 | 66 | int $statusCode = 200, |
68 | 67 | string $reasonPhrase = '' |
69 | - ) { |
|
68 | + ) { |
|
70 | 69 | parent::__construct($statusCode, $reasonPhrase); |
71 | 70 | |
72 | 71 | $this->headers['content-type'] = ['application/json']; |