@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __construct( |
18 | 18 | private readonly InvokerInterface $invoker, |
19 | - ) {} |
|
19 | + ){} |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @param non-empty-string $name |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function getValidation(string $name, array $params = []): ValidationInterface |
33 | 33 | { |
34 | - if (!isset($this->resolvers[$name])) { |
|
34 | + if (!isset($this->resolvers[$name])){ |
|
35 | 35 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
36 | 36 | } |
37 | 37 |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __construct( |
18 | 18 | private readonly InvokerInterface $invoker, |
19 | - ) {} |
|
19 | + ) { |
|
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * @param non-empty-string $name |
@@ -31,7 +32,8 @@ discard block |
||
31 | 32 | */ |
32 | 33 | public function getValidation(string $name, array $params = []): ValidationInterface |
33 | 34 | { |
34 | - if (!isset($this->resolvers[$name])) { |
|
35 | + if (!isset($this->resolvers[$name])) |
|
36 | + { |
|
35 | 37 | throw new ValidationException(\sprintf('Validation with name `%s` is not registered.', $name)); |
36 | 38 | } |
37 | 39 |
@@ -33,6 +33,6 @@ |
||
33 | 33 | new ServerRequest('GET', new Uri('/admin'), ['X-Auth-Token' => $token], 'php://input'), |
34 | 34 | ); |
35 | 35 | |
36 | - self::assertSame($token === 'ok' ? '/admin' : '/login', (string) $response->getBody()); |
|
36 | + self::assertSame($token === 'ok' ? '/admin' : '/login', (string)$response->getBody()); |
|
37 | 37 | } |
38 | 38 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | ); |
35 | 35 | |
36 | 36 | self::assertSame(200, $response->getStatusCode()); |
37 | - self::assertSame('success login', (string) $response->getBody()); |
|
37 | + self::assertSame('success login', (string)$response->getBody()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | #[DataProvider('failTokensDataProvider')] |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | self::assertSame(302, $response->getStatusCode()); |
59 | 59 | self::assertSame(['Location' => ['/login']], $response->getHeaders()); |
60 | - self::assertSame('', (string) $response->getBody()); |
|
60 | + self::assertSame('', (string)$response->getBody()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | #[DataProvider('failTokensDataProvider')] |
@@ -80,6 +80,6 @@ discard block |
||
80 | 80 | |
81 | 81 | self::assertSame(301, $response->getStatusCode()); |
82 | 82 | self::assertSame(['Location' => ['/login']], $response->getHeaders()); |
83 | - self::assertSame('', (string) $response->getBody()); |
|
83 | + self::assertSame('', (string)$response->getBody()); |
|
84 | 84 | } |
85 | 85 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $response = $http->handle(new ServerRequest('GET', '')); |
44 | 44 | |
45 | 45 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
46 | - self::assertSame(AuthContext::class, (string) $response->getBody()); |
|
46 | + self::assertSame(AuthContext::class, (string)$response->getBody()); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function testNoToken(): void |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $http->setHandler( |
62 | 62 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
63 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
63 | + if ($request->getAttribute('authContext')->getToken() === null){ |
|
64 | 64 | echo 'no token'; |
65 | 65 | } |
66 | 66 | }, |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $response = $http->handle(new ServerRequest('GET', '')); |
70 | 70 | |
71 | 71 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
72 | - self::assertSame('no token', (string) $response->getBody()); |
|
72 | + self::assertSame('no token', (string)$response->getBody()); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | protected function getCore(array $middleware = []): Http |
@@ -60,7 +60,8 @@ |
||
60 | 60 | |
61 | 61 | $http->setHandler( |
62 | 62 | static function (ServerRequestInterface $request, ResponseInterface $response): void { |
63 | - if ($request->getAttribute('authContext')->getToken() === null) { |
|
63 | + if ($request->getAttribute('authContext')->getToken() === null) |
|
64 | + { |
|
64 | 65 | echo 'no token'; |
65 | 66 | } |
66 | 67 | }, |
@@ -18,7 +18,7 @@ |
||
18 | 18 | ?string $clientFilename = null, |
19 | 19 | ?string $clientMediaType = null, |
20 | 20 | ): UploadedFileInterface { |
21 | - if ($size === null) { |
|
21 | + if ($size === null){ |
|
22 | 22 | $size = $stream->getSize(); |
23 | 23 | } |
24 | 24 |
@@ -18,7 +18,8 @@ |
||
18 | 18 | ?string $clientFilename = null, |
19 | 19 | ?string $clientMediaType = null, |
20 | 20 | ): UploadedFileInterface { |
21 | - if ($size === null) { |
|
21 | + if ($size === null) |
|
22 | + { |
|
22 | 23 | $size = $stream->getSize(); |
23 | 24 | } |
24 | 25 |
@@ -11,14 +11,14 @@ |
||
11 | 11 | |
12 | 12 | final class ResponseFactory implements ResponseFactoryInterface |
13 | 13 | { |
14 | - public function __construct(protected HttpConfig $config) {} |
|
14 | + public function __construct(protected HttpConfig $config){} |
|
15 | 15 | |
16 | 16 | public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
17 | 17 | { |
18 | 18 | $response = new Response($code); |
19 | 19 | $response = $response->withStatus($code, $reasonPhrase); |
20 | 20 | |
21 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
21 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
22 | 22 | $response = $response->withAddedHeader($header, $value); |
23 | 23 | } |
24 | 24 |
@@ -11,14 +11,17 @@ |
||
11 | 11 | |
12 | 12 | final class ResponseFactory implements ResponseFactoryInterface |
13 | 13 | { |
14 | - public function __construct(protected HttpConfig $config) {} |
|
14 | + public function __construct(protected HttpConfig $config) |
|
15 | + { |
|
16 | +} |
|
15 | 17 | |
16 | 18 | public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface |
17 | 19 | { |
18 | 20 | $response = new Response($code); |
19 | 21 | $response = $response->withStatus($code, $reasonPhrase); |
20 | 22 | |
21 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
23 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
24 | + { |
|
22 | 25 | $response = $response->withAddedHeader($header, $value); |
23 | 26 | } |
24 | 27 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | private readonly bool $secure = false, |
23 | 23 | private readonly bool $httpOnly = true, |
24 | 24 | private readonly ?string $sameSite = null, |
25 | - ) {} |
|
25 | + ){} |
|
26 | 26 | |
27 | 27 | public function fetchToken(Request $request): ?string |
28 | 28 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ): Response { |
39 | 39 | /** @var CookieQueue $cookieQueue */ |
40 | 40 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
41 | - if ($cookieQueue === null) { |
|
41 | + if ($cookieQueue === null){ |
|
42 | 42 | return $response->withAddedHeader( |
43 | 43 | 'Set-Cookie', |
44 | 44 | Cookie::create( |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
57 | - if ($tokenID === null) { |
|
57 | + if ($tokenID === null){ |
|
58 | 58 | $cookieQueue->delete($this->cookie); |
59 | - } else { |
|
59 | + }else{ |
|
60 | 60 | $cookieQueue->set( |
61 | 61 | $this->cookie, |
62 | 62 | $tokenID, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int |
85 | 85 | { |
86 | - if ($expiresAt === null) { |
|
86 | + if ($expiresAt === null){ |
|
87 | 87 | return null; |
88 | 88 | } |
89 | 89 |
@@ -22,7 +22,8 @@ discard block |
||
22 | 22 | private readonly bool $secure = false, |
23 | 23 | private readonly bool $httpOnly = true, |
24 | 24 | private readonly ?string $sameSite = null, |
25 | - ) {} |
|
25 | + ) { |
|
26 | +} |
|
26 | 27 | |
27 | 28 | public function fetchToken(Request $request): ?string |
28 | 29 | { |
@@ -38,7 +39,8 @@ discard block |
||
38 | 39 | ): Response { |
39 | 40 | /** @var CookieQueue $cookieQueue */ |
40 | 41 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
41 | - if ($cookieQueue === null) { |
|
42 | + if ($cookieQueue === null) |
|
43 | + { |
|
42 | 44 | return $response->withAddedHeader( |
43 | 45 | 'Set-Cookie', |
44 | 46 | Cookie::create( |
@@ -54,9 +56,12 @@ discard block |
||
54 | 56 | ); |
55 | 57 | } |
56 | 58 | |
57 | - if ($tokenID === null) { |
|
59 | + if ($tokenID === null) |
|
60 | + { |
|
58 | 61 | $cookieQueue->delete($this->cookie); |
59 | - } else { |
|
62 | + } |
|
63 | + else |
|
64 | + { |
|
60 | 65 | $cookieQueue->set( |
61 | 66 | $this->cookie, |
62 | 67 | $tokenID, |
@@ -83,7 +88,8 @@ discard block |
||
83 | 88 | */ |
84 | 89 | private function getLifetime(?\DateTimeInterface $expiresAt = null): ?int |
85 | 90 | { |
86 | - if ($expiresAt === null) { |
|
91 | + if ($expiresAt === null) |
|
92 | + { |
|
87 | 93 | return null; |
88 | 94 | } |
89 | 95 |
@@ -16,10 +16,10 @@ |
||
16 | 16 | protected readonly UriInterface $uri, |
17 | 17 | protected readonly ResponseFactoryInterface $responseFactory, |
18 | 18 | protected readonly int $status = 302, |
19 | - ) {} |
|
19 | + ){} |
|
20 | 20 | |
21 | 21 | protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response |
22 | 22 | { |
23 | - return $this->responseFactory->createResponse($this->status)->withHeader('Location', (string) $this->uri); |
|
23 | + return $this->responseFactory->createResponse($this->status)->withHeader('Location', (string)$this->uri); |
|
24 | 24 | } |
25 | 25 | } |
@@ -16,7 +16,8 @@ |
||
16 | 16 | protected readonly UriInterface $uri, |
17 | 17 | protected readonly ResponseFactoryInterface $responseFactory, |
18 | 18 | protected readonly int $status = 302, |
19 | - ) {} |
|
19 | + ) { |
|
20 | +} |
|
20 | 21 | |
21 | 22 | protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response |
22 | 23 | { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | private readonly UriInterface $uri, |
19 | 19 | private readonly int $status = 401, |
20 | - ) {} |
|
20 | + ){} |
|
21 | 21 | |
22 | 22 | protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response |
23 | 23 | { |
@@ -17,7 +17,8 @@ |
||
17 | 17 | public function __construct( |
18 | 18 | private readonly UriInterface $uri, |
19 | 19 | private readonly int $status = 401, |
20 | - ) {} |
|
20 | + ) { |
|
21 | +} |
|
21 | 22 | |
22 | 23 | protected function denyAccess(Request $request, RequestHandlerInterface $handler): Response |
23 | 24 | { |