Passed
Pull Request — 1.x (#334)
by Akihito
02:32
created

SemanticLoggerModule::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 11
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\SemanticLog\Module;
6
7
use BEAR\Resource\Invoker;
8
use BEAR\Resource\InvokerInterface;
9
use BEAR\Resource\SemanticLog\ContextFactoryInterface;
10
use BEAR\Resource\SemanticLog\Profile\Compact\ContextFactory;
11
use BEAR\Resource\SemanticLog\SemanticInvoker;
12
use Koriym\SemanticLogger\SemanticLogger;
13
use Koriym\SemanticLogger\SemanticLoggerInterface;
14
use Override;
15
use Ray\Di\AbstractModule;
16
use Ray\Di\Scope;
17
18
final class SemanticLoggerModule extends AbstractModule
19
{
20
    #[Override]
21
    protected function configure(): void
22
    {
23
        $this->bind(SemanticLoggerInterface::class)->to(SemanticLogger::class)->in(Scope::SINGLETON);
24
        $this->bind(ContextFactoryInterface::class)->to(ContextFactory::class)->in(Scope::SINGLETON);
25
26
        // Bind the original invoker with annotation so our adapter can inject it
27
        $this->bind(InvokerInterface::class)->annotatedWith('original')->to(Invoker::class);
28
29
        // Override the default invoker with our semantic logging adapter
30
        $this->bind(InvokerInterface::class)->to(SemanticInvoker::class);
31
    }
32
}
33