SecurityBootstrapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getBindings() 0 4 1
A registerBindings() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Framework\Bootstrappers\Http\Middleware;
6
7
use AbterPhp\Framework\Constant\Env;
8
use AbterPhp\Framework\Environments\Environment;
9
use AbterPhp\Framework\Http\Middleware\Security;
10
use Opulence\Cache\ICacheBridge;
11
use Opulence\Ioc\Bootstrappers\Bootstrapper;
12
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
13
use Opulence\Ioc\IContainer;
14
use Opulence\Ioc\IocException;
15
16
class SecurityBootstrapper extends Bootstrapper implements ILazyBootstrapper
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function getBindings(): array
22
    {
23
        return [
24
            Security::class,
25
        ];
26
    }
27
28
    /**
29
     * @param IContainer $container
30
     *
31
     * @throws IocException
32
     */
33
    public function registerBindings(IContainer $container): void
34
    {
35
        $cacheBridge = $container->resolve(ICacheBridge::class);
36
        $environment = Environment::mustGetVar(Env::ENV_NAME);
37
38
        $security = new Security($cacheBridge, $environment);
39
40
        $container->bindInstance(Security::class, $security);
41
    }
42
}
43