Completed
Push — logger ( 8c349b...62e943 )
by Akihito
03:41 queued 02:20
created

LoggerModule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\Module;
6
7
use Ray\Di\AbstractModule;
8
9
final class LoggerModule extends AbstractModule
10
{
11
    /**
12
     * Log Level for Production
13
     *
14
     * Log only unsafe method.
15
     */
16
    const LOG_LEVEL_PROD = 0;
17
18
    /**
19
     * Log level for development L0
20
     *
21
     * Log all request
22
     */
23
    const LOG_LEVEL_DEV = 1;
24
25
    /**
26
     * Log level for development L1
27
     *
28
     * Log all request and request result
29
     */
30
    const LOG_LEVEL_DEV_RESPONSE = 2;
31
32
    /**
33
     * @var string
34
     */
35
    private $level;
36
37
    /**
38
     * @var AbstractModule
39
     */
40
    private $module;
41
42
    public function __construct(string $level, AbstractModule $module)
43
    {
44
        $this->level = $level;
45
        $this->module = $module;
46
        parent::__construct($module);
47
    }
48
49
    protected function configure()
50
    {
51
        if ($this->level === self::LOG_LEVEL_PROD) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of $this->level (string) and self::LOG_LEVEL_PROD (integer) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
52
            $this->bind(LoggerInterface::class)->to(ProdLogger::class);
53
        }
54
        if ($this->level === self::LOG_LEVEL_DEV) {
0 ignored issues
show
Unused Code Bug introduced by
The strict comparison === seems to always evaluate to false as the types of $this->level (string) and self::LOG_LEVEL_DEV (integer) can never be identical. Maybe you want to use a loose comparison == instead?
Loading history...
55
            $this->bind(LoggerInterface::class)->to(DevZeroLogger::class);
56
        }
57
        $this->bind(LoggerInterface::class)->to(DevOneLogger::class);
58
    }
59
}
60