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

EnvironmentWarningBootstrapper::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\EnvironmentWarning;
9
use AbterPhp\Framework\I18n\ITranslator;
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 EnvironmentWarningBootstrapper extends Bootstrapper implements ILazyBootstrapper
16
{
17
    /**
18
     * @return array
19
     */
20
    public function getBindings(): array
21
    {
22
        return [
23
            EnvironmentWarning::class,
24
        ];
25
    }
26
27
    /**
28
     * @param IContainer $container
29
     *
30
     * @throws \Opulence\Ioc\IocException
31
     */
32
    public function registerBindings(IContainer $container)
33
    {
34
        /** @var ITranslator $translator */
35
        $translator  = $container->resolve(ITranslator::class);
36
        $environment = Environment::getVar(Env::ENV_NAME);
37
38
        $environmentWarning = new EnvironmentWarning($translator, $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\...tWarning::__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

38
        $environmentWarning = new EnvironmentWarning($translator, /** @scrutinizer ignore-type */ $environment);
Loading history...
39
40
        $container->bindInstance(EnvironmentWarning::class, $environmentWarning);
41
    }
42
}
43