Passed
Push — master ( 83c445...092c55 )
by Kirill
05:01
created

StrictCsrfFirewall::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Csrf\Middleware;
13
14
use Psr\Http\Message\ResponseFactoryInterface;
15
use Psr\Http\Message\ResponseInterface;
16
use Psr\Http\Message\ServerRequestInterface;
17
use Psr\Http\Server\MiddlewareInterface;
18
use Psr\Http\Server\RequestHandlerInterface;
19
20
/**
21
 * Requires CSRF token to presented in every passed request (no matter request method).
22
 */
23
final class StrictCsrfFirewall implements MiddlewareInterface
24
{
25
    /** @var CsrfFirewall */
26
    private $csrfFirewall;
27
28
    /**
29
     * @param ResponseFactoryInterface $responseFactory
30
     */
31
    public function __construct(ResponseFactoryInterface $responseFactory)
32
    {
33
        $this->csrfFirewall = new CsrfFirewall($responseFactory, []);
34
    }
35
36
    /**
37
     * @param ServerRequestInterface  $request
38
     * @param RequestHandlerInterface $handler
39
     * @return ResponseInterface
40
     */
41
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
42
    {
43
        return $this->csrfFirewall->process($request, $handler);
44
    }
45
}
46