Passed
Push — master ( a13ecb...04451c )
by Peter
02:15
created

SecurityBootstrapper::getBindings()   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
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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\Http\Middleware\Security;
9
use Opulence\Cache\ICacheBridge;
10
use Opulence\Environments\Environment;
11
use Opulence\Ioc\Bootstrappers\Bootstrapper;
12
use Opulence\Ioc\Bootstrappers\ILazyBootstrapper;
13
use Opulence\Ioc\IContainer;
14
15
class SecurityBootstrapper extends Bootstrapper implements ILazyBootstrapper
16
{
17
    /**
18
     * @return array
19
     */
20
    public function getBindings(): array
21
    {
22
        return [
23
            Security::class,
24
        ];
25
    }
26
27
    /**
28
     * @param IContainer $container
29
     *
30
     * @throws \Opulence\Ioc\IocException
31
     */
32
    public function registerBindings(IContainer $container)
33
    {
34
        $cacheBridge = $container->resolve(ICacheBridge::class);
35
        $environment = Environment::getVar(Env::ENV_NAME);
36
37
        $security = new Security($cacheBridge, $environment);
0 ignored issues
show
Bug introduced by
It seems like $environment can also be of type null; however, parameter $environment of AbterPhp\Framework\Http\...Security::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        $security = new Security($cacheBridge, /** @scrutinizer ignore-type */ $environment);
Loading history...
38
39
        $container->bindInstance(Security::class, $security);
40
    }
41
}
42