| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 1 | public function register(Container $container) |
|
| 18 | { |
||
| 19 | 1 | $container['csrf.tokenGenerator.entropy'] = 256; |
|
| 20 | |||
| 21 | $container['csrf.tokenGenerator'] = function () use ($container) { |
||
| 22 | 1 | return new CsrfTokenGenerator($container['csrf.tokenGenerator.entropy']); |
|
| 23 | }; |
||
| 24 | |||
| 25 | $container['csrf.errorResponseHandler'] = new class() implements CsrfErrorHandlerInterface { |
||
| 26 | 1 | public function errorResponse( |
|
| 27 | Request $request, |
||
| 28 | Response $response, |
||
| 29 | int $code, |
||
| 30 | string $reasonPhrase |
||
| 31 | ): Response { |
||
| 32 | 1 | return $response->withStatus($code, $reasonPhrase); |
|
| 33 | } |
||
| 34 | }; |
||
| 35 | |||
| 36 | 1 | $container['csrf.middleware'] = function () use ($container) { |
|
| 37 | 1 | return new CsrfErrorResponseMiddleware( |
|
| 38 | 1 | $container['csrf.tokenGenerator'], |
|
| 39 | 1 | $container['session'], |
|
| 40 | 1 | $container['csrf.errorResponseHandler'], |
|
| 41 | 1 | $container['logger'] ?? null |
|
| 42 | ); |
||
| 43 | }; |
||
| 44 | 1 | } |
|
| 45 | } |
||
| 46 |