Passed
Push — master ( 8926af...beb5fc )
by Anton
02:16
created

CsrfBootloader::defineDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Spiral\Bootloader\Http;
11
12
use Spiral\Boot\Bootloader\Bootloader;
13
use Spiral\Config\ConfiguratorInterface;
14
use Spiral\Csrf\Middleware\CsrfMiddleware;
15
16
final class CsrfBootloader extends Bootloader
17
{
18
    const DEPENDENCIES = [
19
        HttpBootloader::class
20
    ];
21
22
    /**
23
     * @param ConfiguratorInterface $config
24
     * @param HttpBootloader        $http
25
     */
26
    public function boot(ConfiguratorInterface $config, HttpBootloader $http)
27
    {
28
        $config->setDefaults('csrf', [
29
            'cookie'   => 'csrf-token',
30
            'length'   => 16,
31
            'lifetime' => 86400
32
        ]);
33
34
        $http->addMiddleware(CsrfMiddleware::class);
35
    }
36
}
37